mango-ui-v3/components/DayHighLow.tsx

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-08-15 06:31:59 -07:00
import { formatUsdValue } from '../utils'
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
if (high) {
2022-02-17 01:44:28 -08:00
rangePercent = ((latest - low) * 100) / (high - low)
2021-08-13 14:30:39 -07:00
}
return (
2022-02-19 01:11:29 -08:00
<div className="flex items-center justify-between md:block">
<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'}`}>
{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">
<div
style={{
2021-08-13 14:30:39 -07:00
width: `${rangePercent}%`,
}}
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'}`}>
{high ? formatUsdValue(high) : <MarketDataLoader />}
2021-08-13 14:30:39 -07:00
</div>
</div>
</div>
)
}
export default DayHighLow