Skip to content

fix: card fills template preview iframe and starter section moves up#2484

Merged
aalemayhu merged 1 commit into
mainfrom
fix/templates-card-fill-iframe
May 20, 2026
Merged

fix: card fills template preview iframe and starter section moves up#2484
aalemayhu merged 1 commit into
mainfrom
fix/templates-card-fill-iframe

Conversation

@aalemayhu
Copy link
Copy Markdown
Contributor

@aalemayhu aalemayhu commented May 20, 2026

Summary

Two gallery fixes in the same surface, prompted by user feedback after #2482 + #2483 deployed.

1. Cards fill the iframe edge to edge

`notion.css` ships with `body { margin: 2em auto; max-width: 900px }` — that meant every Notion-flavoured starter (Default Basic/Cloze/Type-the-answer, Only Notion variants) rendered with a band of the gallery card background showing through the top and bottom of the iframe. Visible as a "offset" between the preview wrap and the card content.

Separately, "Raw Note (no style)" has `cssFile: null` so `noteType.css` is empty — the wrapper left both html and body transparent, so the thumbnail showed whatever was behind the iframe.

Fix in `renderNoteTypePreview.ts > buildPreviewDocument`:

  • Wrapper sets a default `background: #fff; color: Visual improvements #111` on html and body.
  • Wrapper re-asserts `margin: 0 / padding: 0 / max-width: none / width: 100% / height: 100%` on html and body after the template CSS, with `!important` so notion.css's `body { margin: 2em auto; max-width: 900px }` no longer wins.
  • Templates that set their own `.card` background (Quote = #1c1917, Alex Deluxe = blue gradient, Abhiyan = night-mode dark) still win because that selector is more specific than the body reset.

2. Section reorder — Starter note types lead the page

Visible sections were ordered:

  1. Your note types
  2. Official 2anki templates
  3. Starter note types

Reordered to:

  1. Your note types
  2. Starter note types (Clean Basic, Modern Cloze, Vocabulary, Medical, Code, Minimal, Quote, Math & Science — polished designs)
  3. Official 2anki templates (Default / Only Notion / Raw / Abhiyan / Alex variants)

User's own work still leads. The polished gallery comes next so the first impression is the strong designs, not the historical defaults.

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: hard-refresh `/templates`, confirm Only Notion thumbnails fill the iframe (no dark band top/bottom), confirm Raw Note (no style) has a white background, confirm Starter section appears above Official

🤖 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

Two gallery fixes in the same surface.

1. notion.css ships with `body { margin: 2em auto; max-width: 900px }`
which made every Notion-flavoured starter render with a band of the
gallery card background showing through top and bottom of the iframe,
and "Raw Note (no style)" had no background at all because the wrapper
left both html and body transparent. The wrapper now sets a default
white background and re-asserts margin/padding/width on html and body
*after* the template CSS so the card always fills the iframe edge to
edge. Templates that set their own .card background (Quote, Alex
Deluxe, etc.) still win because that selector is more specific than
the body reset.

2. Reorder the gallery sections so the polished `defaultStarters`
(Clean Basic, Modern Cloze, Vocabulary Card, Medical Term, Code Card,
Minimal, Quote, Math & Science) lead the page, with the rougher
`officialStarters` (Default/Notion/Abhiyan/Alex variants) below them.
`Your note types` stays at the very top so a user's own work is the
first thing they see.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aalemayhu aalemayhu merged commit 0af15a3 into main May 20, 2026
4 checks passed
@aalemayhu aalemayhu deleted the fix/templates-card-fill-iframe branch May 20, 2026 13:29
@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for notion2anki ready!

Name Link
🔨 Latest commit a0b227e
🔍 Latest deploy log https://app.netlify.com/projects/notion2anki/deploys/6a0db72823f6850008e552bb
😎 Deploy Preview https://deploy-preview-2484--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.

@sonarqubecloud
Copy link
Copy Markdown

aalemayhu added a commit that referenced this pull request May 20, 2026
…2486)

## Summary

Four gallery polish issues from the latest review.

### 1. Default-center .card content

Templates without their own \`.card\` display rules (Default, Only
Notion, Raw Note, Minimal, parts of user-saved defaults) rendered short
text in the top-left, leaving 70%+ of the thumbnail blank.

Wrapper now adds \`display: flex; flex-direction: column; align-items:
center; justify-content: center; padding: 16px; text-align: center\` on
\`body > .card\` as a default. Templates that set their own \`.card\`
display (Quote, Vocabulary, Modern Cloze, Code Card, etc.) keep their
own layout because their declarations are equally specific and come
later in the cascade.

### 2. Inert form fields

Default (Type the answer) renders an \`<input>\` in the qfmt; in the
preview it became a focusable text box that looked broken at thumbnail
scale. \`input, button, select, textarea { pointer-events: none }\` in
the wrapper — they still render as styled elements but can't be focused.

### 3. Image Occlusion fallback

The canvas + script Anki uses to draw masks can't run in
\`sandbox=\"\"\`. The thumbnail was always blank except for the Header
text. Hide \`#image-occlusion-canvas\` and inject \"Image occlusion
preview — install in Anki to see masks\" via \`::after\` on the
container.

### 4. Background defaults (still in place from #2484)

White card behind every template that doesn't set its own background —
Raw Note included.

## Test plan

- [x] \`pnpm --filter 2anki-web vitest run src/pages/TemplatesPage\` —
44 tests pass
- [x] \`pnpm --filter 2anki-web typecheck\` clean
- [x] \`pnpm --filter 2anki-web lint\` clean
- [ ] After deploy: hard-refresh \`/templates\`, confirm Default
Basic/Cloze/Type-the-answer + Only Notion + Raw Note + Minimal now
center their content vertically, and Image Occlusion shows the fallback
message instead of a blank canvas

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/2anki/codesmith/server/pr/2486"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-light.svg"><img
alt="View in Codesmith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"></picture></a>
<sup>Need help on this PR? Tag <code>@codesmith</code> with what you
need.</sup>

- [ ] Let Codesmith autofix CI failures and bot reviews
<!-- /codesmith:footer -->

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