Skip to content

Move theming to semantic tokens with class-based dark mode - #16

Merged
kaishin merged 2 commits into
mainfrom
loop/build/semantic-tokens-dark-mode
Nov 22, 2026
Merged

kaishin merged 2 commits into
mainfrom
loop/build/semantic-tokens-dark-mode

Conversation

@kaishin

@kaishin kaishin commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Backlog item

Move theming to semantic tokens with class-based dark mode (Tasker #517) (Goal 00f314685a5c), criterion C1 of the indigo-static migration.

Gap

Colors were global variables inside the <style is:global> block of src/layouts/Base.astro, switched by a prefers-color-scheme media query, so Tailwind's dark: variant could not follow a site-controlled theme. src/layouts/Legal.astro redefined --background-color with its own media block, and LatticeBackground re-read its canvas colors on a scheme matchMedia change only.

Solution

  • src/styles.css now defines semantic tokens with the exact previous values: light on :root and dark on .dark, with color-scheme set per scheme, plus the site-specific --lattice-* canvas inputs (new --lattice-accent triplet keeps the canvas parser fed now that --accent is a full color). Tokens are exposed through @theme inline as --color-*, and @variant dark (&:where(.dark, .dark *)) enables the class-based variant. The html/body/::selection/:focus-visible/scrollbar rules moved into @layer base using the tokens.
  • New src/components/SetTheme.astro: an is:inline script rendered first in Base.astro's <head> that applies .dark on <html> from a valid localStorage.theme (light, dark, system) or else the system scheme, before first paint, and follows live system-scheme changes while no theme is stored. Base.astro also gains <meta name="color-scheme" content="light dark">. Its style block keeps only the fonts and the reading-column rule.
  • index.astro, CircleLink.astro, CompanyLogo.astro and Footer.astro use the new token names; rgb(var(--accent) / X) became color-mix(in oklab, var(--accent) X%, transparent).
  • LatticeBackground.astro reads --lattice-accent and re-reads colors when the .dark class on <html> changes (MutationObserver on the class attribute) instead of on the scheme media query.
  • Removed the old variables, the prefers-color-scheme color block in Base.astro, and Legal.astro's local override (no page uses it).

Copy, fonts, layout, animations, and shadows are unchanged. A theme picker stays owner-deferred and out of scope.

Validation

  • pnpm check, pnpm format:check, pnpm build all pass.
  • rg -- '--(background-color|card-color|text-primary-color|text-secondary-color|logo-color|on-accent-color|hairline)' src is empty; rg prefers-color-scheme src matches only SetTheme.astro.
  • Browser check against a local build of the base branch: / renders identically in light and dark system schemes (page colors and lattice included), documentElement gains/loses .dark before first paint, emulating a scheme change with no reload flips page and lattice live, and the console shows no errors.

No pre-existing failures to report.


Built by: pi harness, model zai/glm-5.3-flash

@netlify

netlify Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for 4rays ready!

Name Link
🔨 Latest commit 22844fb
🔍 Latest deploy log https://app.netlify.com/projects/4rays/deploys/6b027c405928473c759f8dfa
😎 Deploy Preview https://deploy-preview-16--4rays.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T04:51:04.154206Z 7b67457 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b67457b19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/SetTheme.astro Resolved
Comment thread src/components/SetTheme.astro Resolved
@kaishin

kaishin commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Accepted

  • Keep stored system preferences synchronized (src/components/SetTheme.astro): the scheme-change listener now checks the resolved preference instead of key absence, so a stored system and an invalid stored value keep following live OS-scheme changes while stored light/dark stay pinned.
  • Handle unavailable local storage during theme setup (src/components/SetTheme.astro): storage access is wrapped in try/catch, so browsers with storage blocked fall back to the system scheme and the listener still installs.

Verification: pnpm check, pnpm format:check, and pnpm build passed on 22844fb; the Check & Build check passed on the same head. Browser checks: stored system and invalid values follow live scheme switches, light/dark stay pinned, and a throwing localStorage stub resolves to system without errors.

@kaishin
kaishin merged commit 51ebd36 into main Nov 22, 2026
5 checks passed
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