Replace font-size slider with a numeric input + preset dropdown #159
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#159
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The text font-size control in the selection toolbar is a
<input type="range">slider via_buildRange(min, max, value, unit, onChange). Sliders are imprecise and capped at a max (currently 72/48/36 depending on object type). Users want to type an exact value or pick from common preset sizes.Expected
Replace the slider with a compact control similar to typical word processors:
<input>showing the current size (typeable, with up/down chevrons or stepper buttons).Actual
A wide HTML range slider with a small "px" label. Imprecise, max-capped, no quick presets, no way to type a value.
Notes
The slider helper
_buildRangelives incrates/hero_whiteboard_ui/static/web/js/whiteboard/selection_toolbar.js. Font-size call sites:_renderSticky(~line 842) — range 10..72_renderText(~line 873) — range 10..72_renderShape(~line 955) — range 10..48_renderDocument(~line 1044) — range 10..36Add a new
_buildSizePicker(value, onChange, presets)helper (or_buildNumberWithPresets) that renders the desired control, and replace those 4 call sites. Other_buildRangecallers (e.g. line thickness, opacity if any) should keep using the slider — only font size moves to the new control.The preset list should be the standard one shown in the screenshot:
[10, 12, 14, 18, 24, 36, 48, 64, 80, 144, 288].Implementation Spec
Audit
_buildRange(min, max, value, suffix, onInput, tooltip)is used in 7 places — only the 4 font-size sites switch to the new control. The 3 stroke-width sites keep the slider:_renderSticky_renderText_renderShape_renderShape_renderDrawing_renderDocument_renderConnectorReuses existing infra:
_openPopoverfor viewport-anchored popovers (preserves70820da),wb-pt-popoverstyling, theme variables.Helper signature
Purpose-built name (mirrors
_buildAlignTrigger/_buildFontTrigger/_buildColorTrigger). Call sites collapse to_buildSizePicker(fontSize, onChange).Files to Modify
crates/hero_whiteboard_ui/static/web/js/whiteboard/selection_toolbar.js— new helper + sweep 4 call sites.crates/hero_whiteboard_ui/static/web/css/selection_toolbar.css— append new rules._buildRangestays — still used by 3 stroke-width callers.DOM
Trigger:
Uses the input's native spinner (no custom up/down chevrons). Total ~78px wide, comparable to the slider.
Popover:
The preset matching the current input value gets
is-selected.Behavior
onChangeon every keystroke (matches slider parity)._openPopoverinfrastructure.[min, max](1..999 default) on commit.CSS additions
Call-site sweep
Replace each font-size
_buildRange(...)with_buildSizePicker(fontSize, onChange). The previous min/max caps (72/48/36) are dropped — the user can now type up to 999. Stroke-width sites at lines 940, 988, 1358 stay on_buildRange.Acceptance Criteria
70820da).What NOT to break
_buildRange+wb-pt-rangeCSS — still used by 3 stroke-width callers._openPopover/_closeTopPopoverstack — reused, not modified.34156d5— different CSS class space (wb-pt-color-*vswb-pt-size-*), no collision._mdFontSizefield +WhiteboardObjects.rerender*contract — unchanged, helper hands an integer to the same callbacks._buildTextInput,_buildSelect,_buildPopoverTextEditor) — unchanged.Validation
cargo check --workspacecargo test --workspace --lib_buildSizePickerdef + 4 calls (font size); 1_buildRangedef + 3 calls (stroke width) — sliders preserved for stroke-width sitesImplementation summary
Changes
crates/hero_whiteboard_ui/static/web/js/whiteboard/selection_toolbar.jsDEFAULT_FONT_SIZE_PRESETS = [10, 12, 14, 18, 24, 36, 48, 64, 80, 144, 288]constant._buildSizePicker(value, onChange, opts)helper next to_buildRange. Renders a<input type="number">joined to a chevron button that opens a preset listbox via the existing_openPopover/_closeTopPopovermachinery. Live commits on input / Enter / blur, reverts on Escape, clamps to[min, max](defaults 1..999)._buildRangecall sites (sticky, text, shape, document) with_buildSizePicker(fontSize, onChange)._buildRangecall sites (shape stroke, drawing stroke, connector stroke) are unchanged — sliders preserved for those.crates/hero_whiteboard_ui/static/web/css/selection_toolbar.css.wb-pt-size-picker,.wb-pt-size-input,.wb-pt-size-presets-btn,.wb-pt-size-presets,.wb-pt-size-presetrules. Theme-aware via--wb-*variables. Reuses existing.wb-pt-popoverfor the dropdown shell.Keyboard: ArrowUp/Down on the input → live increment via the native spinner. Enter → commit + clamp + blur. Escape → revert to last-committed value. Escape with the popover open → close popover.
Mouse: spinner / chevron / preset-click all behave as expected. Outside-click closes the popover via the existing infrastructure.
Validation
cargo check --workspace: passcargo test --workspace --lib: passNotes
UI-only change. Verify visually:
128and press Enter — applies and syncs.