Freehand drawing: add black swatch + sync first swatch with active theme #122
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#122
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?
Summary
Two small improvements to the freehand drawing sub-toolbar:
#dee2e6), which makes it a poor "default" on the Light or Minimal themes (the stroke is barely visible against the canvas). It should match the active theme'sdraw-stroketoken:#dee2e6for Dark,#0f172afor Light,#64ffdafor Ocean,#f59e0bfor Warm,#374151for Minimal — and update live when the user switches themes.Why
Black is a common request and missing for no good reason. The first swatch is the implicit default when the user opens the freehand tool fresh, so it should produce visible strokes regardless of which theme the board is on.
Files involved
crates/hero_whiteboard_ui/templates/web/board.html— add the black button to#draw-colors, tag the first swatch withdata-theme-defaultso JS can keep it in sync.crates/hero_whiteboard_ui/static/web/js/whiteboard/toolbar.js— addrefreshDrawDefault()that readsWhiteboardThemes.get('draw-stroke')and updates the tagged swatch (color, background, and the active draw color if that swatch is selected). Call it frominit().crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js— callWhiteboardToolbar.refreshDrawDefault()fromapplyThemeso theme switches re-sync the swatch.Implementation Spec for Issue #122
Objective
Add black to the freehand drawing palette and make the leftmost (default) swatch automatically match the active theme's
draw-stroketoken, updating live when the user switches themes.Files to Modify
crates/hero_whiteboard_ui/templates/web/board.html— add a black<button>in#draw-colors, tag the first swatch withdata-theme-default.crates/hero_whiteboard_ui/static/web/js/whiteboard/toolbar.js— newrefreshDrawDefault()function that readsWhiteboardThemes.get('draw-stroke')and updates the tagged swatch in place; expose on the public API; call frominit().crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js— invokeWhiteboardToolbar.refreshDrawDefault()fromapplyThemeso the swatch tracks theme changes.Implementation Plan
Step 1: Markup — black swatch + theme-default attribute
File:
crates/hero_whiteboard_ui/templates/web/board.htmlInside
<div class="subtoolbar-colors" id="draw-colors">:<button class="sub-color active" data-theme-default ... title="Theme default"><button class="sub-color" data-color="#000000" style="background:#000000;" title="Black"></button>The
title="Theme default"(or "Default") is a small UX nudge; the swatch's actual rendered color follows the theme.Dependencies: none.
Step 2: JS — refreshDrawDefault helper
File:
crates/hero_whiteboard_ui/static/web/js/whiteboard/toolbar.jsAdd to the IIFE:
Call
refreshDrawDefault()once at the end ofinit()so the swatch picks up the current theme's draw-stroke even if the user never switches themes.Expose
refreshDrawDefaulton the returned API object.Dependencies: none. Safe-guarded against
WhiteboardThemesbeing undefined (the script load order means it'll always be defined wheninit()runs, but defensive is cheap).Step 3: themes.js — invoke the toolbar refresh
File:
crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.jsIn
applyTheme, after the existing redraw loop andWhiteboardConnectors.applyTheme()call, add:Dependencies: Step 2.
Acceptance Criteria
draw-strokeis#0f172a); strokes are visible against the white canvas.#dee2e6(light gray), matching the previous default. Existing strokes already on the canvas keep their persisted colors.draw-stroke. If that swatch was the active selection, the liveWhiteboardTools.drawColorupdates too.cargo fmt,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --libclean.Notes
data-theme-defaultinstead of anid: it's a single dedicated swatch today, but the same pattern is reusable for other tool palettes later (e.g. shape stroke, sticky default) — the attribute is a generic marker.WhiteboardTools.drawColoronly updates when the theme-default swatch is active. If the user has picked a non-default color, theme switches don't surprise them by changing what they draw with — they only change the default swatch's appearance.Implementation Summary
crates/hero_whiteboard_ui/templates/web/board.html#draw-colors(between white and blue).data-theme-defaultand set its title to "Theme default" so JS can keep it in sync without coupling to a specific color value.crates/hero_whiteboard_ui/static/web/js/whiteboard/toolbar.jsrefreshDrawDefault()function: readsWhiteboardThemes.get('draw-stroke')and updates the tagged swatch'sdata-colorand CSS background. If that swatch is currently active, also pushes the new color intoWhiteboardTools.setDrawColorso the live draw color updates.init()so the swatch picks up the theme on first paint.crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.jsapplyThemenow invokesWhiteboardToolbar.refreshDrawDefault()after the redraw loop andWhiteboardConnectors.applyTheme()so theme switches re-sync the draw swatch live.Files Changed
crates/hero_whiteboard_ui/templates/web/board.html—+2 / -1crates/hero_whiteboard_ui/static/web/js/whiteboard/toolbar.js—+22 / -1crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js—+4 / 0Test Results
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace --lib— 0 failednode --check toolbar.js && node --check themes.js— cleancargo check -p hero_whiteboard_ui— clean (Askama re-compiled the template)Manual smoke
#0f172a); strokes are visible against the white canvas.draw-stroke.Notes