2022-09-21 22:28:53 -07:00
|
|
|
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],
|
2022-09-28 13:02:12 -07:00
|
|
|
]
|
|
|
|
|
2023-07-17 18:18:01 -07:00
|
|
|
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">
|
2022-09-21 22:28:53 -07:00
|
|
|
<TabButtons
|
|
|
|
activeValue={activeTab}
|
|
|
|
onChange={(tab: string) => setActiveTab(tab)}
|
2022-09-28 13:02:12 -07:00
|
|
|
values={TABS}
|
2022-09-21 22:28:53 -07:00
|
|
|
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 ? (
|
2023-07-17 18:18:01 -07:00
|
|
|
<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}
|
2023-07-17 18:18:01 -07:00
|
|
|
<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
|