wwwfiberdirekt/src/utilities/fdTheme.ts
Jeffrey 15c3194eb6 refactor: codebase audit — remove orphaned blocks, unify design tokens
- Delete 5 orphaned blocks: ArchiveBlock, CallToAction, Content, Form, RelatedPosts
  - Remove Form import from RenderBlocks
  - Delete Media-BACKUP.txt
  - Extract fdCardRadius, fdCardRadiusSm to fdTheme — adopted across 15 blocks
  - Extract fdContainer to fdTheme — adopted across 29 blocks
  - Add fdSepiaOverlay, fd-sepia CSS token — replaces hardcoded #8B7D3C
  - Replace #153350 with via-fd-navy-700 in navyGradient
  - Replace #e2e8f0 with fd-gray-light in calculator blocks
2026-03-13 13:22:16 +01:00

87 lines
3.9 KiB
TypeScript

/**
* Fiber Direkt — Shared Theme Utilities
*
* Extracts the repeated sectionBgMap / headingColor / bodyColor logic
* that was duplicated across 15+ block components into a single source of truth.
*
* Usage in any block:
* import { sectionBg, isExplicitDark, headingColor, bodyColor, mutedColor } from '@/utilities/fdTheme'
*
* const bg = sectionBg(sectionBackground)
* const dark = isExplicitDark(sectionBackground)
* const hClr = headingColor(dark)
*/
/* ── Section backgrounds ─────────────────────────────────────────────── */
const sectionBgMap: Record<string, string> = {
white: 'bg-white dark:bg-fd-navy',
gray: 'bg-fd-gray-light dark:bg-fd-navy',
navy: 'bg-fd-navy',
yellow: 'bg-fd-yellow',
navyGradient: 'bg-gradient-to-br from-fd-navy via-fd-navy-700 to-fd-navy',
transparent: 'bg-transparent',
}
export const sectionBg = (bg?: string | null): string =>
sectionBgMap[bg || 'white'] || sectionBgMap.white
/* ── Dark detection ──────────────────────────────────────────────────── */
export const isExplicitDark = (bg?: string | null): boolean =>
bg === 'navy' || bg === 'navyGradient'
/* ── Text colors ─────────────────────────────────────────────────────── */
/** Heading: yellow on dark, navy on light (auto-adapts to OS dark mode) */
export const headingColor = (dark: boolean): string =>
dark ? 'text-fd-yellow' : 'text-fd-navy dark:text-fd-yellow'
/** Body: white on dark, navy on light */
export const bodyColor = (dark: boolean): string =>
dark ? 'text-white' : 'text-fd-navy dark:text-white'
/** Muted / secondary body text */
export const mutedColor = (dark: boolean): string =>
dark ? 'text-white/60' : 'text-fd-navy/60 dark:text-white/60'
/** Subdued body (80% opacity) */
export const bodySubduedColor = (dark: boolean): string =>
dark ? 'text-white/80' : 'text-fd-navy/80 dark:text-white/80'
/** Border color */
export const borderColor = (dark: boolean): string =>
dark ? 'border-white/20' : 'border-fd-navy/10 dark:border-white/20'
/** Link color */
export const linkColor = (dark: boolean): string =>
dark
? 'underline underline-offset-2 hover:text-fd-yellow transition-colors'
: 'underline underline-offset-2 hover:text-fd-navy dark:hover:text-fd-yellow transition-colors'
/** Label text (for form labels etc.) */
export const labelColor = (dark: boolean): string =>
dark ? 'text-white' : 'text-fd-navy dark:text-white'
/** Error text */
export const errorColor = (dark: boolean): string =>
dark ? 'text-red-300' : 'text-red-600 dark:text-red-300'
/* ── Responsive border-radius ────────────────────────────────────────── */
/** Signature FD card radius — responsive so 375px screens don't get capsule cards */
export const fdCardRadius = 'rounded-[32px] md:rounded-[50px] lg:rounded-[70px]'
/** Smaller radius for sub-elements (images inside cards, data tables, etc.) */
export const fdCardRadiusSm = 'rounded-[20px] md:rounded-[30px] lg:rounded-[40px]'
/* ── Layout ───────────────────────────────────────────────────────────── */
/** Standard page container — max width + horizontal padding */
export const fdContainer = 'max-w-[1200px] mx-auto px-6 md:px-8'
/* ── Overlay utilities ────────────────────────────────────────────────── */
/** Sepia colour overlay for images */
export const fdSepiaOverlay = 'bg-fd-sepia/30'