Skip to content

feat: Design and implement CSS design token system#1

Open
charliewwdev wants to merge 4 commits into
mainfrom
feat/design-and-implement-css-design-token-system
Open

feat: Design and implement CSS design token system#1
charliewwdev wants to merge 4 commits into
mainfrom
feat/design-and-implement-css-design-token-system

Conversation

@charliewwdev

Copy link
Copy Markdown
Member

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:

  1. 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.

  2. 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.

  3. 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, and isMounted.

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