{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "theme-selector",
  "title": "Theme selector",
  "description": "A dropdown picker for the five Quill themes and four pigment accents — sets data-theme/data-accent and persists both to localStorage.",
  "registryDependencies": [
    "button",
    "dropdown-menu",
    "https://www.quilldesignsystem.com/r/icon.json"
  ],
  "files": [
    {
      "path": "registry/blocks/theme-selector.tsx",
      "content": "'use client'\nimport { useEffect, useState } from 'react'\nimport { Button } from '@/components/ui/button'\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuLabel,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu'\nimport { Icon } from '@/components/ui/icon'\n\nexport const quillThemes = [\n  { value: 'light', label: 'Dawn', icon: 'light_mode' },\n  { value: 'dark', label: 'Dusk', icon: 'dark_mode' },\n  { value: 'classic-light', label: 'Classic Light', icon: 'radio_button_unchecked' },\n  { value: 'classic-dark', label: 'Classic Dark', icon: 'disk' },\n  // star_shine is Material's sparkle (the glyph older releases called\n  // auto_awesome) — the AI cue for the cockpit theme. Pulled into the sync\n  // core map automatically: coreNames() in build-icons.mjs greps `icon: '…'`\n  // across src AND registry, so a block's icons always ship to consumers.\n  { value: 'intelligent', label: 'Intelligent', icon: 'star_shine' },\n] as const\n\n// Swatch classes are static strings so Tailwind can see them.\nexport const quillAccents = [\n  { value: 'moss', label: 'Moss', swatch: 'bg-moss' },\n  { value: 'terracotta', label: 'Terracotta', swatch: 'bg-terracotta' },\n  { value: 'indigo', label: 'Indigo', swatch: 'bg-indigo' },\n  { value: 'gold', label: 'Gold', swatch: 'bg-gold' },\n] as const\n\nexport type ThemeValue = (typeof quillThemes)[number]['value']\nexport type AccentValue = (typeof quillAccents)[number]['value']\n\nconst isTheme = (v: unknown): v is ThemeValue =>\n  quillThemes.some((t) => t.value === v)\nconst isAccent = (v: unknown): v is AccentValue =>\n  quillAccents.some((a) => a.value === v)\n\n// Filled disk for Classic Dark — the Quill icon set is outlined-only, so the\n// filled Material Symbols `circle` ships inline (weight 500, to match the ring).\nfunction DiskGlyph({ size = 16 }: { size?: number }) {\n  return (\n    <svg viewBox=\"0 -960 960 960\" width={size} height={size} fill=\"currentColor\" aria-hidden>\n      <path d=\"M480.03-74.02q-83.46 0-157.54-31.88-74.07-31.88-129.39-87.2-55.32-55.32-87.2-129.36-31.88-74.04-31.88-157.51 0-84.46 31.88-158.54 31.88-74.07 87.16-128.9 55.28-54.84 129.34-86.82 74.06-31.99 157.55-31.99 84.48 0 158.59 31.97 74.1 31.97 128.91 86.77 54.82 54.8 86.79 128.88 31.98 74.08 31.98 158.6 0 83.5-31.99 157.57-31.98 74.07-86.82 129.36-54.83 55.29-128.87 87.17-74.04 31.88-158.51 31.88Z\" />\n    </svg>\n  )\n}\n\nfunction ThemeGlyph({ icon, size = 16 }: { icon: (typeof quillThemes)[number]['icon']; size?: number }) {\n  if (icon === 'disk') return <DiskGlyph size={size} />\n  return <Icon name={icon} size={size} />\n}\n\n/** A dropdown picker for the five Quill themes and four pigment accents — sets data-theme/data-accent and persists both to localStorage. */\nexport function ThemeSelector({\n  value,\n  onValueChange,\n  accent,\n  onAccentChange,\n  storageKey = 'quill-theme',\n  accentStorageKey = 'quill-accent',\n}: {\n  /** Controlled theme. Omit to let the selector own `data-theme` on <html>. */\n  value?: ThemeValue\n  onValueChange?: (theme: ThemeValue) => void\n  /** Controlled accent. Omit to let the selector own `data-accent` on <html>. */\n  accent?: AccentValue\n  onAccentChange?: (accent: AccentValue) => void\n  /** localStorage keys used in uncontrolled mode. */\n  storageKey?: string\n  accentStorageKey?: string\n}) {\n  const [internalTheme, setInternalTheme] = useState<ThemeValue>('light')\n  const [internalAccent, setInternalAccent] = useState<AccentValue>('moss')\n  const themeControlled = value !== undefined\n  const accentControlled = accent !== undefined\n  const theme = themeControlled ? value : internalTheme\n  const activeAccent = accentControlled ? accent : internalAccent\n  const active = quillThemes.find((t) => t.value === theme) ?? quillThemes[0]\n\n  useEffect(() => {\n    // Read post-hydration: prerendered markup is always Dawn/moss, so\n    // reading storage during render would mismatch.\n    let storedTheme: string | null = null\n    let storedAccent: string | null = null\n    try {\n      storedTheme = localStorage.getItem(storageKey)\n      storedAccent = localStorage.getItem(accentStorageKey)\n    } catch {}\n    if (!themeControlled && isTheme(storedTheme)) {\n      document.documentElement.setAttribute('data-theme', storedTheme)\n      // eslint-disable-next-line react-hooks/set-state-in-effect\n      setInternalTheme(storedTheme)\n    }\n    if (!accentControlled && isAccent(storedAccent)) {\n      document.documentElement.setAttribute('data-accent', storedAccent)\n      setInternalAccent(storedAccent)\n    }\n  }, [themeControlled, accentControlled, storageKey, accentStorageKey])\n\n  function selectTheme(next: ThemeValue) {\n    if (!themeControlled) {\n      setInternalTheme(next)\n      document.documentElement.setAttribute('data-theme', next)\n      try {\n        localStorage.setItem(storageKey, next)\n      } catch {}\n    }\n    onValueChange?.(next)\n  }\n\n  function selectAccent(next: AccentValue) {\n    if (!accentControlled) {\n      setInternalAccent(next)\n      document.documentElement.setAttribute('data-accent', next)\n      try {\n        localStorage.setItem(accentStorageKey, next)\n      } catch {}\n    }\n    onAccentChange?.(next)\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        render={\n          <Button variant=\"outline\" size=\"sm\" aria-label={`Theme: ${active.label}`}>\n            <ThemeGlyph icon={active.icon} />\n            <span className=\"max-sm:hidden\">{active.label}</span>\n            <Icon name=\"keyboard_arrow_down\" className=\"text-muted-foreground\" />\n          </Button>\n        }\n      />\n      <DropdownMenuContent align=\"end\" className=\"w-menu\">\n        {/* Base UI: GroupLabel must live INSIDE a Group/RadioGroup. */}\n        <DropdownMenuRadioGroup\n          value={theme}\n          onValueChange={(next) => {\n            if (isTheme(next)) selectTheme(next)\n          }}\n        >\n          <DropdownMenuLabel>Theme</DropdownMenuLabel>\n          {quillThemes.map((t) => (\n            <DropdownMenuRadioItem key={t.value} value={t.value}>\n              <ThemeGlyph icon={t.icon} />\n              {t.label}\n            </DropdownMenuRadioItem>\n          ))}\n        </DropdownMenuRadioGroup>\n        <DropdownMenuSeparator />\n        <DropdownMenuRadioGroup\n          value={activeAccent}\n          onValueChange={(next) => {\n            if (isAccent(next)) selectAccent(next)\n          }}\n        >\n          <DropdownMenuLabel>Accent</DropdownMenuLabel>\n          {quillAccents.map((a) => (\n            <DropdownMenuRadioItem key={a.value} value={a.value}>\n              <span className={`size-3.5 shrink-0 rounded-full border border-border ${a.swatch}`} aria-hidden />\n              {a.label}\n            </DropdownMenuRadioItem>\n          ))}\n        </DropdownMenuRadioGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/quill/theme-selector.tsx"
    }
  ],
  "meta": {
    "intent": [
      "settings"
    ],
    "use_when": "You need to let users switch among Quill's five themes and four accents, persisted to localStorage.",
    "not_for": "theme choice is one field among many in a broader preferences form, not a standalone quick-switch control → settings"
  },
  "docs": "A dropdown picker for the five Quill themes and four pigment accents — sets data-theme/data-accent and persists both to localStorage. Do: Read the persisted theme/accent from localStorage in an effect, after mount — never during render, or prerendered markup mismatches the client. Don't: Read localStorage synchronously during render; that guarantees a hydration mismatch since the server always renders Dawn/moss. Do: Show a color swatch next to each accent option in the menu, as this picker does, so people see the actual hue before picking it. Don't: List accent names as plain text with no swatch, forcing a guess at what \"Terracotta\" or \"Indigo\" actually look like. Use settings when theme choice is one field among many in a broader preferences form, not a standalone quick-switch control.",
  "categories": [
    "settings"
  ],
  "type": "registry:block"
}