feat(ui): add thin horizontal single-value range rail
This commit is contained in:
@@ -4768,3 +4768,11 @@ textarea.nodedc-field__control {
|
||||
.nodedc-control-row { grid-template-columns: minmax(0, 1fr); gap: var(--nodedc-space-2); }
|
||||
}
|
||||
.nodedc-editor-dock__tool.nodedc-glass-material { overflow: clip; }
|
||||
|
||||
/* Same thin scale as the vertical section rail, with one horizontal boundary. */
|
||||
.nodedc-range-rail { display: flex; flex-direction: column; gap: var(--nodedc-space-2); width: 100%; padding-block: var(--nodedc-space-2); }
|
||||
.nodedc-range-rail__value { text-align: center; color: var(--nodedc-text-primary); font-size: var(--nodedc-font-size-md); line-height: var(--nodedc-line-height-normal); font-weight: var(--nodedc-font-weight-medium); font-variant-numeric: tabular-nums; pointer-events: none; }
|
||||
.nodedc-range[data-variant="rail"] { height: calc(var(--nodedc-control-height) * 0.2); overflow: visible; border: 0; outline: 0; box-shadow: none; }
|
||||
.nodedc-range[data-variant="rail"] input[type="range"] { top: 50%; height: max(100%, 24px); transform: translateY(-50%); }
|
||||
.nodedc-range-rail:has(input:focus-visible) .nodedc-range-rail__value { text-decoration: underline; text-underline-offset: 2px; }
|
||||
.nodedc-range-rail[data-disabled] { opacity: var(--nodedc-disabled-opacity, 0.5); }
|
||||
|
||||
@@ -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