import * as React from "react"; import { cn } from "@/shared/lib/cn"; export type ThemePreviewVars = Record; /** * Buzz sidebar-gradient stop tokens, keyed by theme name. The actual custom * colors live once in `shared/styles/globals/theme.css`; the picker consumes * those same semantic variables instead of duplicating raw values here. */ export const BUZZ_GRADIENT_STOPS: Record< string, { top: string; bottom: string } > = { buzz: { top: "var(--buzz-gradient-light-top)", bottom: "var(--buzz-gradient-light-bottom)", }, "buzz-dark": { top: "var(--buzz-gradient-dark-top)", bottom: "var(--buzz-gradient-dark-bottom)", }, }; export const LIGHT_PREVIEW_VARS: ThemePreviewVars = { "--background": "0 0% 100%", "--border": "0 0% 89.8%", "--foreground": "0 0% 9%", "--muted": "0 0% 96.1%", "--muted-foreground": "0 0% 45.1%", "--primary": "0 0% 9%", "--sidebar-background": "0 0% 98%", "--sidebar-foreground": "0 0% 9%", }; export const DARK_PREVIEW_VARS: ThemePreviewVars = { "--background": "0 0% 3.9%", "--border": "0 0% 14.9%", "--foreground": "0 0% 98%", "--muted": "0 0% 14.9%", "--muted-foreground": "0 0% 63.9%", "--primary": "0 0% 98%", "--sidebar-background": "0 0% 0%", "--sidebar-foreground": "0 0% 98%", }; function hsl(vars: ThemePreviewVars | null, key: string) { return `hsl(${vars?.[key] ?? LIGHT_PREVIEW_VARS[key]})`; } function hslAlpha(vars: ThemePreviewVars | null, key: string, alpha: number) { return `hsl(${vars?.[key] ?? LIGHT_PREVIEW_VARS[key]} / ${alpha})`; } function ThemePreviewSvg({ vars, sidebarGradient, }: { vars: ThemePreviewVars | null; sidebarGradient?: { top: string; bottom: string }; }) { const clipId = React.useId().replace(/:/g, ""); const gradientId = `${clipId}-buzz`; const background = hsl(vars, "--background"); const border = hsl(vars, "--border"); const foreground = hsl(vars, "--foreground"); const mutedForeground = hsl(vars, "--muted-foreground"); const primary = hsl(vars, "--primary"); const primarySoft = hslAlpha(vars, "--primary", 0.68); const sidebar = hsl(vars, "--sidebar-background"); const sidebarForeground = hslAlpha(vars, "--sidebar-foreground", 0.58); return ( ); } /** * Split preview SVG: light theme on top, dark theme on bottom. * Matches the "System Preference" visual — one image showing both modes. */ function SystemPreferencePreviewSvg({ darkVars, lightVars, lightGradient, darkGradient, }: { darkVars: ThemePreviewVars | null; lightVars: ThemePreviewVars | null; lightGradient?: { top: string; bottom: string }; darkGradient?: { top: string; bottom: string }; }) { const clipBase = React.useId().replace(/:/g, ""); const clipDark = `${clipBase}-dark`; const clipLight = `${clipBase}-light`; const clipOuter = `${clipBase}-outer`; const lightGradientId = `${clipBase}-buzz-light`; const darkGradientId = `${clipBase}-buzz-dark`; // Dark half colors const darkBg = hsl(darkVars, "--background"); const darkSidebar = hsl(darkVars, "--sidebar-background"); const darkSidebarFg = hslAlpha(darkVars, "--sidebar-foreground", 0.58); const darkMutedFg = hsl(darkVars, "--muted-foreground"); // Light half colors const lightBg = hsl(lightVars, "--background"); const lightBorder = hsl(lightVars, "--border"); const lightForeground = hsl(lightVars, "--foreground"); const lightPrimary = hsl(lightVars, "--primary"); const lightPrimarySoft = hslAlpha(lightVars, "--primary", 0.68); const lightSidebar = hsl(lightVars, "--sidebar-background"); const lightSidebarFg = hslAlpha(lightVars, "--sidebar-foreground", 0.58); const lightMutedFg = hsl(lightVars, "--muted-foreground"); return ( ); } export function ThemePreviewFrame({ className, vars, sidebarGradient, }: { className?: string; vars: ThemePreviewVars | null; sidebarGradient?: { top: string; bottom: string }; }) { return (
); } /** * System preference preview frame: shows light on top, dark on bottom * in a single image to represent auto-switching themes. */ export function SystemPreferencePreviewFrame({ className, darkVars, lightVars, lightGradient, darkGradient, }: { className?: string; darkVars: ThemePreviewVars | null; lightVars: ThemePreviewVars | null; lightGradient?: { top: string; bottom: string }; darkGradient?: { top: string; bottom: string }; }) { return (
); }