Spaces:
Running
Running
File size: 1,360 Bytes
a874986 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
interface NumberInputProps {
label: string;
value: number;
onChange: (value: number) => void;
min?: number;
max?: number;
step?: number;
info?: string;
unit?: string;
compact?: boolean;
}
export function NumberInput({
label,
value,
onChange,
min,
max,
step = 0.01,
info,
unit,
compact = false,
}: NumberInputProps) {
return (
<div className="space-y-1.5">
<label className={`font-semibold text-text-primary ${compact ? 'text-xs' : 'text-sm'}`}>{label}</label>
{info && <p className={`text-text-muted ${compact ? 'text-[10px]' : 'text-xs'}`}>{info}</p>}
<div className="relative">
<input
type="number"
value={value}
onChange={(e) => onChange(Number(e.target.value))}
min={min}
max={max}
step={step}
className={`w-full bg-white border border-dark-border rounded-lg text-text-primary focus:border-nvidia-green focus:outline-none focus:ring-2 focus:ring-nvidia-green/20 transition-all ${
compact ? 'px-3 py-2 text-sm' : 'px-4 py-3 text-base'
}`}
/>
{unit && (
<span className={`absolute right-3 top-1/2 -translate-y-1/2 text-text-muted ${
compact ? 'text-xs' : 'text-sm'
}`}>
{unit}
</span>
)}
</div>
</div>
);
}
|