4.1 KiB
4.1 KiB
02. Theme System — Auto-Shifting CSS with Kordant Brand Palette
meta: id: kordant-unified-restructure-02 feature: kordant-unified-restructure priority: P0 depends_on: [kordant-unified-restructure-01] tags: [frontend, design-system, css, theme]
objective:
- Create a comprehensive, auto-shifting CSS theme system for the web app using Tailwind v4
@themeand CSS custom properties with@propertyanimations, adapted from the Lendair reference but using a Kordant-appropriate brand palette.
deliverables:
web/src/app.css— Complete theme file with:@propertydeclarations for all animatable color tokens:rootlight-mode color tokens (backgrounds, text, brand, borders, semantic, glass)@media (prefers-color-scheme: dark)dark-mode overrides:root.lightand:root.darkmanual override classes@themeblock registering all tokens for Tailwind v4- Base styles (
html,body,*:focus-visible) - Utility classes (gradients, glassmorphism, gradient text, glow shadows, dot-grid background, noise texture)
- Global background dot-grid pattern and smooth 500ms color transitions
- Typography scale using Inter font family
- Spacing and radius scale aligned with Lendair's design
steps:
- Copy the Lendair
app.cssstructure from~/code/Lendair/web/src/app.cssas the scaffold. - Replace the brand color tokens with Kordant palette:
- Primary: deep indigo
#4f46e5(brand-primary), light#818cf8(brand-primary-light), dark#4338ca(brand-primary-dark) - Accent: electric cyan
#06b6d4(brand-accent), light#67e8f9(brand-accent-light), dark#0891b2(brand-accent-dark) - Alert/Danger: amber
#f59e0b(warning), red#ef4444(error) - Keep neutral grays from Lendair for backgrounds and text
- Primary: deep indigo
- Add
@propertydeclarations for every custom property that should animate smoothly. - Define
@themeblock with all tokens so Tailwind v4 utility classes resolve correctly. - Implement
prefers-color-scheme: darkmedia query with full dark palette. - Add
.lightand.darkclasses on:rootfor manual JS toggling. - Define utility classes:
.gradient-primary,.gradient-accent,.gradient-subtle,.gradient-card.glass,.glass-dark.text-gradient-primary,.text-gradient-accent.shadow-glow-primary,.shadow-glow-accent.bg-dot-grid,.bg-noise
- Set global
background-color,background-image(dot-grid), andtransitionon:rootandbody. - Import the CSS in
web/src/entry-client.tsxorweb/src/app.tsx(whichever is the root). - Create a small
useTheme()hook inweb/src/lib/theme.tsthat detectsprefers-color-scheme, exposesthemesignal, and toggles.light/.darkondocument.documentElement.
tests:
- Unit:
useTheme()hook returns correct initial theme based on media query; toggling updates class and signal - Visual: Open app in light and dark OS modes; verify all colors shift smoothly over 500ms
- Visual: Toggle theme manually via
useTheme(); verify override persists across reloads (localStorage)
acceptance_criteria:
- All color tokens animate smoothly between light/dark modes
- Tailwind utilities like
text-brand-primary,bg-bg-secondary,border-borderwork correctly - Manual theme toggle (light/dark/system) functions and persists
- Dot-grid background pattern renders correctly in both modes
- No FOUC (flash of unstyled content) on initial load
validation:
- Open
http://localhost:3000in browser DevTools - Toggle OS dark mode; verify background, text, and card colors shift
- Run
document.documentElement.classList.add('dark')in console; verify immediate dark mode - Check computed styles for
--color-bgand confirm it matches token values
notes:
- Reference:
~/code/Lendair/web/src/app.css— this is the exact structure we want, just with Kordant colors. - Tailwind v4
@themeis compile-time; changing tokens requires rebuild. Runtime theme switching uses CSS custom properties. - The
transitionon:rootandbodymust includebackground-colorandcolorfor smooth shifts. - Consider adding a
theme-colormeta tag that updates with the theme for mobile browsers.