import { memo, useState } from 'react'; import type { ReactNode } from 'react'; import { useNavigate } from 'react-router-dom'; import { LayoutPriority } from 'allotment'; import classNames from 'classnames'; import AutoSizer from 'react-virtualized-auto-sizer'; import type { PinnedAsset } from '@vegaprotocol/accounts'; import { t } from '@vegaprotocol/i18n'; import { OracleBanner } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets'; import { Filter } from '@vegaprotocol/orders'; import { usePaneLayout, useScreenDimensions, } from '@vegaprotocol/react-helpers'; import { Tab, LocalStoragePersistTabs as Tabs, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; import { useMarketClickHandler, useMarketLiquidityClickHandler, } from '../../lib/hooks/use-market-click-handler'; import { VegaWalletContainer } from '../../components/vega-wallet-container'; import { HeaderTitle } from '../../components/header'; import { ResizableGrid, ResizableGridPanel, } from '../../components/resizable-grid'; import { TradingViews } from './trade-views'; import { MarketSelector } from './market-selector'; import { HeaderStats } from './header-stats'; interface TradeGridProps { market: Market | null; onSelect: (marketId: string, metaKey?: boolean) => void; pinnedAsset?: PinnedAsset; } interface BottomPanelProps { marketId: string; pinnedAsset?: PinnedAsset; } const MarketBottomPanel = memo( ({ marketId, pinnedAsset }: BottomPanelProps) => { const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'bottom' }); const { screenSize } = useScreenDimensions(); const onMarketClick = useMarketClickHandler(true); const onOrderTypeClick = useMarketLiquidityClickHandler(); return 'xxxl' === screenSize ? ( ) : ( ); } ); MarketBottomPanel.displayName = 'MarketBottomPanel'; const MainGrid = memo( ({ marketId, pinnedAsset, }: { marketId: string; pinnedAsset?: PinnedAsset; }) => { const navigate = useNavigate(); const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'top' }); const [sizesMiddle, handleOnMiddleLayoutChange] = usePaneLayout({ id: 'middle-1', }); const onMarketClick = useMarketClickHandler(true); return ( navigate('/portfolio')} /> ); } ); MainGrid.displayName = 'MainGrid'; export const TradeGrid = ({ market, pinnedAsset }: TradeGridProps) => { const [sidebarOpen, setSidebarOpen] = useState(true); const wrapperClasses = classNames( 'h-full grid', 'grid-rows-[min-content_min-content_1fr]', 'grid-cols-[320px_1fr]' ); const paneWrapperClasses = classNames('min-h-0', { 'col-span-2 col-start-1': !sidebarOpen, }); return (
{sidebarOpen && (
)}
); }; interface TradeGridChildProps { children: ReactNode; } const TradeGridChild = ({ children }: TradeGridChildProps) => { return (
{({ width, height }) =>
{children}
}
); };