Slider: the set value to its step's decimals; the reading marked on the track and on the ring; mark geometry in the docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-10-14 16:00:53 +02:00
co-authored by Claude Opus 5.5
parent a6a1f2a2c3
commit 5b2769c141
11 changed files with 141 additions and 14 deletions
@@ -674,6 +674,9 @@ function SliderWidget({ widget, dashboard }: WidgetProps) {
const unit = cfg.unit ? text(cfg.unit) : undefined
const vertical = cfg.orientation === "vertical"
const reading = typeof value === "number" ? value : min
// Both the value and what it is set against are written to the step's
// decimals, as a round face writes them, so the two always match.
const digits = decimalsOf(num(cfg.step, 1))
const control = (
<Slider
value={reading}
@@ -688,17 +691,19 @@ function SliderWidget({ widget, dashboard }: WidgetProps) {
// that row is the difference between fitting and being cut off. A
// column has no room for them at all.
ticks={cfg.ticks !== false}
mark={typeof read?.value === "number" ? read.value : null}
label={widget.title || target}
disabled={locked}
onCommit={send}
/>
)
const readout = (
<Readout value={reading} precision={null} unit={unit} size="inline" />
<Readout value={reading} precision={digits} unit={unit} size="inline" />
)
// A line under the value, smaller, so the value being set is still the one
// that reads. In the slider's unit and to its step's decimals, as a round
// face writes it: the two are read against each other.
// face writes it: the two are read against each other. Its mark on the
// track is the same reading, placed.
const against = beside.message ? (
<span
data-testid="slider-reading"
@@ -713,7 +718,7 @@ function SliderWidget({ widget, dashboard }: WidgetProps) {
<span className="shrink-0">
<Readout
value={read?.value}
precision={decimalsOf(num(cfg.step, 1))}
precision={digits}
unit={unit}
size="inline"
/>