Skip to content

fix(viewer): make Full-Width toggle actually toggle width; center default at ~780px#159

Open
andrey-golovko wants to merge 2 commits into
alecdotdev:masterfrom
andrey-golovko:fix/full-width-toggle-center-pr
Open

fix(viewer): make Full-Width toggle actually toggle width; center default at ~780px#159
andrey-golovko wants to merge 2 commits into
alecdotdev:masterfrom
andrey-golovko:fix/full-width-toggle-center-pr

Conversation

@andrey-golovko
Copy link
Copy Markdown

Summary

The Full-Width toggle in MarkdownViewer.svelte is currently a visual no-op for the document body. The default and .full-width rules are byte-for-byte identical:

/* before */
.markdown-body {
    padding: 50px clamp(24px, 5vw, 50px);
    max-width: 100%;
}
.markdown-body.full-width {
    padding: 50px clamp(24px, 5vw, 50px);   /* same */
    max-width: 100%;                         /* same */
}

The isFullWidth state only feeds the isOverhanging derivation that decides whether the TOC overlaps the content (MarkdownViewer.svelte:183) — it does not affect the body's width or padding.

A side effect is that on wide monitors the body fills the entire viewer pane, producing very long line lengths.

Change

One-line CSS edit — the default .markdown-body now uses a centering padding:

- padding: 50px clamp(24px, 5vw, 50px);
+ padding: 50px max(24px, calc((100% - 780px) / 2));
  • On wide screens, (100% - 780px) / 2 produces symmetric gutters that visually center an ~780 px content column. The 780 matches the existing magic number already used by isOverhanging at MarkdownViewer.svelte:183, so TOC overhang behavior is consistent.
  • On narrow screens, the max(24px, …) floor keeps a sensible minimum gutter (same 24 px as before).
  • .markdown-body.full-width is unchanged — its existing clamp(24px, 5vw, 50px) padding is now a genuine wide alternative, so toggling Full-Width has a visible effect for the first time.

.markdown-body remains the scroll container, so the scrollbar continues to sit at the pane edge (centering via horizontal padding rather than margin: auto).

Out of scope

  • No JS/TS changes. isFullWidth state, localStorage persistence, and TOC overhang logic at MarkdownViewer.svelte:180-187 are untouched.
  • Content width is hard-coded to 780 px to match the existing constant. Happy to make it a setting in a follow-up if you'd prefer.

Test plan

  • npm run build succeeds (Svelte/Vite, no new warnings on touched rules)
  • Local Tauri release build (cargo tauri build) succeeds; toggling Full-Width visibly switches between centered ~780 px column and full-width on a wide monitor
  • Cross-check at narrow viewport widths (≤ ~830 px) — gutter falls back to 24 px floor as expected
  • Cross-check with TOC visible (settings.showToc) — TOC overhang behavior unchanged

🤖 Generated with Claude Code

andrey-golovko and others added 2 commits May 20, 2026 16:42
…ggle now meaningful

The .markdown-body and .markdown-body.full-width CSS rules in
MarkdownViewer.svelte were byte-for-byte identical, so the Full-Width toggle
had no effect on the document body — it only fed the TOC overhang derivation.

Change the default .markdown-body padding to:

    padding: 50px max(24px, calc((100% - 780px) / 2));

which centers content at ~780px on wide screens (matching the 780 magic
number already used by isOverhanging at MarkdownViewer.svelte:183) and keeps
a 24px gutter floor on narrow screens. The existing .full-width rule's
responsive clamp(24px, 5vw, 50px) padding is now genuinely the wide
alternative, restoring the toggle's purpose.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant