mango-v4-ui/components/trade/OrderbookAndTrades.tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

import TabButtons from '@components/shared/TabButtons'
2022-09-20 13:05:50 -07:00
import { useState } from 'react'
import Orderbook from './Orderbook'
import RecentTrades from './RecentTrades'
2023-06-29 20:05:41 -07:00
import DepthChart from './DepthChart'
2023-07-12 07:37:18 -07:00
import useLocalStorageState from 'hooks/useLocalStorageState'
import { DEPTH_CHART_KEY } from 'utils/constants'
2022-09-20 13:05:50 -07:00
2022-10-25 18:37:59 -07:00
export const TABS: [string, number][] = [
2022-10-03 03:38:05 -07:00
['trade:book', 0],
['trade:trades', 0],
]
const OrderbookAndTrades = () => {
2022-10-03 03:38:05 -07:00
const [activeTab, setActiveTab] = useState('trade:book')
2023-07-12 07:37:18 -07:00
const [showDepthChart] = useLocalStorageState<boolean>(DEPTH_CHART_KEY, false)
2022-09-20 13:05:50 -07:00
return (
<div className="hide-scroll h-full">
2022-10-22 05:14:25 -07:00
<div className="border-b border-th-bkg-3">
<TabButtons
activeValue={activeTab}
onChange={(tab: string) => setActiveTab(tab)}
values={TABS}
fillWidth
/>
2022-09-20 13:05:50 -07:00
</div>
2022-10-03 03:38:05 -07:00
<div
2023-07-12 07:37:18 -07:00
className={`flex ${activeTab === 'trade:book' ? 'visible' : 'hidden'}`}
2023-06-29 20:05:41 -07:00
>
2023-07-12 07:37:18 -07:00
{showDepthChart ? (
<div className="hidden w-1/2 border-r border-th-bkg-3 lg:block">
<DepthChart />
2023-07-12 07:37:18 -07:00
</div>
) : null}
<div className={showDepthChart ? 'w-full lg:w-1/2' : 'w-full'}>
<Orderbook />
2023-07-12 07:37:18 -07:00
</div>
2023-06-29 20:05:41 -07:00
</div>
2022-09-20 13:05:50 -07:00
<div
2022-10-03 03:38:05 -07:00
className={`h-full ${
activeTab === 'trade:trades' ? 'visible' : 'hidden'
}`}
2022-09-20 13:05:50 -07:00
>
<RecentTrades />
</div>
</div>
)
}
export default OrderbookAndTrades