2021-08-15 06:31:59 -07:00
|
|
|
import { formatUsdValue } from '../utils'
|
2021-09-19 17:36:02 -07:00
|
|
|
import { MarketDataLoader } from './MarketDetails'
|
2021-08-13 14:30:39 -07:00
|
|
|
|
2022-02-17 01:44:28 -08:00
|
|
|
interface DayHighLowProps {
|
|
|
|
high: number
|
|
|
|
low: number
|
|
|
|
latest: number
|
|
|
|
isTableView?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
const DayHighLow = ({ high, low, latest, isTableView }: DayHighLowProps) => {
|
2021-08-13 14:30:39 -07:00
|
|
|
let rangePercent = 0
|
2021-08-14 03:26:54 -07:00
|
|
|
|
2021-08-25 14:39:48 -07:00
|
|
|
if (high) {
|
2022-02-17 01:44:28 -08:00
|
|
|
rangePercent = ((latest - low) * 100) / (high - low)
|
2021-08-13 14:30:39 -07:00
|
|
|
}
|
|
|
|
|
2021-07-20 07:21:58 -07:00
|
|
|
return (
|
2022-02-19 01:11:29 -08:00
|
|
|
<div className="flex items-center justify-between md:block">
|
2022-01-31 19:51:54 -08:00
|
|
|
<div className="flex items-center">
|
2022-02-17 01:44:28 -08:00
|
|
|
<div className={`pr-2 text-th-fgd-2 ${!isTableView && 'md:text-xs'}`}>
|
2021-08-25 14:39:48 -07:00
|
|
|
{low ? formatUsdValue(low) : <MarketDataLoader />}
|
2021-08-13 14:30:39 -07:00
|
|
|
</div>
|
2022-01-31 07:52:28 -08:00
|
|
|
<div className="h-1.5 flex rounded bg-th-bkg-3 w-16 sm:w-16">
|
2021-07-20 07:21:58 -07:00
|
|
|
<div
|
|
|
|
style={{
|
2021-08-13 14:30:39 -07:00
|
|
|
width: `${rangePercent}%`,
|
2021-07-20 07:21:58 -07:00
|
|
|
}}
|
|
|
|
className="flex rounded bg-th-primary"
|
|
|
|
></div>
|
|
|
|
</div>
|
2022-02-17 01:44:28 -08:00
|
|
|
<div className={`pl-2 text-th-fgd-2 ${!isTableView && 'md:text-xs'}`}>
|
2021-08-25 14:39:48 -07:00
|
|
|
{high ? formatUsdValue(high) : <MarketDataLoader />}
|
2021-08-13 14:30:39 -07:00
|
|
|
</div>
|
2021-07-20 07:21:58 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DayHighLow
|