Files
Mohammed Abad d28b4caa7e docs(react_frontend): add comprehensive documentation & AGENTS.md
- docs/README.md: overview and table of contents
- docs/tech_stack.md: full dependency inventory and design decisions
- docs/project_structure.md: directory tree with conventions
- docs/architecture.md: data flow, layer responsibilities, key patterns
- docs/routing.md: route table, code splitting, discover categories
- docs/state_management.md: Zustand stores and React Query conventions
- docs/api_layer.md: all API modules with endpoint mappings
- docs/components.md: layout, entries, collections, charts, dialogs, UI primitives
- docs/pages.md: all 16 pages with features and routes
- docs/styling.md: theming, CSS tokens, responsive breakpoints, animations
- AGENTS.md: architecture summary, code conventions, data flow, key files
2026-04-10 02:44:06 +01:00

3.7 KiB

Styling & Theming

CSS Architecture

  • Framework: Tailwind CSS 4 via @tailwindcss/vite plugin
  • Colour space: OKLCH (CSS oklch() function)
  • Theming: CSS custom properties on :root, switched via .dark / .light class on <html>
  • Font: Geist Variable (loaded locally)
  • Border radius: 0.625rem (global --radius token)

Theme Variables

Defined in src/index.css as CSS custom properties. All colours use OKLCH values.

Core Tokens

Variable Purpose
--background Page background
--foreground Default text colour
--card Card background
--card-foreground Card text colour
--primary Brand / accent colour
--primary-foreground Text on primary background
--secondary Secondary surfaces
--muted Muted backgrounds
--muted-foreground Muted text
--accent Interactive accent colour
--destructive Error / delete actions
--border Default border colour
--input Input field border
--ring Focus ring colour

Chart Tokens

Variable Purpose
--chart-1 Chart colour 1
--chart-2 Chart colour 2
--chart-3 Chart colour 3
--chart-4 Chart colour 4
--chart-5 Chart colour 5

Sidebar Tokens

Variable Purpose
--sidebar-background Sidebar background
--sidebar-foreground Sidebar text
--sidebar-primary Active item text
--sidebar-accent Active item bg
--sidebar-border Sidebar border
--sidebar-ring Sidebar focus ring

Dark / Light Mode

Theme toggling is managed by useThemeStore (Zustand, persisted to localStorage).

The setTheme action applies the corresponding class to document.documentElement:

document.documentElement.classList.remove('light', 'dark');
document.documentElement.classList.add(theme);

Tailwind's darkMode: 'class' strategy detects the class and applies dark: variants.

Both .dark and .light rulesets are defined in index.css with different OKLCH values for all tokens.


Responsive Breakpoints

Standard Tailwind defaults:

Breakpoint Min-width Typical usage
sm 640 px 3-col grids
md 768 px 4-col grids, sidebar
lg 1024 px 5-col grids
xl 1280 px 6-col grids
2xl 1536 px 7-col grids

Animation Utilities

Class Effect
animate-page-enter Fade + slide-up on page mount
animate-card-enter Staggered fade-in for card grids
animate-in fade-in Generic fade-in with configurable duration

Card staggering is achieved via inline animation-delay based on the card index.


Component Styling (shadcn/ui)

UI primitives in src/components/ui/ use:

  • class-variance-authority (via shadcn internals) for variant props
  • cn() utility (src/lib/utils.ts) = clsx + tailwind-merge for conflict-free class composition
  • All colours reference CSS custom property tokens, not hard-coded values