{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "testimonials",
  "title": "Testimonials",
  "description": "Customers’ quotes on cards in packed columns, each with who said it and a link to where, folded to a set height with Show all.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/controllable.json",
    "https://kinoui.com/r/fold.json",
    "https://kinoui.com/r/section-heading.json",
    "https://kinoui.com/r/testimonial-parts.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/testimonials/testimonials.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport { useControllable } from '@/registry/lib/controllable'\nimport { bringTopBack, useFoldMove } from '@/registry/lib/fold'\nimport { SectionHeading } from '@/registry/lib/section-heading'\nimport {\n  TestimonialCard,\n  testimonialsColumnClassName,\n  type TestimonialsSectionProps,\n  testimonialsSectionClassName,\n} from '@/registry/lib/testimonial-parts'\nimport { type FocusEvent, useId, useLayoutEffect, useRef, useState } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * Every quote in view at once, on cards in columns that read down, so long\n * and short quotes pack together. A wall much taller than its set height\n * folds to it, with its foot fading out, and Show all unfolds it on\n * `layout`, as the Code block's lines do. Nothing else moves.\n *\n *   <Testimonials\n *     title='Teams plan their week in Kino'\n *     testimonials={[{ value: 'mei', quote: '…', name: 'Mei Lin', role: 'Head of Product', company: 'Tessel' }]}\n *   />\n */\n\ninterface TestimonialsProps extends TestimonialsSectionProps {\n  /** Whether a wall taller than its set height shows every quote. */\n  expanded?: boolean\n  defaultExpanded?: boolean\n  onExpandedChange?: (expanded: boolean) => void\n}\n\nfunction Testimonials({\n  title,\n  description,\n  eyebrow,\n  heading = 'h2',\n  testimonials,\n  expanded: expandedProp,\n  defaultExpanded = false,\n  onExpandedChange,\n  className,\n  ...props\n}: TestimonialsProps) {\n  const titleId = useId()\n  const wallId = useId()\n  const rootRef = useRef<HTMLElement>(null)\n  const frameRef = useRef<HTMLDivElement>(null)\n  const fadeRef = useRef<HTMLDivElement>(null)\n  const [expanded, setExpanded] = useControllable(\n    expandedProp,\n    defaultExpanded,\n    onExpandedChange,\n  )\n  // Until it is measured, a wall is taken to be worth folding, as most are.\n  const [foldable, setFoldable] = useState(true)\n  const folded = foldable && !expanded\n  useFoldMove(frameRef, folded)\n\n  // A wall that runs past its set height by less than its fade isn't worth folding: showing it costs less than a click.\n  useLayoutEffect(() => {\n    const frame = frameRef.current\n    const fade = fadeRef.current\n    const inner = frame?.firstElementChild\n    if (!frame || !fade || !(inner instanceof HTMLElement)) return\n    // The cap is read while it holds; the wall keeps the last one it read.\n    let cap = 0\n    const measure = () => {\n      const max = getComputedStyle(frame).maxHeight\n      if (max.endsWith('px')) cap = Number.parseFloat(max)\n      if (cap > 0) setFoldable(inner.offsetHeight > cap + fade.offsetHeight)\n    }\n    measure()\n    const observer = new ResizeObserver(measure)\n    observer.observe(inner)\n    return () => observer.disconnect()\n  }, [])\n\n  const toggle = (next: boolean) => {\n    const root = rootRef.current\n    if (!next && root) bringTopBack(root)\n    setExpanded(next)\n  }\n\n  // A card that takes focus behind the fade unfolds the wall, so it is never hidden.\n  const onFocus = (event: FocusEvent<HTMLDivElement>) => {\n    const fade = fadeRef.current\n    if (!folded || !fade) return\n    // The card's box, which its ring is drawn around, not the link inside it.\n    const card = event.target.closest('[data-slot=testimonial-card]') ?? event.target\n    if (card.getBoundingClientRect().bottom > fade.getBoundingClientRect().top) {\n      toggle(true)\n    }\n  }\n\n  return (\n    <section\n      ref={rootRef}\n      data-slot='testimonials'\n      aria-labelledby={titleId}\n      className={cn(testimonialsSectionClassName, className)}\n      {...props}\n    >\n      <div className={cn(testimonialsColumnClassName, 'flex flex-col gap-12')}>\n        <SectionHeading\n          id={titleId}\n          eyebrow={eyebrow}\n          title={title}\n          description={description}\n          heading={heading}\n        />\n        <div className='flex min-w-0 flex-col items-center gap-6'>\n          {/* Capped while folded and not moving. Clipped down the page only, with room above for a card's focus ring. */}\n          <div\n            ref={frameRef}\n            id={wallId}\n            data-fold={folded ? '' : undefined}\n            onFocus={onFocus}\n            className='relative -mt-1 w-full min-w-0 overflow-y-clip pt-1 transition-[height] duration-(--motion-layout-duration) ease-(--motion-layout-easing) data-fold:not-data-moving:max-h-(--testimonials-height,40rem) motion-reduce:transition-none'\n          >\n            <div className='columns-1 gap-4 @2xl/testimonials:columns-2 @5xl/testimonials:columns-3 [&>*]:mb-4 [&>*]:break-inside-avoid'>\n              {testimonials.map((testimonial) => (\n                <TestimonialCard key={testimonial.value} testimonial={testimonial} />\n              ))}\n            </div>\n            {/* The foot of a folded wall fades into the page. */}\n            <div\n              ref={fadeRef}\n              aria-hidden\n              className={cn(\n                'from-background pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-t to-transparent transition-opacity duration-(--motion-exit-duration) ease-(--motion-exit-fade-easing)',\n                !folded && 'opacity-0',\n              )}\n            />\n          </div>\n          {foldable ? (\n            <Button\n              variant='outline'\n              aria-expanded={expanded}\n              aria-controls={wallId}\n              onClick={() => toggle(!expanded)}\n            >\n              {expanded ? 'Show fewer' : `Show all ${testimonials.length}`}\n            </Button>\n          ) : null}\n        </div>\n      </div>\n    </section>\n  )\n}\n\nexport { Testimonials, type TestimonialsProps }\n",
      "type": "registry:component",
      "target": "@components/kino/testimonials/testimonials.tsx"
    }
  ],
  "type": "registry:block"
}