Skip to content

fix: stop overriding template .card layout in gallery + editor preview#2487

Merged
aalemayhu merged 1 commit into
mainfrom
fix/templates-restore-template-centering
May 20, 2026
Merged

fix: stop overriding template .card layout in gallery + editor preview#2487
aalemayhu merged 1 commit into
mainfrom
fix/templates-restore-template-centering

Conversation

@aalemayhu
Copy link
Copy Markdown
Contributor

@aalemayhu aalemayhu commented May 20, 2026

Summary

The previous fix (#2486) added `body > .card { display: flex; ... padding: 16px; text-align: center }` to the iframe wrapper. That selector is specificity 0,1,1 — higher than templates' own `.card { ... }` (0,1,0) — so it stomped every template that had its own centering and padding.

Visible breakage

  • Live editor preview broken: `/templates/edit/vocab-language` no longer centers because Vocabulary's `.card { display: flex; align-items: center; padding: 32px 24px }` was overridden by my wrapper.
  • Clean Basic gallery thumbnail clipped the `?` from "What is the capital of France?" on the right edge (16px padding ate into the content area while the template's font size still assumed 800px internal).
  • Alexander Deluxe (Blue) wrapped onto a second line that clipped at the bottom; (Blue — Cloze) lost the leading "The".

What changes

One line in `renderNoteTypePreview.ts`: wrap the default `.card` layout rule in `:where(body > .card)` (specificity drops to 0,0,0). Templates' own `.card` rules now always win. Templates without a `.card` display rule (Default, Only Notion, Raw Note, Minimal) still get flex-column centering as the fallback. Padding removed — that's the template's call.

Test plan

  • `pnpm --filter 2anki-web vitest run src/pages/TemplatesPage` — 44 tests pass
  • `pnpm --filter 2anki-web typecheck` clean
  • `pnpm --filter 2anki-web lint` clean
  • After deploy: `/templates/edit/vocab-language` shows Vocab centered again
  • After deploy: Clean Basic + Alexander Deluxe text no longer clips at edges

🤖 Generated with Claude Code


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Last commit added `body > .card { display: flex; ... padding: 16px;
text-align: center }` with specificity 0,1,1 — higher than templates'
own `.card { display: flex; ... padding: 32px 24px }` (0,1,0). Result:
every template that had its own centering lost it, and the 16px padding
clipped large-text designs (Clean Basic right edge, Alex Deluxe
wrapping into clipped second lines).

Wrap the default layout rule in `:where(body > .card)` so the
specificity drops to 0,0,0. Templates with their own `.card` rules win
automatically. Templates without — Default, Only Notion, Raw Note,
Minimal — still get flex-column centering as a fallback. Drop the
padding entirely; the template owns padding.

Hit on the live editor preview at /templates/edit/vocab-language
(Vocab's `display: flex; align-items: center` was being stomped) as
well as the gallery thumbnails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for notion2anki ready!

Name Link
🔨 Latest commit b11bad1
🔍 Latest deploy log https://app.netlify.com/projects/notion2anki/deploys/6a0dbb40cdbced0008ba253d
😎 Deploy Preview https://deploy-preview-2487--notion2anki.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@aalemayhu aalemayhu merged commit 6f02d3b into main May 20, 2026
9 checks passed
@aalemayhu aalemayhu deleted the fix/templates-restore-template-centering branch May 20, 2026 13:47
@sonarqubecloud
Copy link
Copy Markdown

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