Theme & Branding Engine
I korthet
A theme engine that turns each tenant's BrandingConfig into scoped CSS variables, ships pre-built archetype themes (modern, classic, sport, minimal), supports header/footer customization and validated custom CSS, and lets club sites inherit federation branding while still picking their own accent. The default theme matches the platform's bottle-green and ivory shadcn system with Fraunces and Inter, giving every new site a polished look on day one.
Så fungerar det
Theming is a thin layer on top of the design tokens shared by www and web. Each CmsSite stores a BrandingConfig containing logo URL, primary_color, accent_color, font_pair_id, sender-name and dark-mode preference. On render, the Next.js layout emits a server-rendered `<style>` tag scoped to `[data-tenant-brand="<site.id>"]` that injects CSS variables — `--tenant-brand-primary`, `--tenant-brand-accent`, foreground variants derived via YIQ luminance for AA contrast, and an auto-derived accent (×1.18 lightness) when the editor leaves accent_color blank.
Pre-built theme templates (modern, classic, sport, minimal) are JSON presets that the wizard applies to BrandingConfig in one click; switching themes never destroys the logo or custom colors, only the structural layout choices. Header and footer are configurable via layout presets (six headers including sticky, centered-logo, transparent-hero; six footers including multi-column, social-focused, hidden) so editors don't write code to change shell. Advanced users can inject scoped custom CSS — validated for brace mismatches and warned about `!important` use, version-tracked, and prefixed with the site selector so it cannot leak into other tenants.
Every site is responsive by default with mobile-first breakpoints, and dark mode flips the variable set via the shared ThemeProvider hook. Federation brand inheritance is opt-in per club site: a child site can declare `inherit_from_parent: true` and pick which fields to override, ensuring national visual identity without locking clubs in. The default theme out of the box is the platform's bottle-green primary, ivory surface, Fraunces display and Inter body, giving full shadcn parity with www.petanque.life.
Centrala funktioner
- Per-site BrandingConfig (logo, colors, font, sender-name) injected as scoped CSS variables
- Pre-built theme templates (modern, classic, sport, minimal) applied non-destructively
- Header and footer layout presets — no code required
- Validated, scoped custom CSS injection for advanced users
- Mobile-first responsive design with dark mode
- Federation brand inheritance with selective field override
- Bottle-green + ivory default theme matching the platform design system
I praktiken
Sofia, communications lead at the Swedish Federation, wants club sites to feel cohesive without forcing identical branding. She opens the federation theme tab, sets the primary color, the Fraunces+Inter font pair, and the SBF-blue logo. She enables 'Allow inheritance' and tags color and fonts as inheritable.
Klara at BK Hagaberg creates her club site, picks 'Inherit from federation' and overrides only the accent to her club's terracotta. The renderer produces a header that visually echoes the federation while keeping the club's identity. A month later Klara wants a tighter spacing on her hero — she pastes a six-line custom CSS snippet into the advanced tab, the validator warns about one `!important`, she removes it, and the change goes live within the next ISR window.
Features i detta subsystem
8| ID | Status | Funktioner |
|---|---|---|
| F18.03.01 | Levererad | Per-site theming (colors, fonts, logo) — PL-F1803a ✅ PL-F1803a |
| F18.03.02 | Levererad | Pre-built theme templates (modern, classic, sport, minimal) — PL-F1803a ✅ PL-F1803a |
| F18.03.03 | Levererad | Header/footer layout customization — PL-F1803a ✅ PL-F1803a |
| F18.03.04 | Levererad | Custom CSS injection (for advanced users) — PL-F1803a ✅ PL-F1803a |
| F18.03.05 | Levererad | Responsive design (mobile-first) — PL-F1803b ✅ PL-F1803b |
| F18.03.06 | Levererad | Dark mode support — PL-F1803b ✅ PL-F1803b |
| F18.03.07 | Levererad | Federation brand inheritance (club sites can inherit national branding) — PL-F1803b ✅ PL-F1803b |
| F18.03.08 | Levererad | Default-tema: bottle-green + ivory, Fraunces display + Inter body, shadcn-parity med www — PL-T109 ✅ PL-T109 |
Intressenter som behöver detta subsystem
Förekommer i 1 intressentanalyser