mango-ui-v3/components/DayHighLow.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-08-15 06:31:59 -07:00
import { formatUsdValue } from '../utils'
2021-08-13 14:30:39 -07:00
const DayHighLow = ({ high, low, latest }) => {
let rangePercent = 0
2021-08-14 03:26:54 -07:00
2021-08-13 14:30:39 -07:00
if (high?.baseOraclePrice) {
rangePercent =
2021-08-14 03:26:54 -07:00
((parseFloat(latest?.baseOraclePrice) -
parseFloat(low?.baseOraclePrice)) *
100) /
(parseFloat(high?.baseOraclePrice) - parseFloat(low?.baseOraclePrice))
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">
24h Range
</div>
<div className="flex items-center">
2021-08-13 14:30:39 -07:00
<div className="pr-2 text-th-fgd-1 text-xs">
2021-08-16 15:40:56 -07:00
{low?.baseOraclePrice ? formatUsdValue(low.baseOraclePrice) : null}
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">
2021-08-16 15:40:56 -07:00
{high?.baseOraclePrice ? formatUsdValue(high.baseOraclePrice) : null}
2021-08-13 14:30:39 -07:00
</div>
</div>
</div>
)
}
export default DayHighLow