feat: Design and implement CSS design token system#1
Open
charliewwdev wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Define semantic CSS custom properties (--color-bg, --color-surface, --color-text-primary, etc.) for both light and dark palettes. Apply via :root and [data-theme='dark'] selectors.
Generated by OpenDev AI
Three-layer design token system for OpenDev:
tokens.css — Single CSS file with all custom properties. Primitive palette (~80 raw values) is theme-invariant; semantic tokens (bg, surface, text, border, accent, status) are declared on :root (light) and overridden on [data-theme='dark']. Shadows increase opacity in dark mode. Reduced-motion @media sets all durations to 0ms. Eight categories: colors, typography, spacing (4px grid), radius, shadow, motion, and z-index.
tokens.ts — Exhaustive TypeScript union types for every token name so typos are caught at compile time.
token()returns the CSS var() string for inline styles.cssVar()reads live computed values from the DOM.applyTheme()/loadTheme()handle localStorage persistence.buildAntiFlashScript()emits an inline script for the HTML to prevent FOUC on hard reload.useTheme.ts — React hook that hydrates from localStorage after mount (SSR-safe), applies the theme as a side-effect, and listens for OS-level prefers-color-scheme changes when preference is 'system'. Exposes
theme,resolvedTheme,setTheme,toggleTheme, andisMounted.