Newsletter: social bar and event countdown parts, full-width builder

- Social bar: a colored band of the site's platform icons, linked;
  no links added shows the footer's (src/data/socialLinks.ts, shared)
- Icons are white and ink PNGs in public/email/, made from
  PlatformIcon.tsx by scripts/email-icons.mjs (no SVG in Gmail/Outlook)
- Event countdown: a picture drawn by /api/countdown/<id>.png when the
  email is opened (days, hours, minutes to local midnight in
  America/Chicago; then happening now; then over), with a fixed line
  under it as of copying
- The builder takes the whole window (useWideAdminPage('full'))

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-02 00:43:28 -05:00
parent a943ecd3a3
commit 00170ca912
29 changed files with 322 additions and 27 deletions

30
scripts/email-icons.mjs Normal file
View file

@ -0,0 +1,30 @@
/* ═══════════════════════════════════════════════════════════════
EMAIL ICONS: node scripts/email-icons.mjs (from the repo root)
Gmail and Outlook don't show SVG, so a newsletter's social bar
(src/lib/newsletter.ts) uses PNG copies of the platform icons in
PlatformIcon.tsx: white and ink, 48px square (shown at 24), into
public/email/, which the build copies as they are, so the files
keep their addresses in emails already sent. Run it again after
adding a platform or changing an icon. Uses the server's sharp.
═══════════════════════════════════════════════════════════════ */
import { readFileSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
const sharp = createRequire(new URL("../server/package.json", import.meta.url))("sharp");
const source = readFileSync(new URL("../src/components/PlatformIcon.tsx", import.meta.url), "utf8");
const paths = {};
for (const [, id, d] of source.matchAll(/^\s*(\w+):\s*'([^']+)'/gm)) paths[id] = d;
for (const [, id, d] of source.matchAll(/^\s*(\w+):\s*\n\s*'([^']+)'/gm)) paths[id] = d;
paths.instagram = /INSTAGRAM_PATH =\s*'([^']+)'/.exec(source)[1];
const TONES = { white: "#ffffff", ink: "#001011" };
for (const [id, d] of Object.entries(paths)) {
for (const [tone, fill] of Object.entries(TONES)) {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="48" height="48"><path fill="${fill}" d="${d}"/></svg>`;
writeFileSync(new URL(`../public/email/${id}-${tone}.png`, import.meta.url), await sharp(Buffer.from(svg)).png().toBuffer());
}
}
console.log(`${Object.keys(paths).length} icons: ${Object.keys(paths).join(", ")}`);