{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch-10",
  "title": "Switch with icon",
  "description": "A dark mode switch whose icon swaps the sun for the moon.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/label.json",
    "https://ui.ndekocode.dev/r/switch.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/switch/switch-10.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { MoonIcon, SunIcon } from '@/registry/ndeko/lib/icons';\nimport { Label } from '@/registry/ndeko/ui/label';\nimport { Switch } from '@/registry/ndeko/ui/switch';\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 themeGlyphOf(isDark: boolean) {\n  if (isDark) {\n    return { key: 'dark', icon: <MoonIcon /> };\n  }\n  return { key: 'light', icon: <SunIcon /> };\n}\n\nexport default function Switch10() {\n  const id = useId();\n  const [isDark, setIsDark] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const iconVariants = iconVariantsOf(shouldReduceMotion);\n  const glyph = themeGlyphOf(isDark);\n\n  return (\n    <div className='inline-flex items-center gap-2'>\n      <Switch id={id} checked={isDark} onCheckedChange={setIsDark} />\n      <Label htmlFor={id} className='relative'>\n        <span className='sr-only'>Dark mode</span>\n        <AnimatePresence mode='popLayout' initial={false}>\n          <motion.span\n            key={glyph.key}\n            className='flex'\n            variants={iconVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={SWAP_TRANSITION}\n          >\n            {glyph.icon}\n          </motion.span>\n        </AnimatePresence>\n      </Label>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "switch"
  ],
  "type": "registry:component"
}