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

53 lines
1.2 KiB
TypeScript
Raw Normal View History

import TabButtons from '@components/shared/TabButtons'
2023-07-24 15:52:09 -07:00
import { useState } from 'react'
2022-09-20 13:05:50 -07:00
import Orderbook from './Orderbook'
import RecentTrades from './RecentTrades'
2023-06-29 20:05:41 -07:00
import DepthChart from './DepthChart'
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],
2023-07-20 17:09:34 -07:00
['trade:depth', 0],
2022-10-03 03:38:05 -07:00
['trade:trades', 0],
]
const OrderbookAndTrades = () => {
2022-10-03 03:38:05 -07:00
const [activeTab, setActiveTab] = useState('trade:book')
2023-07-20 17:09:34 -07:00
2022-09-20 13:05:50 -07:00
return (
2023-07-24 15:52:09 -07:00
<div className="h-full">
2023-07-20 17:09:34 -07:00
<div className="hide-scroll overflow-x-auto border-b border-th-bkg-3">
<TabButtons
activeValue={activeTab}
onChange={(tab: string) => setActiveTab(tab)}
2023-07-24 15:52:09 -07:00
values={TABS}
fillWidth
2023-07-20 17:09:34 -07:00
showBorders
/>
2022-09-20 13:05:50 -07:00
</div>
2022-10-03 03:38:05 -07:00
<div
2023-07-24 15:52:09 -07:00
className={`h-full ${
activeTab === 'trade:book' ? 'visible' : 'hidden'
}`}
2023-06-29 20:05:41 -07:00
>
2023-07-24 15:52:09 -07:00
<Orderbook />
2023-06-29 20:05:41 -07:00
</div>
2023-07-20 17:09:34 -07:00
<div
className={`h-full ${
activeTab === 'trade:depth' ? 'visible' : 'hidden'
}`}
>
<DepthChart />
</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