Files
crosscode-platform/apps/events/frontend/src/lib/theme.ts
T
joshuaandClaude Opus 5.5 abd2c36e97 WIP 2.0.0: React Compiler lint rules back to errors; docs
- The 192 places the rules flagged are fixed and the rules are errors
  again (npx eslint src: nothing). lib/hooks.ts: useStateSync (state
  that follows other state, set while rendering), useExternalEffect
  (API loads and browser reads), useNow; lib/navigation.ts hardNavigate
  for full reloads after sign-out or identity switches; other pages use
  the router. Resets moved into the handlers that cause them.
- The banner shows and hides at its times on open pages.
- HANDOVER, roadmap, README, FEATURES, SETTINGS, CHANGELOG updated;
  2.0.0 section drafted in WHATS-NEW.

e2e 102/102 (PayFast sandbox skipped); production build passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:45:25 +02:00

32 lines
1.2 KiB
TypeScript

"use client";
import { useState } from "react";
import { useExternalEffect } from "@/lib/hooks";
/**
* Static fallback for BRAND_600 — used as the initial value before the
* client can read the live CSS custom property (see useBrandColorVar below),
* and as the SSR/first-paint value. Keep in sync with globals.css's
* `--brand-600` default.
*/
const BRAND_600_FALLBACK = "#4F46E5";
/**
* Reads a live brand CSS custom property (e.g. `--brand-600`) off the
* document root. Needed by the rare spot that requires a literal color value
* instead of a Tailwind class (SVG stroke/fill, canvas, etc.) — Tailwind
* classes like `text-brand-600` pick up the admin-configurable primary color
* automatically via CSS variables (see tailwind.config.js), but a literal
* hex string has to be read explicitly since it can't reference `var()`.
*/
export function useBrandColorVar(cssVar: string, fallback: string = BRAND_600_FALLBACK): string {
const [color, setColor] = useState(fallback);
useExternalEffect(() => {
const value = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
if (value) setColor(value);
}, [cssVar]);
return color;
}