23 lines
523 B
TypeScript
23 lines
523 B
TypeScript
type WaterLevelProps = {
|
|
label: string
|
|
value: number
|
|
unit?: string
|
|
}
|
|
|
|
export function WaterLevel({ label, value, unit = '%' }: WaterLevelProps) {
|
|
const clamped = Math.min(100, Math.max(0, value))
|
|
|
|
return (
|
|
<div className="vk-water-level">
|
|
<div className="vk-water-level-tank">
|
|
<div className="vk-water-level-fill" style={{ height: `${clamped}%` }} />
|
|
<strong>
|
|
{clamped}
|
|
<small>{unit}</small>
|
|
</strong>
|
|
</div>
|
|
<span>{label}</span>
|
|
</div>
|
|
)
|
|
}
|