import type { CSSProperties } from 'react'; export interface SliderProps { label?: string; value?: number; min?: number; max?: number; step?: number; unit?: string; onChange?: (value: number) => void; disabled?: boolean; /** Custom formatter for the value readout. */ format?: (value: number) => string; style?: CSSProperties; } /** * Manifold Slider — labeled horizontal range with a glowing orange thumb and * a tabular value readout. Controlled via value/onChange (0..max). * * Relies on the `.mf-slider-input` rules in `styles/primitives.css` for the * track gradient and glowing thumb. The fill percentage is passed via the * inline `--mf-pct` custom property. */ export function Slider({ label, value = 0, min = 0, max = 1, step = 0.01, unit = '', onChange, disabled = false, format, style, }: SliderProps) { const pct = max > min ? (value - min) / (max - min) : 0; const display = format ? format(value) : Number.isInteger(step) ? String(value) : value.toFixed(2); return (
{label && ( {label} )}
onChange?.(parseFloat(e.target.value))} className="mf-slider-input" style={ { flex: 1, WebkitAppearance: 'none', appearance: 'none', background: 'transparent', height: 24, margin: 0, cursor: 'pointer', '--mf-pct': `${pct}`, } as CSSProperties } /> {display} {unit && {unit}}
); }