{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dropdown-15",
  "title": "Theme menu",
  "description": "Picks a theme and swaps the icon of its trigger.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/dropdown/dropdown-15.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  MonitorIcon,\n  MoonIcon,\n  SunIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\n\ntype Theme = 'light' | 'dark' | 'system';\n\ntype ThemeOption = {\n  value: Theme;\n  label: string;\n  icon: Icon;\n};\n\nconst THEME_OPTIONS: ThemeOption[] = [\n  { value: 'light', label: 'Light', icon: SunIcon },\n  { value: 'dark', label: 'Dark', icon: MoonIcon },\n  { value: 'system', label: 'System', icon: MonitorIcon },\n];\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst ICON_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction iconVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return ICON_VARIANTS;\n}\n\nfunction themeOptionOf(theme: Theme) {\n  const option = THEME_OPTIONS.find((candidate) => candidate.value === theme);\n  if (option) {\n    return option;\n  }\n  return THEME_OPTIONS[0];\n}\n\nexport default function Dropdown15() {\n  const [theme, setTheme] = useState<Theme>('system');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const iconVariants = iconVariantsOf(shouldReduceMotion);\n  const selectedOption = themeOptionOf(theme);\n\n  function selectTheme(nextTheme: Theme) {\n    setTheme(nextTheme);\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        render={\n          <Button\n            variant='outline'\n            size='icon'\n            aria-label={`Change theme, currently ${selectedOption.label}`}\n          />\n        }\n      >\n        <AnimatePresence mode='popLayout' initial={false}>\n          <motion.span\n            key={selectedOption.value}\n            className='flex'\n            variants={iconVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={SWAP_TRANSITION}\n          >\n            <selectedOption.icon />\n          </motion.span>\n        </AnimatePresence>\n      </DropdownMenuTrigger>\n      <DropdownMenuContent className='min-w-36'>\n        <DropdownMenuRadioGroup value={theme} onValueChange={selectTheme}>\n          {THEME_OPTIONS.map((option) => (\n            <DropdownMenuRadioItem\n              key={option.value}\n              value={option.value}\n              closeOnClick\n            >\n              <option.icon />\n              {option.label}\n            </DropdownMenuRadioItem>\n          ))}\n        </DropdownMenuRadioGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "dropdown"
  ],
  "type": "registry:component"
}