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
|
|
|
|
2021-08-25 14:39:48 -07:00
|
|
|
if (high) {
|
2021-08-13 14:30:39 -07:00
|
|
|
rangePercent =
|
2021-08-25 14:39:48 -07:00
|
|
|
((parseFloat(latest) - parseFloat(low)) * 100) /
|
|
|
|
(parseFloat(high) - parseFloat(low))
|
2021-08-13 14:30:39 -07:00
|
|
|
}
|
|
|
|
|
2021-07-20 07:21:58 -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">
|
2021-08-29 09:55:34 -07:00
|
|
|
Daily Range
|
2021-08-16 06:31:25 -07:00
|
|
|
</div>
|
2021-07-20 07:21:58 -07:00
|
|
|
<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-25 14:39:48 -07:00
|
|
|
{low ? formatUsdValue(low) : <MarketDataLoader />}
|
2021-08-13 14:30:39 -07:00
|
|
|
</div>
|
2021-07-20 07:21:58 -07:00
|
|
|
<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}%`,
|
2021-07-20 07:21:58 -07:00
|
|
|
}}
|
|
|
|
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-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
|