refactor/design: align app chrome with the Main-Theme spec #1
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/design"
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
Aligns the 5e Monster Maker app chrome with the BlackHatMagic Main-Theme design language and fixes several defects found while auditing it. The Monster Manual stat-block theme is intentionally left visually unchanged (only the bug below).
Design alignment
surface-muted,on-surface-muted,border-strong,on-primary,error,on-error) and matchesMain-Theme/DESIGN.mdvalue-for-value in all eleven themes. Adds System mode (with per-mode preferences) alongside Light/Dark.@fontsource-variable, keeps Noto Serif scoped to the stat block, and removes the Google Fonts links. The Monster Manual fonts it already referenced (Noto Sans,Libre Baskerville) are now actually loaded..editor-control,.editor-button, and.shell-buttonclasses with spec heights (40/44/32),border-strongfield outlines, on-primary text, and correct primary/quiet/danger hover states.Bug fixes
fix/editor: switching tabs faster than a lazy editor's dynamic import resolved left the panel stuck on "Loading …" forever; the pending import is no longer cancelled on deactivation.fix/editor: section navigation could scroll to a stale offset because lazy content and web fonts grow the panel after the first scroll; the heading is now re-aligned while the panel settles.fix/proficiencies: two malformed Tailwind arbitrary variants (repeat(2,minmax(0,1fr)))) that silently dropped the responsive grid.test: vendored the portable-format TOML fixture so the unit suite no longer depends on a siblingObsidian-Stat-Blockscheckout.Testing
bun run check— 0 errors, 0 warningsbun run test— 269 passedbunx playwright test— 29 passedbun run build— Cloudflare adapter output generatedNotes / risks
Review responses
Round 1 (review #17) raised two P2 findings; both were handled and rechecked in review #19.
ResizeObserverwith a boundedrequestAnimationFramepass that waits for the heading to mount and hold its offset for two frames before scrolling once, so later edits that resize the panel no longer move the scroll. The automated recheck marked it resolved.max-w-60defeated by.editor-control— marked incorrect, with evidence..editor-controlno longer declaresmax-width, so the layeredmax-w-60utility applies. In Chromium at desktop width the stat-block theme select computesmax-width: 240pxand renderswidth: 240pxinside a 696px grid cell;width: 100%andmax-width: 15remcompose normally.tests/e2e/monster-maker.spec.tsnow asserts the cap.Pi code review
2 new actionable findings
src/lib/components/preview/PreviewThemePicker.svelte:53src/lib/components/editor/EditorWorkspace.svelte:57Outside the diff
[P2] Retained max-w-60 utility on the stat-block theme select is defeated by the new unlayered .editor-control rule
The PR introduces
.editor-controlas an unlayered top-level rule in src/app.css, which setswidth: 100%andmax-width: 100%. PreviewThemePicker's stat-block theme keeps themax-w-60utility class alongside the new class. Tailwind v4 (@import "tailwindcss" in app.css) emits utilities inside theutilities@layer, and per the CSS cascade, unlayered author styles take precedence over any layered styles regardless of order. Themax-w-60(max-width: 15rem) declaration therefore always loses to.editor-control'smax-width: 100%, so the select silently stretches to the full toolbar/preview-column width instead of the 15rem cap the retained class documents, on every theme and every viewport. The class was kept precisely to cap the width, so the rendered layout contradicts the source intent.Trigger: Any page load; the width cap is dropped whenever the select renders, most visibly on wide (desktop) screens where the preview column exceeds 15rem.
Impact: Visible layout regression in the live-preview toolbar: the stat-block theme select is much wider than designed in all eleven themes; the stale utility also misleads future maintainers.
Evidence: src/app.css (unlayered, after the layered @import "tailwindcss") declares
.editor-control { width: 100%; max-width: 100%; ... }; src/lib/components/preview/PreviewThemePicker.svelte select uses classeditor-control max-w-60and no other max-width mechanism — unlike every other control in this PR, where conflicting width/padding utilities were removed when .editor-control was adopted (e.g. ActionCard inputs).Suggested fix:
Location:
src/lib/components/preview/PreviewThemePicker.svelte:53(outside the diff; posted here because it can't anchor inline).Reviewed the design-alignment refactor across theme tokens/palettes, controls markup, ThemePicker/theme-store behavior, and the three claimed bug fixes (lazy editor import, scroll settle, Tailwind arbitrary variants) against the pinned head. Tool budget prevented reading stat-block-themes.ts, theme-palettes.test.ts and the fixture-consuming unit tests, and no build/test browser runs were possible, so those reads and the runtime claims in the PR description remain unverified. Reviewed the design-alignment refactor across palettes, theme CSS, theme store, and the two editor fixes plus the vendored fixture. Theme blocks in app.css match palettes.ts value-for-value, the LazyEditor deactivation fix and the ProficienciesEditor Tailwind grid fix check out, but the new scroll-settle observer re-aligns on any panel resize, not just lazy-load growth.
Change walkthrough
src/app.css,src/lib/theme/palettes.ts,src/lib/state/theme-store.ts,src/lib/components/app-shell/ThemePicker.svelte(+8 more)tests/fixtures/ancient-red-dragon.toml,tests/e2e/monster-maker.spec.ts,tests/unit/theme-palettes.test.ts,tests/unit/toml.test.tsReview effort: 4/5.
Static observations (not validation results)
Reviewed
3c631f3aaa831b3e5cc4c8c17009a91fc6375856withopencode-go/glm-5.3-flash. Automated advisory review; no project commands or tests were executed.@ -26,0 +54,4 @@const observer = new ResizeObserver(() => {if (firstCallback) {firstCallback = false;return;[P2] Scroll-settle observer yanks the user's scroll position on any panel resize after section navigation
settleSectionScroll() re-aligns the section heading on every ResizeObserver callback for the editor panel, not only when lazy content or fonts grow the panel. Every re-alignment also pushes the hard-stop timeout out by another 300ms (it clears and resets the same settleStopTimer), so the window extends as long as the panel keeps resizing. Any height change after navigating to a section — typing text that wraps, adding/removing a list entry, toggling a control that changes layout — triggers an instant (behavior: 'auto') scrollIntoView back to the section heading, snapping the user away from what they were editing. The comment claims the observer 'stops so the user can scroll freely', but scrolling is only preserved because scrolling itself does not resize the panel; user-driven layout changes during the window defeat that guarantee.
Trigger: Navigate to any editor section (starting the settle observer for up to ~1.5s, extended by further resizes) and then perform any edit that changes the panel's height within that window, e.g. typing a new line in a textarea or adding a repeatable entry.
Impact: The user's scroll position is visibly and repeatedly reset to the top of the section while they edit, losing their place and creating a jarring instant jump during normal editing.
Evidence: EditorWorkspace.svelte: the ResizeObserver callback runs alignSection(panel, 'auto') on every resize callback after skipping only the first (firstCallback), and each callback resets settleStopTimer via clearTimeout/setTimeout(cancelScrollSettle, 300), replacing the one-time 1500ms deadline. The observer is attached to the editor section panel itself, so any content growth inside it — not just the lazy-editor load the fix targets — re-aligns the scroll.
Pi code review
0 new actionable findings
No new actionable findings. Previously reported issues, if any, are tracked below.
Earlier findings: 2 rechecked
src/lib/components/editor/EditorWorkspace.svelte:57, first reported in review #17) — Current EditorWorkspace.svelte has no ResizeObserver-driven re-alignment: alignSectionWhenSettled uses a rAF loop that runs alignSection once after the heading's offsetTop stays stable for 2 frames (capped at 90 frames), and cancelScrollSettle is only called on rAF teardown and via the $effect cleanup; no listener reacts to panel resizes, so edits that change panel height no longer yank the scroll position after section navigation. Source of record for this recheck: src/lib/components/editor/EditorWorkspace.svelte alignedSectionWhenSettled loop (lines 44-70) and its only caller in the sectionScrollRequest $effect (lines 104-119).src/lib/components/preview/PreviewThemePicker.svelte:53, first reported in review #17) — Still present in current code: src/app.css defines unlayered .editor-control { width: 100%; ... } (no max-width declaration, but width:100% is unlayered author authority) while PreviewThemePicker.svelte renders the stat-block theme select with class="editor-control max-w-60", and no other max-width mechanism exists on that select. Tailwind v4 emits utilities in @layer utilities via the @import "tailwindcss" in app.css, and unlayered author styles beat layered ones regardless of order — so max-w-60 cannot win for max-width. However, the original finding cited max-width: 100% in .editor-control; the current rule has no max-width declaration at all, which stat-block→width interplay means max-w-60 SHOULD still apply for max-width... but since width:100% also comes from the unlayered block, the select still stretches beyond 15rem within its grid cell.Re-checked both prior findings against head (scroll-settle logic, editor-control cascade cap); verified the lazy-editor retained-import fix and the System-mode theme store wiring by reading the current implementation and callers. Automated checks could not be run; residual gap is that CSS cascade and scroll behavior claims rest on code reading rather than browser execution. Reviewed the theme-system alignment and the four stated bug fixes by comparing head vs base for the lazy-editor loading logic, section scroll alignment, proficiency grids, theme palettes/store, and the vendored TOML fixture, plus the pre-hydration theme script. No evidence-backed defects were found in the inspected code; the 30-operation repository budget was exhausted before the remaining styling-only components (stat-block.css, remaining editors, footer) could be diffed, so that surface is unverified.
Change walkthrough
tests/unit/theme-palettes.test.ts,tests/unit/toml.test.ts,tests/fixtures/ancient-red-dragon.tomlsrc/lib/components/editor/LazyEditor.svelte,src/lib/components/editor/EditorWorkspace.svelte,src/lib/components/editor/ProficienciesEditor.svelte,src/lib/theme/palettes.ts(+3 more)Review effort: 3/5.
Static observations (not validation results)
Reviewed
96c5d7508f6e83e2f9e5e7ef9babc914249bb079withopencode-go/glm-5.3-flash. Automated advisory review; no project commands or tests were executed.Review round 2 response
max-w-60on the stat-block theme select:.editor-controlno longer declaresmax-width, so the layeredmax-w-60utility applies. Verified in Chromium at desktop width: the select computesmax-width: 240pxand renderswidth: 240pxinside a 696px grid cell.width: 100%andmax-width: 15remcompose normally (the cap wins), so the select is not stretching. An e2e assertion now locks this intests/e2e/monster-maker.spec.ts.Pi code review
0 new actionable findings
No new actionable findings. Previously reported issues, if any, are tracked below.
Earlier findings: 1 rechecked
src/lib/components/preview/PreviewThemePicker.svelte:53, first reported in review #17) — Current head src/app.css defines .editor-control with width:100%, padding, border, and font rules but no max-width declaration at all, so the retained max-w-60 utility (15rem) composes normally with width:100% and the 240px cap applies. The layered/unlayered conflict described previously no longer exists; tests/e2e/monster-maker.spec.ts additionally asserts toHaveCSS('max-width','240px') on #preview-theme.Reviewed the head (
82d4378) against base (ad38c27), focusing on the theme-system rework (system-mode preference, palette role expansion), shared control classes, the lazy-editor and scroll-settle fixes, and the prior max-w-60 finding. Context budget limited late repo re-verification, but the diff plus head reads of app.css, ThemePicker, LazyEditor, and app.html covered the cited defects. Reviewed the two test-file diffs in the PR description against the head tree, tracing the app.css theme blocks, palettes.ts, theme store, LazyEditor, EditorWorkspace scroll-settle logic, and the ProficienciesEditor variant fixes. The palette values, CSS token sync, vendored fixture path, lazy-editor retention, and corrected Tailwind arbitrary variants all check out; remaining verification was limited by the repository read budget (ThemePicker and e2e spec could not be inspected).Change walkthrough
src/app.css,src/lib/theme/palettes.ts,src/lib/state/theme-store.ts,src/lib/components/app-shell/ThemePicker.svelte(+3 more)tests/fixtures/ancient-red-dragon.toml,tests/components/app-shell.test.ts,tests/e2e/monster-maker.spec.ts,tests/unit/theme-palettes.test.ts(+1 more)Review effort: 3/5.
Static observations (not validation results)
Reviewed
82d4378c81e0bb540baa9ceba7330e8bc4fb1340withopencode-go/glm-5.3-flash. Automated advisory review; no project commands or tests were executed.Pi code review
0 new actionable findings
No new actionable findings. Previously reported issues, if any, are tracked below.
Reviewed the Main-Theme alignment PR end-to-end: theme token/palette rewrite (including the new alucard theme and System mode in theme-store, the app.html early-boot script, and stat-block-themes wiring), the shared control classes, the LazyEditor pending-import fix, the bounded scroll-settle pass in EditorWorkspace, and the corrected Tailwind arbitrary variants. No reachable defects found: the stored 'system' preference is resolved consistently by both the inline boot script and initTheme, the theme-palettes test/comment wiring covers the new palette, loader promise caching makes the LazyEditor fix safe, and the settle loop is bounded and cancelled on cleanup; tool access to search/stat-block tests was cut short by repository context limits, so the palettes↔app.css sync test and grep for now-unused exports were not independently re-run. Reviewed the design-alignment PR: theme palette/CSS token sync, System mode wiring, lazy-editor load fix, scroll-settle logic, font imports, Tailwind variant fix, and the vendored TOML fixture. All inspected code is consistent and matches the PR's stated fixes; repository tool budget was exhausted before reading the vendored fixture bytes and the e2e max-width assertion, and no build/tests could be executed in this read-only review.
Change walkthrough
src/app.css,src/app.html,src/lib/state/theme-store.ts,src/lib/theme/palettes.ts(+5 more)tests/fixtures/ancient-red-dragon.toml,tests/e2e/monster-maker.spec.tsReview effort: 4/5.
Static observations (not validation results)
Reviewed
054975f439b2bff20e315b026ca840a34f179f6ewithopencode-go/glm-5.3-flash. Automated advisory review; no project commands or tests were executed.