diff --git a/apps/catalog/src/CatalogApp.tsx b/apps/catalog/src/CatalogApp.tsx index dc4b385..05d3376 100644 --- a/apps/catalog/src/CatalogApp.tsx +++ b/apps/catalog/src/CatalogApp.tsx @@ -1356,6 +1356,7 @@ export function CatalogApp() { <> `${value}%`} onChange={setBrightness} /> + `${v}%`} onChange={setBrightness}/>
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={setSliceBand} />
`${value.toFixed(1).replace('.', ',')} м`} formatLimit={(value) => value.toFixed(1).replace('.', ',')} onChange={setSliceBand} />
`${value}%`} onChange={setGlowDistance} /> diff --git a/docs/COMPONENTS.md b/docs/COMPONENTS.md index 875eae3..dee4c72 100644 --- a/docs/COMPONENTS.md +++ b/docs/COMPONENTS.md @@ -58,6 +58,8 @@ FieldFrame объединяет label, control, hint и description. `labelPlace ## RangeControl +`RangeControl variant="rail"` — горизонтальный односторонний вариант тонкой шкалы среза: та же толщина `0.2 × --nodedc-control-height`, заполнение слева и текущее `formatValue` над шкалой. Общей подложки, стекла, рамки и тени нет; прозрачная область захвата не ниже 24 px. Native range сохраняет стрелки, Home/End, доступное имя и disabled; focus-visible подчёркивает значение. Точный ввод остаётся у обычного варианта `field`. Позиционирование в viewport и время показа задаёт приложение. + Вертикальная шкала занимает `0.2 × --nodedc-control-height` (9.2 px при 46 px), вдвое тоньше предыдущей. Прозрачная область захвата не уже 24 px. Pill-range с заполнением акцентным цветом, встроенной подписью и значением. Домен определяет min/max/step и формат числа. `min/max` задают только рабочий диапазон перетаскивания; ручной ввод по умолчанию принимает любое конечное число и не меняет геометрию ползунка. Опциональный `exactValueBounds` независимо задаёт жёсткие границы ручного ввода: например, `{ min: 0 }` сохраняет неотрицательное значение, но не ограничивает верхнюю границу ползунком. diff --git a/packages/ui-core/styles.css b/packages/ui-core/styles.css index cfdade8..4b86878 100644 --- a/packages/ui-core/styles.css +++ b/packages/ui-core/styles.css @@ -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); } diff --git a/packages/ui-react/src/RangeControl.tsx b/packages/ui-react/src/RangeControl.tsx index 9816857..5e5b493 100644 --- a/packages/ui-react/src/RangeControl.tsx +++ b/packages/ui-react/src/RangeControl.tsx @@ -11,6 +11,8 @@ import { screenColorPicker } from "./screenColorPicker.js"; export interface RangeControlProps extends Omit, "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 ( +
+ +
+ onChange(Number(event.target.value))}/> +
+
+ ); + if (orientation === "vertical") return (
diff --git a/registry/components.json b/registry/components.json index d8f1876..59ea2ff 100644 --- a/registry/components.json +++ b/registry/components.json @@ -312,7 +312,8 @@ "The browser places the caret at the clicked character, preserves native drag or keyboard selection, and replaces the selected substring on typing without pointer-state interception.", "Editor foreground and caret switch automatically between theme text and on-accent tokens according to the actual fill edge beneath the value area.", "The editor has no separate background box and keeps focus across parent window rerenders and pointer leave.", - "Editor keyboard events do not bubble into enclosing Window shortcuts." + "Editor keyboard events do not bubble into enclosing Window shortcuts.", + "variant=rail is the single-value horizontal counterpart of the thin vertical section scale: 0.2 control-height shaft, minimum 24 px transparent target, value above, native arrows/Home/End, disabled and value underline focus. No enclosing surface, glass, outline, shadow or exact-value editor. Consumer owns placement and visibility timing." ] }, { diff --git a/scripts/range-control-contract.test.mjs b/scripts/range-control-contract.test.mjs index d9743e4..593c748 100644 --- a/scripts/range-control-contract.test.mjs +++ b/scripts/range-control-contract.test.mjs @@ -117,3 +117,15 @@ test("both boundaries move, clamp independently, separate after coincidence and assert.deepEqual(move([0, 10], 1, 7.3, 0, 10, .5), [0, 7.5]); assert.deepEqual(move([0, 9], 1, 10.1, 0, 10.1, 3), [0, 10.1]); }); + +test("horizontal thin rail has one native boundary and a formatted value, without field chrome", () => { + for(const disabled of [false,true]){ + const markup=renderToStaticMarkup(createElement(RangeControl,{variant:"rail",label:"Скорость",value:5,min:.1,max:100,step:.1,disabled,formatValue:n=>`${n} м/с`,onChange(){}})); + assert.equal((markup.match(/type="range"/g)||[]).length,1); + assert.match(markup,/aria-label="Скорость" aria-orientation="horizontal"/); + assert.match(markup,/aria-valuetext="5 м\/с"/); + assert.match(markup,/nodedc-range-rail__value/); + assert.equal(markup.includes('disabled=""'),disabled); + assert.doesNotMatch(markup,/nodedc-range__label|nodedc-range__editor|nodedc-glass/); + } +});