{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "testimonials-04",
  "title": "Quote stage",
  "description": "A large drawn portrait beside one big sample quote, switched with tabs, arrows and the progress row under the tabs: the row fills up to the person picked while their portrait and quote crossfade in, and an optional autoplay waits under the pointer and off screen.",
  "dependencies": [
    " },\n      { kind: ",
    "@base-ui/react",
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-04/index.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 { useAutoplay } from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  ChevronLeftIcon,\n  ChevronRightIcon,\n  QuoteIcon,\n  StoreIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { EASE_OUT_STRONG } from '@/registry/ndeko/lib/motion-presets';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { SECTION, STORIES } from './data';\nimport { PersonTabs, tabIdOf } from './person-tabs';\nimport { PortraitStack } from './portrait-stack';\nimport { StoryQuote } from './story-quote';\n\nconst STORY_MS = 6500;\n\nconst ENTER: Transition = { duration: 0.45, ease: EASE_OUT_STRONG };\n\nconst EXIT: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nconst QUOTE_VARIANTS: Variants = {\n  enter: { opacity: 0, y: 8, filter: 'blur(4px)' },\n  shown: { opacity: 1, y: 0, filter: 'blur(0px)', transition: ENTER },\n  gone: { opacity: 0, y: -6, filter: 'blur(4px)', transition: EXIT },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  shown: { opacity: 1, transition: ENTER },\n  gone: { opacity: 0, transition: EXIT },\n};\n\nfunction variantsOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return QUOTE_VARIANTS;\n}\n\nfunction indexAfter(index: number) {\n  const next = index + 1;\n  return next % STORIES.length;\n}\n\nfunction indexBefore(index: number) {\n  const shifted = index + STORIES.length;\n  const previous = shifted - 1;\n  return previous % STORIES.length;\n}\n\n/** The next person of every story, so a round ends on the first story and the loop shows no seam. */\nconst ROTATION = STORIES.map((_, index) => indexAfter(index));\n\nfunction spokenStoryOf(index: number) {\n  const { person } = STORIES[index];\n  return `${person.name}, ${person.role} at ${person.company}`;\n}\n\ntype Testimonials04Props = {\n  /** Moves to the next story every few seconds until a person clicks, types or tabs into the block. */\n  autoplay?: boolean;\n};\n\nexport default function Testimonials04({\n  autoplay = true,\n}: Testimonials04Props) {\n  const [activeIndex, setActiveIndex] = useState(0);\n  const [isHovered, setIsHovered] = useState(false);\n  const [message, setMessage] = useState('');\n  const idBase = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const activeStory = STORIES[activeIndex];\n  const panelId = `${idBase}-panel`;\n  const activeTabId = tabIdOf(idBase, activeStory.id);\n  const variants = variantsOf(shouldReduceMotion);\n  const isFree = !isHovered;\n  const isRotationEnabled = autoplay && isFree;\n\n  const steps = ROTATION.map((index) => ({\n    after: STORY_MS,\n    run: () => setActiveIndex(index),\n  }));\n  const { ref } = useAutoplay<HTMLElement>(steps, {\n    loopAfter: 0,\n    isEnabled: isRotationEnabled,\n  });\n\n  function showByPerson(index: number) {\n    setActiveIndex(index);\n    setMessage(spokenStoryOf(index));\n  }\n\n  function pick(storyId: string) {\n    const index = STORIES.findIndex((story) => story.id === storyId);\n    showByPerson(index);\n  }\n\n  function showPrevious() {\n    showByPerson(indexBefore(activeIndex));\n  }\n\n  function showNext() {\n    showByPerson(indexAfter(activeIndex));\n  }\n\n  function holdUnderPointer(event: React.PointerEvent<HTMLElement>) {\n    if (event.pointerType === 'mouse') {\n      setIsHovered(true);\n    }\n  }\n\n  function releasePointer() {\n    setIsHovered(false);\n  }\n\n  return (\n    <section\n      ref={ref}\n      onPointerEnter={holdUnderPointer}\n      onPointerLeave={releasePointer}\n      className='@container'\n    >\n      <div className='mx-auto flex max-w-6xl flex-col gap-10 px-4 py-16 @2xl:px-6 @2xl:py-24 @5xl:px-8'>\n        <header className='flex max-w-2xl flex-col gap-3'>\n          <p className='text-primary-ink flex items-center gap-1.5 text-[13px] font-medium'>\n            <StoreIcon className='size-4' />\n            {SECTION.label}\n          </p>\n          <h2 className='text-2xl font-semibold text-balance @2xl:text-3xl'>\n            {SECTION.title}\n          </h2>\n          <p className='text-muted-foreground text-base text-pretty'>\n            {SECTION.lead}\n          </p>\n        </header>\n        <div className='grid gap-6 @3xl:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] @3xl:gap-12'>\n          <PortraitStack stories={STORIES} activeId={activeStory.id} />\n          <div className='flex min-w-0 flex-col gap-8 @3xl:justify-between @3xl:py-2'>\n            <div className='flex flex-col gap-5'>\n              <div className='flex items-center justify-between gap-3'>\n                <QuoteIcon className='text-primary-ink size-7' />\n                <Badge variant='secondary'>Sample quotes</Badge>\n              </div>\n              <div\n                id={panelId}\n                role='tabpanel'\n                aria-labelledby={activeTabId}\n                className='grid *:col-start-1 *:row-start-1'\n              >\n                {STORIES.map((story) => (\n                  <div key={story.id} aria-hidden='true' className='invisible'>\n                    <StoryQuote story={story} />\n                  </div>\n                ))}\n                <AnimatePresence initial={false}>\n                  <motion.div\n                    key={activeStory.id}\n                    variants={variants}\n                    initial='enter'\n                    animate='shown'\n                    exit='gone'\n                  >\n                    <StoryQuote story={activeStory} />\n                  </motion.div>\n                </AnimatePresence>\n              </div>\n            </div>\n            <div className='flex items-end gap-3'>\n              <PersonTabs\n                stories={STORIES}\n                activeId={activeStory.id}\n                tabIdBase={idBase}\n                panelId={panelId}\n                onPick={pick}\n                className='min-w-0 flex-1'\n              />\n              <div className='flex shrink-0 items-center gap-1 pb-1'>\n                <Button\n                  type='button'\n                  variant='outline'\n                  size='icon-sm'\n                  aria-label='Show the previous story'\n                  onClick={showPrevious}\n                >\n                  <ChevronLeftIcon />\n                </Button>\n                <Button\n                  type='button'\n                  variant='outline'\n                  size='icon-sm'\n                  aria-label='Show the next story'\n                  onClick={showNext}\n                >\n                  <ChevronRightIcon />\n                </Button>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n      <LiveRegion message={message} />\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-04/portrait-stack.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\n\nimport type { Story } from './data';\n\nfunction layerToneOf(isActive: boolean) {\n  if (isActive) {\n    return 'opacity-100';\n  }\n  return 'opacity-0';\n}\n\ntype PortraitStackProps = {\n  stories: readonly Story[];\n  activeId: string;\n};\n\n/**\n * Every portrait is laid out at once and only the current one is opaque, so a change of person is\n * an opacity crossfade on the compositor and the frame never changes size.\n */\nexport function PortraitStack({ stories, activeId }: PortraitStackProps) {\n  return (\n    <div\n      aria-hidden='true'\n      className='relative aspect-[3/2] w-full @3xl:aspect-[4/5]'\n    >\n      {stories.map((story) => {\n        const isActive = story.id === activeId;\n        const { person } = story;\n\n        return (\n          <div\n            key={story.id}\n            className={cn(\n              'absolute inset-0 transition-opacity duration-500 ease-(--ease-out-strong)',\n              layerToneOf(isActive)\n            )}\n          >\n            <Avatar seed={person.name} className='size-full rounded-2xl' />\n            <span className='bg-card/90 hairline-ring ring-border dark:bg-popover/90 absolute start-3 bottom-3 flex max-w-[calc(100%-1.5rem)] items-center gap-2 rounded-lg py-1.5 ps-1.5 pe-2.5 text-xs font-medium shadow-[0_1px_2px_rgb(0_0_0/0.06)]'>\n              <CompanyMark seed={person.company} />\n              <span className='truncate'>{person.company}</span>\n            </span>\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-04/portrait-stack.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-04/person-tabs.tsx",
      "content": "'use client';\n\nimport { Tabs as TabsPrimitive } from '@base-ui/react/tabs';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport type { Story } from './data';\n\nexport function tabIdOf(base: string, storyId: string) {\n  return `${base}-tab-${storyId}`;\n}\n\ntype Progress = 'past' | 'current' | 'ahead';\n\nfunction progressOf(index: number, activeIndex: number): Progress {\n  if (index === activeIndex) {\n    return 'current';\n  }\n  if (index < activeIndex) {\n    return 'past';\n  }\n  return 'ahead';\n}\n\nconst FILL_CLASS: Record<Progress, string> = {\n  past: 'scale-x-100 bg-foreground/30',\n  current: 'scale-x-100 bg-primary',\n  ahead: 'scale-x-0 bg-foreground/30',\n};\n\nfunction isStoryId(value: unknown, stories: readonly Story[]) {\n  return stories.some((story) => story.id === value);\n}\n\ntype PersonTabsProps = {\n  stories: readonly Story[];\n  activeId: string;\n  tabIdBase: string;\n  panelId: string;\n  onPick: (storyId: string) => void;\n  className?: string;\n};\n\nexport function PersonTabs({\n  stories,\n  activeId,\n  tabIdBase,\n  panelId,\n  onPick,\n  className,\n}: PersonTabsProps) {\n  const activeIndex = stories.findIndex((story) => story.id === activeId);\n\n  function pickTab(value: unknown) {\n    if (isStoryId(value, stories)) {\n      onPick(String(value));\n    }\n  }\n\n  return (\n    <TabsPrimitive.Root\n      value={activeId}\n      onValueChange={pickTab}\n      className={className}\n    >\n      <TabsPrimitive.List\n        activateOnFocus\n        aria-label='Choose a customer'\n        className='grid grid-cols-4 gap-2'\n      >\n        {stories.map((story, index) => {\n          const { person } = story;\n          const progress = progressOf(index, activeIndex);\n\n          return (\n            <TabsPrimitive.Tab\n              key={story.id}\n              value={story.id}\n              id={tabIdOf(tabIdBase, story.id)}\n              aria-controls={panelId}\n              aria-label={`${person.name}, ${person.company}`}\n              className='group/tab focus-visible:ring-ring/25 flex min-w-0 cursor-pointer flex-col gap-2.5 rounded-lg px-1 pt-1 pb-0.5 text-start outline-none focus-visible:ring-[3px]'\n            >\n              <span className='flex min-w-0 items-center gap-2'>\n                <Avatar seed={person.name} className='size-6' />\n                <span className='text-muted-foreground group-hover/tab:text-foreground group-data-active/tab:text-foreground hidden truncate text-[13px] font-medium transition-colors duration-150 @xl:block'>\n                  {person.name}\n                </span>\n              </span>\n              <span className='bg-foreground/10 relative h-0.5 overflow-hidden rounded-full'>\n                <span\n                  className={cn(\n                    'absolute inset-0 origin-left rounded-full transition-[scale,background-color] duration-300 ease-(--ease-out-strong)',\n                    FILL_CLASS[progress]\n                  )}\n                />\n              </span>\n            </TabsPrimitive.Tab>\n          );\n        })}\n      </TabsPrimitive.List>\n    </TabsPrimitive.Root>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-04/person-tabs.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-04/story-quote.tsx",
      "content": "import { BrandTile } from '@/registry/ndeko/ui/brand-tile';\n\nimport type { QuotePart, Story } from './data';\n\nfunction QuotePartView({ part }: { part: QuotePart }) {\n  if (part.kind === 'brand') {\n    return (\n      <span className='whitespace-nowrap'>\n        <BrandTile\n          brand={part.brand}\n          size='md'\n          className='me-1.5 align-[-0.15em]'\n        />\n        {part.text}\n      </span>\n    );\n  }\n  return part.text;\n}\n\nexport function StoryQuote({ story }: { story: Story }) {\n  const { person } = story;\n\n  return (\n    <figure className='flex flex-col gap-6'>\n      <blockquote className='text-xl leading-snug font-medium text-pretty @4xl:text-[1.75rem] @4xl:leading-[1.3]'>\n        <p>\n          {story.parts.map((part, index) => (\n            <QuotePartView key={index} part={part} />\n          ))}\n        </p>\n      </blockquote>\n      <figcaption className='flex flex-col gap-0.5'>\n        <span className='text-sm font-medium'>{person.name}</span>\n        <span className='text-muted-foreground text-[13px]'>\n          {person.role}, {person.company}\n        </span>\n      </figcaption>\n    </figure>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-04/story-quote.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-04/data.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type QuotePart =\n  | { kind: 'text'; text: string }\n  | { kind: 'brand'; brand: BrandSlug; text: string };\n\nexport type Person = {\n  name: string;\n  role: string;\n  company: string;\n};\n\nexport type Story = {\n  id: string;\n  parts: QuotePart[];\n  person: Person;\n};\n\nexport const SECTION = {\n  label: 'Customer stories',\n  title: 'Shops that stopped reordering by feel',\n  lead: 'Stowly reads what sold and what is on the way, and tells you what will run out before it does.',\n};\n\n/** Invented people and companies. The quotes are samples written for this block. */\nexport const STORIES: Story[] = [\n  {\n    id: 'grace',\n    parts: [\n      {\n        kind: 'text',\n        text: 'We used to reorder on Sunday nights, by feel. Now Stowly tells us on Thursday what will run out next week, and it has been right often enough that we stopped checking twice.',\n      },\n    ],\n    person: {\n      name: 'Grace Mwangi',\n      role: 'Operations lead',\n      company: 'Pallet & Pine',\n    },\n  },\n  {\n    id: 'lukas',\n    parts: [\n      { kind: 'text', text: 'It reads our sales from ' },\n      { kind: 'brand', brand: 'shopify', text: 'Shopify' },\n      {\n        kind: 'text',\n        text: ' and the lead times of every supplier in one place. The reorder list is ready before I open the shop.',\n      },\n    ],\n    person: {\n      name: 'Lukas Brenner',\n      role: 'Founder',\n      company: 'Brenner Bikes',\n    },\n  },\n  {\n    id: 'nadia',\n    parts: [\n      {\n        kind: 'text',\n        text: 'The forecast explains itself. When it asks for twice the usual olive oil, it shows me the festival weekend it found in last year’s sales.',\n      },\n    ],\n    person: {\n      name: 'Nadia Haddad',\n      role: 'Buyer',\n      company: 'Cedar & Salt',\n    },\n  },\n  {\n    id: 'owen',\n    parts: [\n      { kind: 'text', text: 'Purchase orders go straight to ' },\n      { kind: 'brand', brand: 'quickbooks', text: 'QuickBooks' },\n      {\n        kind: 'text',\n        text: ', so closing the month is one check instead of an afternoon of matching receipts.',\n      },\n    ],\n    person: {\n      name: 'Owen Prescott',\n      role: 'Finance manager',\n      company: 'Northline Pharmacy',\n    },\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "testimonials"
  ],
  "type": "registry:block"
}