Skip to content

Add lib/theme.ts source-of-truth and theme-parity verify check#64

Merged
lwwmanning merged 1 commit intomainfrom
claude/lib-theme
May 4, 2026
Merged

Add lib/theme.ts source-of-truth and theme-parity verify check#64
lwwmanning merged 1 commit intomainfrom
claude/lib-theme

Conversation

@lwwmanning
Copy link
Copy Markdown
Contributor

Summary

Establishes a single source of truth for design tokens shared between the runtime site (CSS) and next/og-generated OG images (TS), and adds a CI-enforced parity check so the two sides can't drift silently.

New file src/lib/theme.ts:

export const THEME = {
  background: "#101010",
  foreground: "#ffffff"
} as const;

The OG card in src/lib/og.tsx now imports these constants instead of hardcoding hex literals. The doc comment notes that foreground doesn't currently have a CSS-side counterpart (the site uses Tailwind's built-in text-white), but tracking it here gives the OG components a single name to import and an obvious destination if a future PR adds a --color-foreground token.

Bug fix bundled in: the OG card was painting its background #0a0a0a while the site's actual background is #101010 (declared in globals.css :root as --background). They've quietly diverged since the OG component was scaffolded — close enough that nobody noticed, but inconsistent enough that a click-through from a social share lands on a slightly-lighter dark than the OG preview suggested. This PR converges them on #101010 (the site's actual value), so OG previews now match the site exactly.

New verify check scripts/verify.ts → checkThemeParity():

  • Reads src/app/globals.css from disk
  • Asserts the --background declaration in :root matches THEME.background
  • Skips THEME.foreground (no CSS counterpart to compare against today)

Catches the regression where someone updates one side without the other. Mirrors willmanning's parity-check pattern, narrowed to vortex's smaller token set.

Files

  • New src/lib/theme.ts — the constants, with a header comment that explains the contract and points at the verify check.
  • Modify src/lib/og.tsx — imports THEME, replaces backgroundColor: "#0a0a0a" (now matches site) and color: "#ffffff" (unchanged value, just sourced from THEME). The translucent-white muted variants (rgba(255,255,255,0.7) / 0.3) stay inline — they're alpha-derived from foreground rather than discrete tokens.
  • Modify scripts/verify.ts — adds node:fs/promises + node:path imports, a relative import of THEME, the new checkThemeParity() function, and the corresponding await in main().

Local verification

$ bun run verify
  …
  ok    theme parity                     --background = #101010
  ok    /api/subscribe                   503 with error="Subscription service is not configured"
  …
  Total: 17 passed, 0 failed

Test plan

  • CI green (Lint, build, verify runs the suite end-to-end including the new check)
  • OG previews on the Vercel preview deploy render with #101010 backgrounds (paste preview URL into opengraph.xyz for a visual diff vs. main)
  • If someone deliberately changes :root --background: in globals.css without updating theme.ts, the verify check fails locally with a clear message

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Will Manning <will@willmanning.io>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vortex Ready Ready Preview, Comment May 4, 2026 7:52pm

Request Review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

🔦 Lighthouse audit

URL Perf A11y Best practices SEO Report
/ 🟢 100 🟢 100 🟢 96 🟢 100 report
/blog 🟢 100 🟢 100 🟢 96 🟢 100 report
/blog/btrblocks-compressor 🟢 100 🟢 96 🟢 96 🟢 100 report

Run 25340072030 · 2026-05-04 19:53 UTC

@lwwmanning lwwmanning enabled auto-merge (squash) May 4, 2026 19:53
@lwwmanning lwwmanning merged commit fbfb1f1 into main May 4, 2026
6 checks passed
@lwwmanning lwwmanning deleted the claude/lib-theme branch May 4, 2026 19:53
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