{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-29",
  "title": "Volume stepper",
  "description": "Minus and plus buttons around a level whose digit and speaker icon follow each step.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/button/button-29.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 { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  MinusIcon,\n  PlusIcon,\n  Volume1Icon,\n  Volume2Icon,\n  VolumeIcon,\n  VolumeXIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nconst MIN_VOLUME = 0;\nconst MAX_VOLUME = 6;\nconst INITIAL_VOLUME = 3;\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 volumeGlyphOf(volume: number) {\n  if (volume === MIN_VOLUME) {\n    return { key: 'muted', icon: <VolumeXIcon className='opacity-60' /> };\n  }\n  if (volume < 3) {\n    return { key: 'low', icon: <VolumeIcon className='opacity-60' /> };\n  }\n  if (volume < 5) {\n    return { key: 'medium', icon: <Volume1Icon className='opacity-60' /> };\n  }\n  return { key: 'high', icon: <Volume2Icon className='opacity-60' /> };\n}\n\nexport default function Button29() {\n  const labelId = useId();\n  const [volume, setVolume] = useState(INITIAL_VOLUME);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const iconVariants = iconVariantsOf(shouldReduceMotion);\n  const glyph = volumeGlyphOf(volume);\n  const isMuted = volume === MIN_VOLUME;\n  const isAtMax = volume === MAX_VOLUME;\n\n  function decreaseVolume() {\n    setVolume((current) => {\n      const lower = current - 1;\n      return Math.max(MIN_VOLUME, lower);\n    });\n  }\n\n  function increaseVolume() {\n    setVolume((current) => {\n      const higher = current + 1;\n      return Math.min(MAX_VOLUME, higher);\n    });\n  }\n\n  return (\n    <div\n      className='inline-flex items-center'\n      role='group'\n      aria-labelledby={labelId}\n    >\n      <span id={labelId} className='sr-only'>\n        Volume control\n      </span>\n      <Button\n        variant='outline'\n        size='icon'\n        aria-label='Decrease volume'\n        onClick={decreaseVolume}\n        disabled={isMuted}\n        focusableWhenDisabled\n      >\n        <MinusIcon />\n      </Button>\n      <div\n        className='flex items-center gap-2 px-3 text-[13px] font-medium tabular-nums'\n        aria-live='polite'\n      >\n        <span className='relative flex'>\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        </span>\n        <span className='flex' aria-hidden='true'>\n          <MotionNumber value={volume} />\n        </span>\n        <span className='sr-only'>Current volume is {volume}</span>\n      </div>\n      <Button\n        variant='outline'\n        size='icon'\n        aria-label='Increase volume'\n        onClick={increaseVolume}\n        disabled={isAtMax}\n        focusableWhenDisabled\n      >\n        <PlusIcon />\n      </Button>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "button"
  ],
  "type": "registry:component"
}