{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-49",
  "title": "Show more button",
  "description": "Switches between show more and show less, and turns its chevron.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.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/button/button-49.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 { ChevronDownIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst LABEL_VARIANTS: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction labelVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return LABEL_VARIANTS;\n}\n\nfunction toggleLabelOf(isExpanded: boolean) {\n  if (isExpanded) {\n    return 'Show less';\n  }\n  return 'Show more';\n}\n\nexport default function Button49() {\n  const [isExpanded, setIsExpanded] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const labelVariants = labelVariantsOf(shouldReduceMotion);\n  const label = toggleLabelOf(isExpanded);\n\n  function toggleExpanded() {\n    setIsExpanded((current) => !current);\n  }\n\n  return (\n    <Button\n      variant='ghost'\n      className='gap-1'\n      onClick={toggleExpanded}\n      aria-expanded={isExpanded}\n    >\n      <AnimatedSize axis='width' as='span' contentClassName='relative flex'>\n        <AnimatePresence mode='popLayout' initial={false}>\n          <motion.span\n            key={label}\n            className='flex'\n            variants={labelVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={SWAP_TRANSITION}\n          >\n            {label}\n          </motion.span>\n        </AnimatePresence>\n      </AnimatedSize>\n      <ChevronDownIcon className='-me-1 transition-[rotate] duration-200 ease-(--ease-out-strong) group-aria-expanded/button:rotate-180' />\n    </Button>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "button"
  ],
  "type": "registry:component"
}