mango-v4-ui/components/shared/DailyRange.tsx

38 lines
1016 B
TypeScript
Raw Normal View History

2022-10-11 04:59:01 -07:00
import { useMemo } from 'react'
2023-01-24 16:54:24 -08:00
import FormatNumericValue from './FormatNumericValue'
2022-10-11 04:59:01 -07:00
interface DailyRangeProps {
high: number
low: number
price: number
}
const DailyRange = ({ high, low, price }: DailyRangeProps) => {
const rangePercent = useMemo(() => {
return ((price - low) * 100) / (high - low)
}, [high, low, price])
return (
<div className="flex items-center justify-between md:block">
<div className="flex items-center">
<span className={`pr-2 font-mono text-th-fgd-2`}>
2023-01-24 16:54:24 -08:00
<FormatNumericValue value={low} isUsd />
2022-10-11 04:59:01 -07:00
</span>
<div className="mt-[2px] flex h-2 w-32 rounded-sm bg-th-bkg-3">
<div
style={{
width: `${rangePercent}%`,
}}
2022-11-30 19:32:32 -08:00
className="flex rounded-sm bg-th-active"
2022-10-11 04:59:01 -07:00
></div>
</div>
<span className={`pl-2 font-mono text-th-fgd-2`}>
2023-01-24 16:54:24 -08:00
<FormatNumericValue value={high} isUsd />
2022-10-11 04:59:01 -07:00
</span>
</div>
</div>
)
}
export default DailyRange