Kanban: card font size doesn't scale with the card #51
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#51
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?
Problem
Resizing a kanban grows card rects and column widths, but the text inside them stays fixed (card text fontSize 11, column title fontSize 12). On a large kanban the text looks tiny.
Evidence
renderCard():cardTextalwaysfontSize: 11.renderColumn():colTitlealwaysfontSize: 12.state.cardHeightorstate.colWidth.Fix
fontSize = clamp(round(cardH * 0.25), 9, 20)(tweak factor to taste).fontSize = clamp(round(colW * 0.06 + 8), 10, 18).renderCard/renderColumneach render.Implementation Spec for Issue #51
Objective
Make text inside kanban cards and column titles scale with the user-resizable
cardHeight/colWidthstate values, so that large kanbans no longer have tiny text. This is a bug fix / UI tweak only — no refactor, no new options, no behavior changes beyond font sizing and positional centering required to keep things visually aligned.Requirements
cardTextfont size scales withcardH.menuBtn) font size scales withcardH(so it stays visually balanced with the card text).colTitlefont size scales withcolW.colW(same magnitude family ascolTitle, but small like its current size).titleText(fontSize 11) — meta label, not per-item.×button (fontSize 14) — single glyph, does not need to scale.cardGroupforcardTextandmenuBtnmust adjust so the text stays vertically centered / visible at both the 22-mincardHand largecardHvalues.colWidth=200/cardHeight=44, the computed values must equal the current hardcoded values so existing kanbans look identical on first re-render.Files to Modify/Create
Modify only:
crates/hero_whiteboard_ui/static/web/js/whiteboard/kanban.jsNo new files. No changes in any other file.
Implementation Plan
Step 1 — Add a small local helper for clamped rounding
Files:
kanban.jsWhiteboardKanbanIIFE, near the othervarconstants at the top (around line 17, just belowvar cardGap = 6;), add:Dependencies: none.
Step 2 — Scale
colTitleand the "+ Add card" button font inrenderColumnFiles:
kanban.jsrenderColumn, right aftervar cy = headerH;(~line 181), compute:colTitlefontSize: 12→ usetitleFs.addBtnfontSize: 11→ useaddFs.×delColBtn(fontSize 14) unchanged.colTitle's x/y/width unchanged — the color indicator already re-derives its Y fromcolTitle.getClientRect()so it will auto-center against the new title height.addBtn's y/width unchanged.Dependencies: Step 1.
Step 3 — Scale
cardTextandmenuBtnfont inrenderCard, re-center YFiles:
kanban.jsrenderCard, right aftervar cardY = cy + 28 + cardIdx * (cardH + cardGap);, compute: ThecardH <= 48 ? legacy : centeredbranch preserves exact pixel parity at default (cardH=44: textY=8, menuY=15 — matches current) while vertically centering glyphs on larger cards.cardTextx: 8, y: 8→x: 8, y: textY.cardTextfontSize: 11→fontSize: textFs.menuBtnx: colW - 28, y: (cardH - 14) / 2→x: colW - 28, y: menuY.menuBtnfontSize: 14→fontSize: menuFs.cardText.width: colW - 50,cardRect, andmenuHit(cardH - 4) unchanged.Dependencies: Step 1.
Step 4 — Sanity-check call sites (no code change)
Files:
kanban.js(read-only)renderColumnis only invoked fromrenderKanbanwithcolW, cardHpassed through unchanged.renderCardis only invoked fromrenderColumnwithcolW, cardHpassed through unchanged.state.colWidth/state.cardHeightare the only sources ofcolW/cardH(already written by the resize / transform handler landed in PR #63).Dependencies: Steps 2–3.
Acceptance Criteria
renderColumncomputestitleFsandaddFsfromcolWand uses them forcolTitle.fontSizeandaddBtn.fontSize.renderCardcomputestextFsandmenuFsfromcardHand uses them forcardText.fontSizeandmenuBtn.fontSize.cardText.yandmenuBtn.yfollow thecardH <= 48 ? legacy : centeredrule.colWidth=200/cardHeight=44, a fresh kanban renders with the same font sizes and positions as before this change (no visual diff on load).colWidth=100,cardHeight=22) does not produce unreadable text — clamp floors hold.×delete glyph keep their current font sizes.kanban.js. No new dependencies. No lint warnings.Notes
colWidth=200/cardHeight=44, so existing kanbans don't visually shift after this patch is deployed:clamp(round(cardH * 0.25), 9, 20)at 44 → 11 (was 11).clamp(round(cardH * 0.32), 10, 24)at 44 → 14 (was 14).clamp(round(colW * 0.04 + 4), 10, 18)at 200 → 12 (was 12).clamp(round(colW * 0.035 + 4), 9, 16)at 200 → 11 (was 11).colW * 0.06 + 8— rejected because atcolW=200it produces 20, which would jump the default column title from 12 to 20 on every existing kanban. The tunedcolW * 0.04 + 4preserves default parity.cardText/menuBtnvertical placement uses a simplecardH <= 48 ? legacy : centeredbranch rather than one continuous formula. A continuous centering formula would shift every existing card's text by ~8 px on load, which requirement 7 forbids.titleBoxmeasurement for the color indicator (readscolTitle.getClientRect()) automatically adapts to the newcolTitleheight — no explicit change needed.menuHit(invisible hit rect) is sized atcardH - 4, which accommodates the menu glyph across all clamp bounds. No change needed.renderCard/renderColumnsignatures, no extraction of font logic into a module, no configuration knobs. Only the lines listed above change.Test Results
JavaScript-only change in
kanban.js; Rust workspace validated for regressions.cargo check --workspacecargo test --workspace --libcargo clippy --workspace -- -D warningscargo fmt --checkNo Rust tests cover the JS whiteboard modules, so the suite confirms regression safety on the Rust side. Manual verification against a running UI is needed for the font-scaling criteria listed in the spec's Acceptance Criteria.
Implementation Summary
Kanban text inside columns and cards now scales with
colWidth/cardHeight.Files changed
crates/hero_whiteboard_ui/static/web/js/whiteboard/kanban.js(+21 / -6)Changes
clampFont(v, min, max)helper that rounds and clamps a derived font size.renderColumn: computestitleFs = clampFont(colW * 0.04 + 4, 10, 18)andaddFs = clampFont(colW * 0.035 + 4, 9, 16);colTitle.fontSizeandaddBtn.fontSizeuse them.renderCard: computestextFs = clampFont(cardH * 0.25, 9, 20)andmenuFs = clampFont(cardH * 0.32, 10, 24);cardText.fontSizeandmenuBtn.fontSizeuse them.cardTextandmenuBtnusescardH <= 48 ? legacy : centeredso default cards keep pixel-exact parity (textY=8,menuY=15atcardH=44) while larger cards center their glyphs.Default parity
At
colWidth=200/cardHeight=44the new formulas produce exactly the previous hardcoded values (12, 11, 11, 14 for title / add-button / card-text / menu-glyph), so existing kanbans render identically on first load.Out of scope
×delete glyph.Test results
cargo check --workspace: passcargo test --workspace --lib: passcargo clippy --workspace -- -D warnings: passcargo fmt --check: passPull request opened: #64
This PR implements the changes discussed in this issue.