feat: add resizable panels to portfolio page (#888)
* chore: fix padding issues * chore: add resizable panels to portfolio page * chore: padding tweak * chore: adding resizable panels component
This commit is contained in:
parent
0a88087f47
commit
f46d7e4617
@ -25,12 +25,12 @@ import {
|
|||||||
Tab,
|
Tab,
|
||||||
Tabs,
|
Tabs,
|
||||||
PriceCellChange,
|
PriceCellChange,
|
||||||
|
ResizablePanel,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import type { CandleClose } from '@vegaprotocol/types';
|
import type { CandleClose } from '@vegaprotocol/types';
|
||||||
import { AuctionTrigger } from '@vegaprotocol/types';
|
import { AuctionTrigger } from '@vegaprotocol/types';
|
||||||
import { MarketTradingMode } from '@vegaprotocol/types';
|
import { MarketTradingMode } from '@vegaprotocol/types';
|
||||||
import { Allotment, LayoutPriority } from 'allotment';
|
import { Allotment, LayoutPriority } from 'allotment';
|
||||||
import 'allotment/dist/style.css';
|
|
||||||
|
|
||||||
const TradingViews = {
|
const TradingViews = {
|
||||||
Candles: CandlesChartContainer,
|
Candles: CandlesChartContainer,
|
||||||
@ -159,11 +159,11 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
<>
|
<>
|
||||||
<div className={wrapperClasses}>
|
<div className={wrapperClasses}>
|
||||||
<TradeMarketHeader market={market} />
|
<TradeMarketHeader market={market} />
|
||||||
<Allotment vertical={true}>
|
<ResizablePanel vertical={true}>
|
||||||
<Allotment.Pane>
|
<Allotment.Pane minSize={75}>
|
||||||
<Allotment proportionalLayout={false} minSize={200}>
|
<ResizablePanel proportionalLayout={false} minSize={200}>
|
||||||
<Allotment.Pane priority={LayoutPriority.High} minSize={200}>
|
<Allotment.Pane priority={LayoutPriority.High} minSize={200}>
|
||||||
<TradeGridChild className="h-full px-4 bg-black-10 dark:bg-black-70">
|
<TradeGridChild className="h-full pr-4 bg-black-10 dark:bg-black-70">
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab id="candles" name={t('Candles')}>
|
<Tab id="candles" name={t('Candles')}>
|
||||||
<TradingViews.Candles marketId={market.id} />
|
<TradingViews.Candles marketId={market.id} />
|
||||||
@ -195,7 +195,7 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
preferredSize={430}
|
preferredSize={430}
|
||||||
minSize={200}
|
minSize={200}
|
||||||
>
|
>
|
||||||
<TradeGridChild className="h-full px-4 bg-black-10 dark:bg-black-70">
|
<TradeGridChild className="h-full pl-4 bg-black-10 dark:bg-black-70">
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab id="orderbook" name={t('Orderbook')}>
|
<Tab id="orderbook" name={t('Orderbook')}>
|
||||||
<TradingViews.Orderbook marketId={market.id} />
|
<TradingViews.Orderbook marketId={market.id} />
|
||||||
@ -206,7 +206,7 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
</Allotment.Pane>
|
</Allotment.Pane>
|
||||||
</Allotment>
|
</ResizablePanel>
|
||||||
</Allotment.Pane>
|
</Allotment.Pane>
|
||||||
<Allotment.Pane
|
<Allotment.Pane
|
||||||
priority={LayoutPriority.Low}
|
priority={LayoutPriority.Low}
|
||||||
@ -227,7 +227,7 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
</Allotment.Pane>
|
</Allotment.Pane>
|
||||||
</Allotment>
|
</ResizablePanel>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -10,76 +10,88 @@ import classNames from 'classnames';
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { VegaWalletContainer } from '../../components/vega-wallet-container';
|
import { VegaWalletContainer } from '../../components/vega-wallet-container';
|
||||||
import { DepositsContainer } from './deposits-container';
|
import { DepositsContainer } from './deposits-container';
|
||||||
|
import { ResizablePanel } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { Allotment, LayoutPriority } from 'allotment';
|
||||||
|
|
||||||
const Portfolio = () => {
|
const Portfolio = () => {
|
||||||
const wrapperClasses = classNames(
|
const wrapperClasses = classNames(
|
||||||
'h-full max-h-full',
|
'h-full max-h-full',
|
||||||
'grid gap-4 grid-rows-[1fr_300px]',
|
'flex flex-col',
|
||||||
'bg-black-10 dark:bg-white-10',
|
'bg-black-10 dark:bg-black-70',
|
||||||
'text-ui'
|
'text-ui'
|
||||||
);
|
);
|
||||||
const tabContentClassName = 'h-full grid gap-4 grid-rows-[min-content_1fr]';
|
const tabContentClassName = 'h-full grid gap-4 grid-rows-[min-content_1fr]';
|
||||||
return (
|
return (
|
||||||
<div className={wrapperClasses}>
|
<div className={wrapperClasses}>
|
||||||
<PortfolioGridChild>
|
<ResizablePanel vertical={true}>
|
||||||
<Tabs>
|
<Allotment.Pane minSize={75}>
|
||||||
<Tab id="positions" name={t('Positions')}>
|
<PortfolioGridChild className="h-full">
|
||||||
<VegaWalletContainer>
|
<Tabs>
|
||||||
<div className={tabContentClassName}>
|
<Tab id="positions" name={t('Positions')}>
|
||||||
<h4 className="text-h4 text-black dark:text-white p-8">
|
<VegaWalletContainer>
|
||||||
{t('Positions')}
|
<div className={tabContentClassName}>
|
||||||
</h4>
|
<h4 className="text-h4 text-black dark:text-white p-8">
|
||||||
<div>
|
{t('Positions')}
|
||||||
<PositionsContainer />
|
</h4>
|
||||||
</div>
|
<div>
|
||||||
</div>
|
<PositionsContainer />
|
||||||
</VegaWalletContainer>
|
</div>
|
||||||
</Tab>
|
</div>
|
||||||
<Tab id="orders" name={t('Orders')}>
|
</VegaWalletContainer>
|
||||||
<VegaWalletContainer>
|
</Tab>
|
||||||
<div className={tabContentClassName}>
|
<Tab id="orders" name={t('Orders')}>
|
||||||
<h4 className="text-h4 text-black dark:text-white p-8">
|
<VegaWalletContainer>
|
||||||
{t('Orders')}
|
<div className={tabContentClassName}>
|
||||||
</h4>
|
<h4 className="text-h4 text-black dark:text-white p-8">
|
||||||
<div>
|
{t('Orders')}
|
||||||
<OrderListContainer />
|
</h4>
|
||||||
</div>
|
<div>
|
||||||
</div>
|
<OrderListContainer />
|
||||||
</VegaWalletContainer>
|
</div>
|
||||||
</Tab>
|
</div>
|
||||||
<Tab id="fills" name={t('Fills')}>
|
</VegaWalletContainer>
|
||||||
<VegaWalletContainer>
|
</Tab>
|
||||||
<div className={tabContentClassName}>
|
<Tab id="fills" name={t('Fills')}>
|
||||||
<h4 className="text-h4 text-black dark:text-white p-8">
|
<VegaWalletContainer>
|
||||||
{t('Fills')}
|
<div className={tabContentClassName}>
|
||||||
</h4>
|
<h4 className="text-h4 text-black dark:text-white p-8">
|
||||||
<div>
|
{t('Fills')}
|
||||||
<FillsContainer />
|
</h4>
|
||||||
</div>
|
<div>
|
||||||
</div>
|
<FillsContainer />
|
||||||
</VegaWalletContainer>
|
</div>
|
||||||
</Tab>
|
</div>
|
||||||
</Tabs>
|
</VegaWalletContainer>
|
||||||
</PortfolioGridChild>
|
</Tab>
|
||||||
<PortfolioGridChild>
|
</Tabs>
|
||||||
<Tabs>
|
</PortfolioGridChild>
|
||||||
<Tab id="collateral" name={t('Collateral')}>
|
</Allotment.Pane>
|
||||||
<VegaWalletContainer>
|
<Allotment.Pane
|
||||||
<AccountsContainer />
|
priority={LayoutPriority.Low}
|
||||||
</VegaWalletContainer>
|
preferredSize={300}
|
||||||
</Tab>
|
minSize={50}
|
||||||
<Tab id="deposits" name={t('Deposits')}>
|
>
|
||||||
<DepositsContainer />
|
<PortfolioGridChild className="h-full mt-4">
|
||||||
</Tab>
|
<Tabs>
|
||||||
<Tab id="withdrawals" name={t('Withdrawals')}>
|
<Tab id="collateral" name={t('Collateral')}>
|
||||||
<Web3Container>
|
<VegaWalletContainer>
|
||||||
<VegaWalletContainer>
|
<AccountsContainer />
|
||||||
<WithdrawalsContainer />
|
</VegaWalletContainer>
|
||||||
</VegaWalletContainer>
|
</Tab>
|
||||||
</Web3Container>
|
<Tab id="deposits" name={t('Deposits')}>
|
||||||
</Tab>
|
<DepositsContainer />
|
||||||
</Tabs>
|
</Tab>
|
||||||
</PortfolioGridChild>
|
<Tab id="withdrawals" name={t('Withdrawals')}>
|
||||||
|
<Web3Container>
|
||||||
|
<VegaWalletContainer>
|
||||||
|
<WithdrawalsContainer />
|
||||||
|
</VegaWalletContainer>
|
||||||
|
</Web3Container>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
</PortfolioGridChild>
|
||||||
|
</Allotment.Pane>
|
||||||
|
</ResizablePanel>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -291,10 +291,10 @@ export const Orderbook = ({
|
|||||||
className="sticky top-0 grid grid-cols-4 gap-5 text-right border-b-1 text-ui-small mb-2 pt-4 pb-2 bg-white dark:bg-black z-10"
|
className="sticky top-0 grid grid-cols-4 gap-5 text-right border-b-1 text-ui-small mb-2 pt-4 pb-2 bg-white dark:bg-black z-10"
|
||||||
style={{ gridAutoRows: '17px' }}
|
style={{ gridAutoRows: '17px' }}
|
||||||
>
|
>
|
||||||
<div>{t('Bid Vol')}</div>
|
<div>{t('Bid vol')}</div>
|
||||||
<div>{t('Price')}</div>
|
<div>{t('Price')}</div>
|
||||||
<div>{t('Ask Vol')}</div>
|
<div>{t('Ask vol')}</div>
|
||||||
<div className="pr-4">{t('Cumulative Vol')}</div>
|
<div className="pr-4">{t('Cumulative vol')}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -17,7 +17,8 @@ export const Accordion = ({ panels }: AccordionProps) => {
|
|||||||
const triggerClassNames = classNames(
|
const triggerClassNames = classNames(
|
||||||
'w-full py-2 box-border',
|
'w-full py-2 box-border',
|
||||||
'appearance-none cursor-pointer focus:outline-none',
|
'appearance-none cursor-pointer focus:outline-none',
|
||||||
'flex items-center justify-between border-b border-muted'
|
'flex items-center justify-between border-b border-muted',
|
||||||
|
'text-left'
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -20,6 +20,7 @@ export * from './loader';
|
|||||||
export * from './lozenge';
|
export * from './lozenge';
|
||||||
export * from './price-change';
|
export * from './price-change';
|
||||||
export * from './radio-group';
|
export * from './radio-group';
|
||||||
|
export * from './resizable-panel';
|
||||||
export * from './select';
|
export * from './select';
|
||||||
export * from './sparkline';
|
export * from './sparkline';
|
||||||
export * from './splash';
|
export * from './splash';
|
||||||
|
1
libs/ui-toolkit/src/components/resizable-panel/index.tsx
Normal file
1
libs/ui-toolkit/src/components/resizable-panel/index.tsx
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './resizable-panel';
|
@ -0,0 +1,24 @@
|
|||||||
|
import type { Story, Meta } from '@storybook/react';
|
||||||
|
import { ResizablePanel } from './resizable-panel';
|
||||||
|
import { Allotment } from 'allotment';
|
||||||
|
import 'allotment/dist/style.css';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
component: ResizablePanel,
|
||||||
|
title: 'ResizablePanel',
|
||||||
|
} as Meta;
|
||||||
|
|
||||||
|
const Template: Story = (args) => (
|
||||||
|
<div className="h-48">
|
||||||
|
<ResizablePanel vertical={true}>
|
||||||
|
<Allotment.Pane minSize={20}>
|
||||||
|
<div>Panel 1</div>
|
||||||
|
</Allotment.Pane>
|
||||||
|
<Allotment.Pane minSize={20}>
|
||||||
|
<div>Panel 2</div>
|
||||||
|
</Allotment.Pane>
|
||||||
|
</ResizablePanel>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Default = Template.bind({});
|
@ -0,0 +1,39 @@
|
|||||||
|
import { Allotment } from 'allotment';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import 'allotment/dist/style.css';
|
||||||
|
|
||||||
|
interface ResizablePanelProps {
|
||||||
|
children: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
defaultSizes?: Array<number>;
|
||||||
|
maxSize?: number;
|
||||||
|
minSize?: number;
|
||||||
|
proportionalLayout?: boolean;
|
||||||
|
snap?: boolean;
|
||||||
|
vertical?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ResizablePanel = ({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
defaultSizes,
|
||||||
|
maxSize,
|
||||||
|
minSize,
|
||||||
|
proportionalLayout,
|
||||||
|
snap,
|
||||||
|
vertical,
|
||||||
|
}: ResizablePanelProps) => {
|
||||||
|
return (
|
||||||
|
<Allotment
|
||||||
|
className={className}
|
||||||
|
defaultSizes={defaultSizes}
|
||||||
|
maxSize={maxSize}
|
||||||
|
minSize={minSize}
|
||||||
|
proportionalLayout={proportionalLayout}
|
||||||
|
snap={snap}
|
||||||
|
vertical={vertical}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Allotment>
|
||||||
|
);
|
||||||
|
};
|
@ -1,3 +1,13 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
div {
|
||||||
|
--focus-border: theme('colors.vega.pink');
|
||||||
|
--separator-border: theme('colors.black.10');
|
||||||
|
}
|
||||||
|
|
||||||
|
div.dark div {
|
||||||
|
--focus-border: theme('colors.vega.yellow');
|
||||||
|
--separator-border: theme('colors.black.70');
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user