mango-ui-v3/components/DayHighLow.tsx

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-08-15 06:31:59 -07:00
import { formatUsdValue } from '../utils'
2021-08-21 06:02:51 -07:00
import { MarketDataLoader } from './MarketHeader'
2021-08-13 14:30:39 -07:00
const DayHighLow = ({ high, low, latest }) => {
let rangePercent = 0
2021-08-14 03:26:54 -07:00
if (high) {
2021-08-13 14:30:39 -07:00
rangePercent =
((parseFloat(latest) - parseFloat(low)) * 100) /
(parseFloat(high) - parseFloat(low))
2021-08-13 14:30:39 -07:00
}
return (
<div className="pr-6">
2021-08-16 06:31:25 -07:00
<div className="text-center text-th-fgd-3 tiny-text pb-0.5">
Daily Range
2021-08-16 06:31:25 -07:00
</div>
<div className="flex items-center">
2021-08-13 14:30:39 -07:00
<div className="pr-2 text-th-fgd-1 text-xs">
{low ? formatUsdValue(low) : <MarketDataLoader />}
2021-08-13 14:30:39 -07:00
</div>
<div className="h-1.5 flex rounded bg-th-bkg-3 w-24">
<div
style={{
2021-08-13 14:30:39 -07:00
width: `${rangePercent}%`,
}}
className="flex rounded bg-th-primary"
></div>
</div>
2021-08-13 14:30:39 -07:00
<div className="pl-2 text-th-fgd-1 text-xs">
{high ? formatUsdValue(high) : <MarketDataLoader />}
2021-08-13 14:30:39 -07:00
</div>
</div>
</div>
)
}
export default DayHighLow