2023-05-16 16:57:36 +00:00
|
|
|
import { memo, useState } from 'react';
|
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { LayoutPriority } from 'allotment';
|
feat: market list mega dropdown (rich popover) (#889)
* feat: use MarketList query only
* fix: remove Market.ts from index
* feat: 30 refactor dialog, market list, change query
* feat: #30 add indicativeVolume, total fees, tooltip, large dialog, tooltip accepts html description
* fix: #30 total fees display in tooltip
* fix: #30 toggle title on dialog open
* fix: #30 fix order, price, high, low utils
* fix: #30 fix test for market utils
* feat: #30 add popover with markets to select
* feat: #30 storybook popover
* feat: #30 remove border on trigger and add some other classes
* fix: #30 fix format check with format:write
* feat: #30 add tooltip on taker fee
* feat: #30 add tooltip on taker fee
* fix: #30 format on select market list
* fix: #30 remove unknown cast in test mock data
* fix: #30 show markets where you have open positions
* fix: #30 double check if open positions
* fix: #30 dialog has only small/large sizes
* feat: #30 add border on trigger and change padding and no wrap
* fix: #30 if fees or factors are not found
* fix: #30 remove markets.cy tests as markets page is now gone
* fix #30 remove view full market list test
* fix: #30 add rotating arrow on market title
* fix: #30 add ease-in-out on popover
* fix: #30 add ease-in-out on popover
* fix: #30 align select a market table
* fix: #30 select a market title
* fix: #30 select a market title
* fix: #30 fix any validateDOMnesting issues
* fix: #30 show loading market data
* fix: #30 add list of header columns
* fix: #30 add list of header columns
* fix: #30 small refactoring after review
* fix: #30 update bold undreline class names
* fix: #30 add large-mobile size
* feat: #30 refactor select markets tables to render array of columns
* fix: #30 remove size from select market dialog
* fix: #30 add extra file for columns
* fix: #30 update formtting
* fix: #30 make sure popup closes on same market navigation
* fix: rename market-utils, add calcCandle methods, store market id on select
* fix: useMemo ondata and marketPositionData + orderbook stories fix
* feat: #30 add open volume positions
* fix: add market summary back
* fix: update formatting
* fix: use currentcolor on arrow
* fix: create all markets page
* fix: add overflow-y auto
* fix: enlarge select market to get started dialog
* fix: revert markets container
* fix: use query to fix flickering on position markets
* fix: edit unordered list in tooltips
* fix: fix tooltip table
* fix: fix home.cy.ts
* chore: skip /markets tests
2022-08-11 11:56:35 +00:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
2023-05-16 16:57:36 +00:00
|
|
|
import type { PinnedAsset } from '@vegaprotocol/accounts';
|
2023-02-28 18:56:29 +00:00
|
|
|
import { t } from '@vegaprotocol/i18n';
|
2023-05-18 11:22:54 +00:00
|
|
|
import { OracleBanner } from '@vegaprotocol/markets';
|
|
|
|
import type { Market } from '@vegaprotocol/markets';
|
2023-05-16 16:57:36 +00:00
|
|
|
import { Filter } from '@vegaprotocol/orders';
|
2023-05-03 08:44:45 +00:00
|
|
|
import {
|
|
|
|
usePaneLayout,
|
|
|
|
useScreenDimensions,
|
|
|
|
} from '@vegaprotocol/react-helpers';
|
2023-05-16 16:57:36 +00:00
|
|
|
import {
|
|
|
|
Tab,
|
|
|
|
LocalStoragePersistTabs as Tabs,
|
|
|
|
VegaIcon,
|
|
|
|
VegaIconNames,
|
|
|
|
} from '@vegaprotocol/ui-toolkit';
|
2023-04-18 12:55:11 +00:00
|
|
|
import {
|
|
|
|
useMarketClickHandler,
|
|
|
|
useMarketLiquidityClickHandler,
|
|
|
|
} from '../../lib/hooks/use-market-click-handler';
|
2023-05-16 16:57:36 +00:00
|
|
|
import { VegaWalletContainer } from '../../components/vega-wallet-container';
|
|
|
|
import { HeaderTitle } from '../../components/header';
|
2023-04-21 15:16:04 +00:00
|
|
|
import {
|
|
|
|
ResizableGrid,
|
|
|
|
ResizableGridPanel,
|
|
|
|
} from '../../components/resizable-grid';
|
2023-05-16 16:57:36 +00:00
|
|
|
import { TradingViews } from './trade-views';
|
|
|
|
import { MarketSelector } from './market-selector';
|
|
|
|
import { HeaderStats } from './header-stats';
|
2022-03-28 19:34:45 +00:00
|
|
|
|
2022-06-20 23:52:25 +00:00
|
|
|
interface TradeGridProps {
|
2023-02-09 14:20:31 +00:00
|
|
|
market: Market | null;
|
2023-03-31 13:23:44 +00:00
|
|
|
onSelect: (marketId: string, metaKey?: boolean) => void;
|
2023-02-17 13:32:20 +00:00
|
|
|
pinnedAsset?: PinnedAsset;
|
2022-06-20 23:52:25 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 09:50:43 +00:00
|
|
|
interface BottomPanelProps {
|
2022-10-11 12:30:07 +00:00
|
|
|
marketId: string;
|
2023-02-17 13:32:20 +00:00
|
|
|
pinnedAsset?: PinnedAsset;
|
2023-03-17 09:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const MarketBottomPanel = memo(
|
|
|
|
({ marketId, pinnedAsset }: BottomPanelProps) => {
|
2023-05-03 08:44:45 +00:00
|
|
|
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'bottom' });
|
2023-03-17 09:50:43 +00:00
|
|
|
const { screenSize } = useScreenDimensions();
|
2023-03-31 13:23:44 +00:00
|
|
|
const onMarketClick = useMarketClickHandler(true);
|
2023-04-18 12:55:11 +00:00
|
|
|
const onOrderTypeClick = useMarketLiquidityClickHandler(true);
|
2023-03-17 09:50:43 +00:00
|
|
|
|
|
|
|
return 'xxxl' === screenSize ? (
|
2023-05-03 08:44:45 +00:00
|
|
|
<ResizableGrid
|
|
|
|
proportionalLayout
|
|
|
|
minSize={200}
|
|
|
|
onChange={handleOnLayoutChange}
|
|
|
|
>
|
2023-03-17 09:50:43 +00:00
|
|
|
<ResizableGridPanel
|
|
|
|
priority={LayoutPriority.Low}
|
2023-05-03 08:44:45 +00:00
|
|
|
preferredSize={sizes[0] || '50%'}
|
2023-03-17 09:50:43 +00:00
|
|
|
minSize={50}
|
|
|
|
>
|
|
|
|
<TradeGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-trade-grid-bottom-left">
|
2023-05-04 10:09:55 +00:00
|
|
|
<Tab id="open-orders" name={t('Open')}>
|
2023-03-17 09:50:43 +00:00
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Open}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketOpenOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="closed-orders" name={t('Closed')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Closed}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketClosedOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="rejected-orders" name={t('Rejected')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Rejected}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketRejectOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="orders" name={t('All')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
2023-02-14 15:43:52 +00:00
|
|
|
marketId={marketId}
|
2023-03-17 09:50:43 +00:00
|
|
|
onMarketClick={onMarketClick}
|
2023-04-18 12:55:11 +00:00
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
2023-03-23 08:13:07 +00:00
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketAllOrders"
|
2023-02-14 15:43:52 +00:00
|
|
|
/>
|
2023-03-17 09:50:43 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="fills" name={t('Fills')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.fills.component
|
2022-12-14 12:59:59 +00:00
|
|
|
marketId={marketId}
|
2023-03-17 09:50:43 +00:00
|
|
|
onMarketClick={onMarketClick}
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketFills"
|
2022-12-14 12:59:59 +00:00
|
|
|
/>
|
2023-03-17 09:50:43 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
<ResizableGridPanel
|
|
|
|
priority={LayoutPriority.Low}
|
2023-05-03 08:44:45 +00:00
|
|
|
preferredSize={sizes[1] || '50%'}
|
2023-03-17 09:50:43 +00:00
|
|
|
minSize={50}
|
|
|
|
>
|
|
|
|
<TradeGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-trade-grid-bottom-right">
|
2023-03-17 09:50:43 +00:00
|
|
|
<Tab id="positions" name={t('Positions')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.positions.component
|
2023-03-17 09:50:43 +00:00
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
noBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketPositions"
|
2023-03-17 09:50:43 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="accounts" name={t('Collateral')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.collateral.component
|
2023-03-17 09:50:43 +00:00
|
|
|
pinnedAsset={pinnedAsset}
|
2023-06-16 10:28:59 +00:00
|
|
|
onMarketClick={onMarketClick}
|
2023-03-17 09:50:43 +00:00
|
|
|
hideButtons
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketCollateral"
|
2023-03-17 09:50:43 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
</ResizableGrid>
|
|
|
|
) : (
|
|
|
|
<TradeGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-trade-grid-bottom">
|
2023-03-17 09:50:43 +00:00
|
|
|
<Tab id="positions" name={t('Positions')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-09 06:09:53 +00:00
|
|
|
<TradingViews.positions.component
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
storeKey="marketPositions"
|
|
|
|
/>
|
2023-03-17 09:50:43 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
2023-05-04 10:09:55 +00:00
|
|
|
<Tab id="open-orders" name={t('Open')}>
|
2023-03-17 09:50:43 +00:00
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Open}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketOpenOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="closed-orders" name={t('Closed')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Closed}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketClosedOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="rejected-orders" name={t('Rejected')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
|
|
|
marketId={marketId}
|
|
|
|
filter={Filter.Rejected}
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketRejectedOrders"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="orders" name={t('All')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<TradingViews.orders.component
|
2023-03-17 09:50:43 +00:00
|
|
|
marketId={marketId}
|
|
|
|
onMarketClick={onMarketClick}
|
2023-04-18 12:55:11 +00:00
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
2023-03-23 08:13:07 +00:00
|
|
|
enforceBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketAllOrders"
|
2023-03-17 09:50:43 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="fills" name={t('Fills')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.fills.component
|
2023-03-17 09:50:43 +00:00
|
|
|
marketId={marketId}
|
|
|
|
onMarketClick={onMarketClick}
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketFills"
|
2023-03-17 09:50:43 +00:00
|
|
|
/>
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="accounts" name={t('Collateral')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.collateral.component
|
|
|
|
pinnedAsset={pinnedAsset}
|
2023-06-16 10:28:59 +00:00
|
|
|
onMarketClick={onMarketClick}
|
2023-05-04 10:09:55 +00:00
|
|
|
hideButtons
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="marketCollateral"
|
2023-05-04 10:09:55 +00:00
|
|
|
/>
|
2023-03-17 09:50:43 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
MarketBottomPanel.displayName = 'MarketBottomPanel';
|
|
|
|
|
|
|
|
const MainGrid = memo(
|
|
|
|
({
|
|
|
|
marketId,
|
|
|
|
pinnedAsset,
|
|
|
|
}: {
|
|
|
|
marketId: string;
|
|
|
|
pinnedAsset?: PinnedAsset;
|
|
|
|
}) => {
|
|
|
|
const navigate = useNavigate();
|
2023-05-22 14:09:37 +00:00
|
|
|
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'top' });
|
2023-05-03 08:44:45 +00:00
|
|
|
const [sizesMiddle, handleOnMiddleLayoutChange] = usePaneLayout({
|
2023-05-22 14:09:37 +00:00
|
|
|
id: 'middle-1',
|
2023-05-03 08:44:45 +00:00
|
|
|
});
|
2023-06-16 10:28:59 +00:00
|
|
|
const onMarketClick = useMarketClickHandler(true);
|
2023-05-03 08:44:45 +00:00
|
|
|
|
2023-03-17 09:50:43 +00:00
|
|
|
return (
|
2023-05-03 08:44:45 +00:00
|
|
|
<ResizableGrid vertical onChange={handleOnLayoutChange}>
|
2023-03-17 09:50:43 +00:00
|
|
|
<ResizableGridPanel minSize={75} priority={LayoutPriority.High}>
|
2023-05-03 08:44:45 +00:00
|
|
|
<ResizableGrid
|
|
|
|
proportionalLayout={false}
|
|
|
|
minSize={200}
|
|
|
|
onChange={handleOnMiddleLayoutChange}
|
|
|
|
>
|
2023-03-17 09:50:43 +00:00
|
|
|
<ResizableGridPanel
|
2023-05-22 13:40:42 +00:00
|
|
|
preferredSize={sizesMiddle[0] || 330}
|
2023-03-17 09:50:43 +00:00
|
|
|
minSize={300}
|
|
|
|
>
|
|
|
|
<TradeGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-trade-grid-main-center">
|
2023-03-17 09:50:43 +00:00
|
|
|
<Tab id="ticket" name={t('Ticket')}>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.ticket.component
|
2023-03-17 09:50:43 +00:00
|
|
|
marketId={marketId}
|
2023-06-16 10:28:59 +00:00
|
|
|
onMarketClick={onMarketClick}
|
2023-03-17 09:50:43 +00:00
|
|
|
onClickCollateral={() => navigate('/portfolio')}
|
|
|
|
/>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="info" name={t('Info')}>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.info.component marketId={marketId} />
|
2023-03-17 09:50:43 +00:00
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
<ResizableGridPanel
|
2023-05-22 15:55:02 +00:00
|
|
|
priority={LayoutPriority.High}
|
2023-05-22 13:40:42 +00:00
|
|
|
minSize={200}
|
|
|
|
preferredSize={sizesMiddle[1] || '50%'}
|
|
|
|
>
|
|
|
|
<TradeGridChild>
|
|
|
|
<Tabs storageKey="console-trade-grid-main-left">
|
|
|
|
<Tab id="chart" name={t('Chart')}>
|
|
|
|
<TradingViews.candles.component marketId={marketId} />
|
|
|
|
</Tab>
|
|
|
|
<Tab id="depth" name={t('Depth')}>
|
|
|
|
<TradingViews.depth.component marketId={marketId} />
|
|
|
|
</Tab>
|
|
|
|
<Tab id="liquidity" name={t('Liquidity')}>
|
|
|
|
<TradingViews.liquidity.component marketId={marketId} />
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
<ResizableGridPanel
|
2023-06-07 08:58:34 +00:00
|
|
|
preferredSize={sizesMiddle[2] || 300}
|
2023-03-17 09:50:43 +00:00
|
|
|
minSize={200}
|
|
|
|
>
|
|
|
|
<TradeGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-trade-grid-main-right">
|
2023-03-17 09:50:43 +00:00
|
|
|
<Tab id="orderbook" name={t('Orderbook')}>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.orderbook.component marketId={marketId} />
|
2023-03-17 09:50:43 +00:00
|
|
|
</Tab>
|
|
|
|
<Tab id="trades" name={t('Trades')}>
|
2023-05-04 10:09:55 +00:00
|
|
|
<TradingViews.trades.component marketId={marketId} />
|
2023-03-17 09:50:43 +00:00
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</TradeGridChild>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
</ResizableGrid>
|
|
|
|
</ResizableGridPanel>
|
|
|
|
<ResizableGridPanel
|
|
|
|
priority={LayoutPriority.Low}
|
2023-05-03 08:44:45 +00:00
|
|
|
preferredSize={sizes[1] || '25%'}
|
2023-03-17 09:50:43 +00:00
|
|
|
minSize={50}
|
|
|
|
>
|
|
|
|
<MarketBottomPanel marketId={marketId} pinnedAsset={pinnedAsset} />
|
|
|
|
</ResizableGridPanel>
|
|
|
|
</ResizableGrid>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
MainGrid.displayName = 'MainGrid';
|
2022-10-11 12:30:07 +00:00
|
|
|
|
2023-05-16 16:57:36 +00:00
|
|
|
export const TradeGrid = ({ market, pinnedAsset }: TradeGridProps) => {
|
|
|
|
const [sidebarOpen, setSidebarOpen] = useState(true);
|
|
|
|
const wrapperClasses = classNames(
|
|
|
|
'h-full grid',
|
|
|
|
'grid-rows-[min-content_min-content_1fr]',
|
2023-05-17 01:45:17 +00:00
|
|
|
'grid-cols-[320px_1fr]'
|
2023-05-16 16:57:36 +00:00
|
|
|
);
|
|
|
|
const paneWrapperClasses = classNames('min-h-0', {
|
|
|
|
'col-span-2 col-start-1': !sidebarOpen,
|
|
|
|
});
|
|
|
|
|
2022-10-11 12:30:07 +00:00
|
|
|
return (
|
2023-05-16 16:57:36 +00:00
|
|
|
<div className={wrapperClasses}>
|
|
|
|
<div className="border-b border-r border-default">
|
2023-05-23 04:33:16 +00:00
|
|
|
<div className="h-full flex gap-2 justify-between items-end px-4 pt-1 pb-3">
|
2023-05-16 16:57:36 +00:00
|
|
|
<HeaderTitle
|
|
|
|
primaryContent={market?.tradableInstrument.instrument.code}
|
|
|
|
secondaryContent={market?.tradableInstrument.instrument.name}
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
onClick={() => setSidebarOpen((x) => !x)}
|
2023-05-23 04:33:16 +00:00
|
|
|
className="flex flex-col items-center text-xs w-12"
|
2023-05-16 16:57:36 +00:00
|
|
|
data-testid="sidebar-toggle"
|
|
|
|
>
|
2023-05-23 04:33:16 +00:00
|
|
|
{sidebarOpen ? (
|
|
|
|
<>
|
|
|
|
<VegaIcon name={VegaIconNames.CHEVRON_UP} />
|
|
|
|
<span className="text-vega-light-300 dark:text-vega-dark-300">
|
|
|
|
{t('Close')}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<VegaIcon name={VegaIconNames.CHEVRON_DOWN} />
|
|
|
|
<span className="text-vega-light-300 dark:text-vega-dark-300">
|
|
|
|
{t('Markets')}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2023-05-16 16:57:36 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="border-b border-default min-w-0">
|
|
|
|
<HeaderStats market={market} />
|
|
|
|
</div>
|
|
|
|
<div className="col-span-2 bg-vega-green">
|
2023-04-21 16:31:52 +00:00
|
|
|
<OracleBanner marketId={market?.id || ''} />
|
|
|
|
</div>
|
2023-05-16 16:57:36 +00:00
|
|
|
{sidebarOpen && (
|
|
|
|
<div className="border-r border-default min-h-0">
|
|
|
|
<div className="h-full pb-8">
|
|
|
|
<MarketSelector currentMarketId={market?.id} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className={paneWrapperClasses}>
|
|
|
|
<MainGrid marketId={market?.id || ''} pinnedAsset={pinnedAsset} />
|
|
|
|
</div>
|
2022-08-31 04:35:46 +00:00
|
|
|
</div>
|
2022-03-02 02:08:42 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
interface TradeGridChildProps {
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
2022-08-31 04:35:46 +00:00
|
|
|
const TradeGridChild = ({ children }: TradeGridChildProps) => {
|
2022-03-02 02:08:42 +00:00
|
|
|
return (
|
2022-08-31 04:35:46 +00:00
|
|
|
<section className="h-full">
|
2022-03-02 02:08:42 +00:00
|
|
|
<AutoSizer>
|
2022-09-13 08:19:41 +00:00
|
|
|
{({ width, height }) => <div style={{ width, height }}>{children}</div>}
|
2022-03-02 02:08:42 +00:00
|
|
|
</AutoSizer>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
};
|