import classNames from 'classnames';
import AutoSizer from 'react-virtualized-auto-sizer';
import { useState, ReactNode } from 'react';
import { Market_market } from './__generated__/Market';
import { View, Views } from './trading-components';
import { GridTab, GridTabs } from './grid-tabs';
interface TradeGridProps {
market: Market_market;
}
export const TradeGrid = ({ market }: TradeGridProps) => {
const wrapperClasses = classNames(
'h-full max-h-full',
'grid gap-[1px] grid-cols-[1fr_325px_325px] grid-rows-[min-content_1fr_200px]',
'bg-neutral-200',
'text-ui'
);
return (
{JSON.stringify(market.trades, null, 2)}
);
};
interface TradeGridChildProps {
children: ReactNode;
className?: string;
}
const TradeGridChild = ({ children, className }: TradeGridChildProps) => {
const gridChildClasses = classNames('bg-white', className);
return (
{({ width, height }) => (
{children}
)}
);
};
interface TradePanelsProps {
market: Market_market;
}
export const TradePanels = ({ market }: TradePanelsProps) => {
const [view, setView] = useState('chart');
const renderView = () => {
const Component = Views[view];
if (!Component) {
throw new Error(`No component for view: ${view}`);
}
return ;
};
return (
{({ width, height }) => (
{renderView()}
)}
{Object.keys(Views).map((key: View) => {
const className = classNames(
'p-8',
'border-t',
'border-neutral-200',
'capitalize',
{
'text-vega-pink': view === key,
'bg-white': view === key,
}
);
return (
);
})}
);
};