feat(ui): port dashboard components to react
This commit is contained in:
parent
a71d66b1b8
commit
73abcc1b69
33 changed files with 1304 additions and 182 deletions
34
src/lib/ui/components/ProgressMeter.tsx
Normal file
34
src/lib/ui/components/ProgressMeter.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import type { CSSProperties } from "react";
|
||||
import { clampPercent } from "../format";
|
||||
import type { UiSeverity } from "../types";
|
||||
|
||||
export interface ProgressMeterProps {
|
||||
value?: number;
|
||||
severity?: UiSeverity;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export function ProgressMeter({
|
||||
value,
|
||||
severity = "neutral",
|
||||
label = "Progress",
|
||||
}: ProgressMeterProps) {
|
||||
const progress = value === undefined ? null : clampPercent(value);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="progress-meter"
|
||||
data-severity={severity}
|
||||
role="meter"
|
||||
aria-label={label}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={progress ?? undefined}
|
||||
data-empty={progress === null}
|
||||
>
|
||||
{progress !== null ? (
|
||||
<span style={{ "--meter-progress": `${progress}%` } as CSSProperties} />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue