Skip to content

feat(Form): add slider annotations, a slider default value, and number record inputs - #138

Draft
gdevenyi wants to merge 2 commits into
mainfrom
feat/slider-options-number-record-input
Draft

gdevenyi wants to merge 2 commits into
mainfrom
feat/slider-options-number-record-input

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Draft: this needs @douglasneuroinformatics/libui-form-types 1.7.0 (DouglasNeuroInformatics/libui-form-types#24). CI fails until that release. Then the dependency and the lockfile must change to ^1.7.0 in this PR.

Note: the commit message says "closes #36". Two items of #36 are not done (see Merge Danger), so open #36 again after the merge, or change the message in a squash merge.

Summary

 <NumberFieldSlider>
   <Slider
-    value={[value ?? 0]}
+    value={[value ?? midpoint]}            # no value: thumb at the midpoint
+    data-unset                             # no value: thumb dimmed (opacity 40%)
+    onPointerDown -> setValue(midpoint)    # a press on the thumb selects the midpoint
   />
   <span>{value ?? 'NA'}</span>
+  {showRange && <min … max>}               # numbers at the ends of the track
+  {marks && <label at each value>}         # text below the track, at the position of its value
+  useEffect: value === undefined && defaultValue !== undefined -> setValue(defaultValue)

 <NumberRecordField>
-  each item -> <NumberField variant="radio" options />
+  variant 'likert' -> <NumberField variant="radio" options />
+  variant 'input'  -> <NumberField variant="input" />
Option Default Effect
showRange off Shows min and max below the ends of the track
marks none { 0: 'Not at all', 10: 'Extremely' } shows text below the track. A mark outside of the range is not shown. Long text wraps at 40% of the width.
defaultValue none A real value, visible and submitted. It is set again after a form reset. It is not set when the field is disabled or read-only.

The value stays undefined (shown as "NA") until the user presses the slider or uses the keyboard.

Evidence

  • Before: a slider with no value shows the thumb at min, the same as a selected minimum. A number-record field can only render radio buttons.
    After: examined in Storybook (Chromium) with the new stories NumberField / Slider With Range, Slider With Marks, Slider With Range And Marks, Slider With Default Value and Form / With Number Record Input. Marks at 0, 5 and 10 are below the thumb positions for those values. At a width of 480 px a long mark wraps and the page has no horizontal scroll.
  • 15 new tests (12 slider, 3 number record). pnpm test: 42 files, 261 tests pass. pnpm lint passes. These ran with the form types from the linked PR.

Merge Danger

Door: two-way

Blast Radius: sliders

  • Each slider with no value now shows a dimmed thumb at the midpoint, not a thumb at min. This is the only change for forms that do not use the new options.
  • Slider (public component) gets the class group/slider and dims its thumb when data-unset is set.
  • Not done from Slider interface improvements #36: the value below the thumb, and arrows. The value stays at the right of the track.
  • Form elements need default values that are visible #21 is done for sliders only. Other fields (for example a boolean radio with a default in the schema) still do not show a default.

Closes #15, closes #34
Refs #21, #36

🤖 Generated with Claude Code

https://claude.ai/code/session_01W53iUP9ECVtoteopM7QtC7

…r record inputs

- slider: optional marks, showRange and defaultValue
- slider: with no value, the thumb is dimmed and at the midpoint
- number-record: render a number input for each item with variant 'input'

Requires @douglasneuroinformatics/libui-form-types 1.7.0.

Closes #15, closes #34, closes #36
Refs #21

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W53iUP9ECVtoteopM7QtC7
@gdevenyi
gdevenyi requested a review from joshunrau November 10, 2026 04:41

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slider interface improvements Create a number record field that can contain number input questions Optional annotations on slider object

1 participant