"use client"; import { Check, Expand } from "@openstatus/icons"; import { THEMES, THEME_KEYS, type ThemeKey } from "@openstatus/theme-store"; import { Button } from "@openstatus/ui/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@openstatus/ui/components/ui/command"; import { FormControl } from "@openstatus/ui/components/ui/form"; import { Popover, PopoverContent, PopoverTrigger, } from "@openstatus/ui/components/ui/popover"; import { cn } from "@openstatus/ui/lib/utils"; import { useTheme } from "next-themes"; import { useEffect, useState } from "react"; import { Link } from "@/components/common/link"; // Color swatches shown next to each theme option. Mirrors the playground // convention at `apps/status-page/.../public/client.tsx`. const SWATCH_VARS = [ "--primary", "--success", "--warning", "--destructive", "--info", ] as const; export function ThemeSwatches({ themeKey }: { themeKey: ThemeKey }) { const { resolvedTheme } = useTheme(); // next-themes resolves `system` only on the client, so SSR has no // resolvedTheme. Render the light palette until mount to keep the // server HTML and the first client render in agreement, then settle to // the resolved mode. const [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); const theme = THEMES[themeKey] ?? THEMES.default; const palette = mounted && resolvedTheme === "dark" ? theme.dark : theme.light; return (