feat(ui): add thin horizontal single-value range rail
This commit is contained in:
@@ -11,6 +11,8 @@ import { screenColorPicker } from "./screenColorPicker.js";
|
||||
export interface RangeControlProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange"> {
|
||||
label: string;
|
||||
orientation?: "horizontal" | "vertical";
|
||||
/** Thin horizontal single-value rail; no containing surface or exact editor. */
|
||||
variant?: "field" | "rail";
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
@@ -73,6 +75,7 @@ export function RangeControl(props: RangeControlProps | RangeBandControlProps) {
|
||||
function SingleRangeControl({
|
||||
label,
|
||||
orientation = "horizontal",
|
||||
variant = "field",
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
@@ -159,6 +162,17 @@ function SingleRangeControl({
|
||||
}
|
||||
};
|
||||
|
||||
if (orientation === "horizontal" && variant === "rail") return (
|
||||
<div className={cn("nodedc-range-rail", className)} data-disabled={disabled || undefined}>
|
||||
<span className="nodedc-range-rail__value" aria-hidden="true">{displayValue}</span>
|
||||
<div ref={rootRef} className="nodedc-range" style={style} data-variant="rail">
|
||||
<input ref={rangeRef} {...props} type="range" value={value} min={min} max={safeMax} step={step}
|
||||
disabled={disabled} tabIndex={tabIndex} aria-label={label} aria-orientation="horizontal"
|
||||
aria-valuetext={displayValue} onChange={event => onChange(Number(event.target.value))}/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (orientation === "vertical") return (
|
||||
<div className="nodedc-range-scale" data-limit-side={limitSide} style={style}>
|
||||
<div ref={rootRef} className={cn("nodedc-range", className)} style={style} data-orientation="vertical">
|
||||
|
||||
Reference in New Issue
Block a user