Skip to content

feat(templates): add Mailbag newsletter template (newsletter-mailbag) - #428

Merged
anurag629 merged 2 commits into
codercops:devfrom
Saifjafri212213:fix/410-newsletter-mailbag
Nov 20, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
Saifjafri212213:fix/410-newsletter-mailbag

Conversation

@Saifjafri212213

Copy link
Copy Markdown
Collaborator

Description

Adds the Mailbag newsletter template (newsletter-mailbag) in the Newsletter category, as requested in #410.

How it works:

  • New template src/templates/newsletter/mailbag.ts (id: 'newsletter-mailbag'):
    • Header row with newsletter site name on top left and issue number on top right
    • Fixed "Mailbag" pill under the header in accent tone
    • Auto-scaling issue title with single-line ellipsis truncation
    • Up to three reader question rows stacked below the title, each with an accent-bordered "Q" circle, the question text, and the asker's name in muted tone on the right
    • Blank questions cleanly drop their entire row (including the asker) and the remaining rows close up
    • If all three questions are blank, the question list is completely omitted and the title sits cleanly below the header
    • Blank askers allow questions to utilize the full row width
    • Long questions and askers truncate with an ellipsis on one line, ensuring the question maintains majority width
    • Empty siteName or issue leaves no gap in the header, and an empty header row is omitted entirely
    • Adaptive contrast support for light backgrounds via isLightColor() and mixColors() so the pill, Q circles, and askers stay readable
  • Unit test suite tests/templates/mailbag.test.ts (10 tests) covering registration, defaults, dropped question rows, all blank questions, blank asker width expansion, title auto-sizing, question and asker truncation, empty header fields, and light background readability.
  • Re-exported in src/templates/newsletter/index.ts and registered in the newsletter block of src/templates/registry.ts.

Closes #410

How I Tested This

  • npx vitest run tests/templates/mailbag.test.ts → 10/10 tests passed
  • npm test → 112 test files, 2152/2152 tests passed
  • PREVIEW_FILES=src/templates/newsletter/mailbag.ts npx vitest run tests/templates/previews.test.ts → rendered all 4 variants (defaults, empty, light, long)
  • npx tsc --noEmit → 0 errors

AI Assistance

Antigravity for layout structure, Satori element hierarchy, and unit test coverage.

Type of Change

  • New template
  • Bug fix
  • New feature
  • Documentation
  • Tests
  • Refactoring
  • Performance improvement

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • npm run check / tsc --noEmit passes
  • npm run test passes
  • New templates follow the Template Guidelines

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Saifjafri212213, nice work, the header, pill and three rows match #410, a blank question drops its whole row and the rest close up, and with all three blank the title sits right under the pill. In the long preview the questions stop with an ellipsis before the askers, which truncate too, and the Q circles and askers read fine on the light background.

One thing before I can merge: the title is held to one line (whiteSpace: 'nowrap' at src/templates/newsletter/mailbag.ts:333), so a title past roughly 50 characters gets cut, while the defaults leave about 170px empty at the bottom of the card. In the long preview it stops around 70 of its 140 characters. Reader Poll lets its title run to two lines (src/templates/newsletter/poll.ts:186), so please do the same here: drop the nowrap, cap it at two lines with display: 'block' and lineClamp: 2 the way Transcript does (src/templates/podcast/transcript.ts:122), and move the size steps up toward Poll's (58, 48, 40 and 34px). Three rows still fit under a two-line title at that size. The test at tests/templates/mailbag.test.ts:134 will need to change to match.

Everything else looks good.

@Saifjafri212213

Copy link
Copy Markdown
Collaborator Author

Thanks for the review @anurag629! I've updated this in b86dbd7:

  • Dropped whiteSpace: 'nowrap' and configured the title with display: 'block' and lineClamp: 2 (with lineHeight: 1.15).
  • Moved the font size steps up to Poll's steps: 58px (up to 36 chars), 48px (up to 64 chars), 40px (up to 96 chars), and 34px (up to 140 chars).
  • Updated the unit test to verify the two-line clamp and size scaling.

All 10 unit tests, 112 test files (2152 tests), Resvg preview renders (all 4 variants), and TypeScript checks pass cleanly.

@anurag629 anurag629 added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 20, 2026
@anurag629
anurag629 merged commit 66ada82 into codercops:dev Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the Mailbag newsletter template (newsletter-mailbag)

2 participants