{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "testimonials-05",
  "title": "Quotes with results",
  "description": "One customer at a time on the featured card over a wall of short sample quotes with their result chips: pick a quote, or let the block turn every few seconds, and the quote writes itself in word by word while the illustrative figure beside it rolls to that customer’s result.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/streamed-text.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",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-05/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { useAutoplay } from '@/registry/ndeko/hooks/use-autoplay';\nimport { PRESS_LEAD_MS, usePress } from '@/registry/ndeko/lib/demonstration';\nimport { TrendingUpIcon } from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { CUSTOMERS, SECTION } from './data';\nimport { FeaturedResult } from './featured-result';\nimport { WallCard } from './wall-card';\n\n/** Long enough to read a featured quote once it has written itself in. */\nconst FEATURE_MS = 6200;\n\nfunction indexAfter(index: number) {\n  const next = index + 1;\n  return next % CUSTOMERS.length;\n}\n\n/** The next customer after each one, so a round ends on the first customer and the loop shows no seam. */\nconst ROTATION = CUSTOMERS.map((_, index) => indexAfter(index));\n\nfunction spokenFeatureOf(index: number) {\n  const { company, result } = CUSTOMERS[index];\n  return `Featured: ${company}, ${result.percent}% ${result.label}`;\n}\n\nexport default function Testimonials05() {\n  const [featuredIndex, setFeaturedIndex] = useState(0);\n  const [hasChanged, setHasChanged] = useState(false);\n  const [isReading, setIsReading] = useState(false);\n  const [message, setMessage] = useState('');\n  const { pressed, press } = usePress<string>();\n  const featured = CUSTOMERS[featuredIndex];\n\n  function feature(index: number) {\n    setFeaturedIndex(index);\n    setHasChanged(true);\n  }\n\n  const steps = ROTATION.flatMap((index) => [\n    { after: FEATURE_MS, run: () => press(CUSTOMERS[index].id) },\n    { after: PRESS_LEAD_MS, run: () => feature(index) },\n  ]);\n  const { ref } = useAutoplay<HTMLElement>(steps, {\n    loopAfter: 0,\n    isEnabled: !isReading,\n  });\n\n  function featureByPerson(customerId: string) {\n    const index = CUSTOMERS.findIndex((customer) => customer.id === customerId);\n    feature(index);\n    setMessage(spokenFeatureOf(index));\n  }\n\n  /** The featured quote does not change under the pointer of someone reading it. */\n  function holdWhileReading(event: React.PointerEvent<HTMLDivElement>) {\n    if (event.pointerType === 'mouse') {\n      setIsReading(true);\n    }\n  }\n\n  function stopReading() {\n    setIsReading(false);\n  }\n\n  return (\n    <section ref={ref} className='@container'>\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 flex-wrap items-end justify-between gap-x-6 gap-y-4'>\n          <div 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              <TrendingUpIcon 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          </div>\n          <div className='flex flex-wrap items-center gap-2'>\n            <Badge variant='secondary'>Sample quotes</Badge>\n            <Badge variant='secondary'>Illustrative figures</Badge>\n          </div>\n        </header>\n        <div className='flex flex-col gap-4'>\n          <div onPointerEnter={holdWhileReading} onPointerLeave={stopReading}>\n            <FeaturedResult\n              customer={featured}\n              position={featuredIndex}\n              isStreamed={hasChanged}\n            />\n          </div>\n          <ul className='grid gap-3 @xl:grid-cols-2 @4xl:grid-cols-3'>\n            {CUSTOMERS.map((customer, index) => (\n              <li key={customer.id}>\n                <WallCard\n                  customer={customer}\n                  isFeatured={index === featuredIndex}\n                  isPressed={pressed === customer.id}\n                  onFeature={featureByPerson}\n                />\n              </li>\n            ))}\n          </ul>\n        </div>\n      </div>\n      <LiveRegion message={message} />\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-05/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-05/featured-result.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { TrendingDownIcon, TrendingUpIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { StreamedInk } from '@/registry/ndeko/ui/streamed-text';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport { CUSTOMERS, type Customer } from './data';\n\nconst RESULT_LABELS = CUSTOMERS.map((customer) => customer.result.label);\n\nconst PERCENT_SUFFIX = '%';\n\nconst WORD_MS = 38;\n\nconst FADE_IN =\n  'transition-opacity duration-300 ease-(--ease-out-strong) starting:opacity-0';\n\n/** The quote a visitor reaches first is already written: only a quote that replaced another one arrives. */\nfunction arrivalOf(isStreamed: boolean) {\n  if (isStreamed) {\n    return FADE_IN;\n  }\n  return undefined;\n}\n\n/** Under reduced motion a new quote fades in whole instead of word by word. */\nfunction wholeQuoteFadeOf(isStreamed: boolean, shouldReduceMotion: boolean) {\n  if (!shouldReduceMotion) {\n    return undefined;\n  }\n  return arrivalOf(isStreamed);\n}\n\ntype FeaturedResultProps = {\n  customer: Customer;\n  /** The place of the customer in the list, so the label rolls in the direction of the change. */\n  position: number;\n  isStreamed: boolean;\n};\n\nexport function FeaturedResult({\n  customer,\n  position,\n  isStreamed,\n}: FeaturedResultProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const { person, result } = customer;\n  const isUp = result.trend === 'up';\n  const isWordByWord = isStreamed && !shouldReduceMotion;\n\n  return (\n    <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] relative isolate grid grid-cols-1 gap-8 rounded-2xl p-6 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @2xl:p-8 @3xl:grid-cols-[minmax(0,1fr)_17rem] @3xl:gap-12'>\n      <Wash />\n      <figure className='flex flex-col justify-between gap-8'>\n        <blockquote className='grid text-lg leading-8 font-medium text-pretty *:col-start-1 *:row-start-1 @3xl:text-xl @3xl:leading-8'>\n          {CUSTOMERS.map((candidate) => (\n            <p key={candidate.id} aria-hidden='true' className='invisible'>\n              {candidate.long}\n            </p>\n          ))}\n          <p\n            key={customer.id}\n            className={wholeQuoteFadeOf(isStreamed, shouldReduceMotion)}\n          >\n            <StreamedInk\n              text={customer.long}\n              isStreaming={isWordByWord}\n              wordMs={WORD_MS}\n            />\n          </p>\n        </blockquote>\n        <figcaption\n          key={customer.id}\n          className={cn('flex items-center gap-3', arrivalOf(isStreamed))}\n        >\n          <Avatar seed={person.name} className='size-10' />\n          <span className='flex min-w-0 flex-1 flex-col'>\n            <span className='truncate text-sm font-medium'>{person.name}</span>\n            <span className='text-muted-foreground truncate text-[13px]'>\n              {person.role}, {customer.company}\n            </span>\n          </span>\n          <CompanyMark seed={customer.company} size='lg' />\n        </figcaption>\n      </figure>\n      <div className='bg-foreground/[0.04] flex flex-col justify-between gap-6 rounded-xl p-5'>\n        <span className='text-muted-foreground text-xs'>\n          The number that moved\n        </span>\n        <div className='flex flex-col gap-2'>\n          <MotionNumber\n            value={result.percent}\n            suffix={PERCENT_SUFFIX}\n            className='text-5xl font-semibold'\n          />\n          <span className='text-muted-foreground flex items-center gap-1.5 text-sm'>\n            <Swap swapKey={result.trend} className='text-success-foreground'>\n              {isUp && <TrendingUpIcon className='size-4' />}\n              {!isUp && <TrendingDownIcon className='size-4' />}\n            </Swap>\n            <WordRoll\n              text={result.label}\n              labels={RESULT_LABELS}\n              value={position}\n            />\n          </span>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-05/featured-result.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-05/wall-card.tsx",
      "content": "import { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { TrendingDownIcon, TrendingUpIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\n\nimport type { Customer, Result } from './data';\n\nfunction chipTextOf(result: Result) {\n  return `${result.percent}% ${result.label}`;\n}\n\nfunction featuredToneOf(isFeatured: boolean) {\n  if (isFeatured) {\n    return 'ring-primary/50 bg-primary/[0.04] dark:bg-primary/[0.08]';\n  }\n  return 'ring-border bg-card hover:bg-foreground/[0.02] dark:bg-foreground/[0.04] dark:hover:bg-foreground/[0.06]';\n}\n\ntype WallCardProps = {\n  customer: Customer;\n  isFeatured: boolean;\n  isPressed: boolean;\n  onFeature: (customerId: string) => void;\n};\n\nexport function WallCard({\n  customer,\n  isFeatured,\n  isPressed,\n  onFeature,\n}: WallCardProps) {\n  const { person, result } = customer;\n  const isUp = result.trend === 'up';\n\n  return (\n    <button\n      type='button'\n      aria-pressed={isFeatured}\n      onClick={() => onFeature(customer.id)}\n      className={cn(\n        'hairline-ring focus-visible:ring-ring focus-visible:ring-offset-background flex h-full w-full cursor-pointer flex-col items-start gap-4 rounded-xl p-4 text-start shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-[background-color,box-shadow,scale] duration-150 ease-(--ease-out-strong) outline-none focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.97]',\n        featuredToneOf(isFeatured),\n        pressedQuietOf(isPressed)\n      )}\n    >\n      <span className='text-[13px] leading-5 text-pretty'>\n        {customer.short}\n      </span>\n      <span className='flex w-full min-w-0 items-center gap-2'>\n        <Avatar seed={person.name} className='size-6' />\n        <span className='min-w-0 flex-1 truncate text-xs'>\n          <span className='font-medium'>{person.name}</span>\n          <span className='text-muted-foreground'>, {customer.company}</span>\n        </span>\n      </span>\n      <Badge variant='success'>\n        {isUp && <TrendingUpIcon />}\n        {!isUp && <TrendingDownIcon />}\n        <span className='tabular-nums'>{chipTextOf(result)}</span>\n      </Badge>\n    </button>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-05/wall-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/testimonials/testimonials-05/data.ts",
      "content": "export type Trend = 'down' | 'up';\n\n/** A change measured in percent: the label carries its direction, \"fewer late deliveries\". */\nexport type Result = {\n  percent: number;\n  trend: Trend;\n  label: string;\n};\n\nexport type Customer = {\n  id: string;\n  person: {\n    name: string;\n    role: string;\n  };\n  company: string;\n  short: string;\n  long: string;\n  result: Result;\n};\n\nexport const SECTION = {\n  label: 'Customer results',\n  title: 'What changed for the teams that route with Routewise',\n  lead: 'Dispatchers and owners on the months after they switched, each with the number they watched.',\n};\n\n/** Invented people, companies and results. The figures are illustrative. */\nexport const CUSTOMERS: Customer[] = [\n  {\n    id: 'kestrel',\n    person: { name: 'Ruth Okonkwo', role: 'Dispatch lead' },\n    company: 'Kestrel Couriers',\n    short:\n      'Late deliveries stopped being the first thing we talk about on Mondays.',\n    long: 'We plan eighty routes before six in the morning. Routewise rebuilds them when a driver calls in sick, and late deliveries stopped being the first thing we talk about on Mondays.',\n    result: { percent: 31, trend: 'down', label: 'fewer late deliveries' },\n  },\n  {\n    id: 'greenlane',\n    person: { name: 'Henrik Aalto', role: 'Fleet manager' },\n    company: 'Greenlane Grocers',\n    short: 'Our vans cross the river once a morning instead of four times.',\n    long: 'It found that our vans crossed the river four times a morning. The new routes cross it once, and the fuel bill shows it every month.',\n    result: { percent: 18, trend: 'down', label: 'less fuel per route' },\n  },\n  {\n    id: 'oakmere',\n    person: { name: 'Lucía Romero', role: 'Owner' },\n    company: 'Oakmere Florists',\n    short: 'Customers get a live link instead of calling the shop.',\n    long: 'Customers used to call to ask where their flowers were. Now they get a link with the van on a map, and the phone rings for orders instead.',\n    result: { percent: 44, trend: 'down', label: 'fewer calls about the van' },\n  },\n  {\n    id: 'tidal',\n    person: { name: 'Samir Qureshi', role: 'Operations director' },\n    company: 'Tidal Parcels',\n    short: 'Same drivers, same hours, more parcels at the door.',\n    long: 'We did not hire for peak season this year. The same drivers make more stops in the same hours, because nobody drives back across town for a missed parcel.',\n    result: { percent: 27, trend: 'up', label: 'more stops per driver' },\n  },\n  {\n    id: 'hillcrest',\n    person: { name: 'Joanna Wiśniewska', role: 'Delivery coordinator' },\n    company: 'Hillcrest Pharmacy',\n    short: 'I check the plan now instead of drawing it on a map.',\n    long: 'I used to draw the routes on a printed map. Now I check the plan Routewise drafts, move one or two stops and send it to the drivers’ phones.',\n    result: {\n      percent: 63,\n      trend: 'down',\n      label: 'fewer routes planned by hand',\n    },\n  },\n  {\n    id: 'ferro',\n    person: { name: 'Marco Bianchi', role: 'Yard manager' },\n    company: 'Ferro Builders Supply',\n    short: 'Site managers trust the time window we give them.',\n    long: 'Building sites give us a two hour window. Routewise plans around the cranes and the school runs, so we keep the window far more often than we miss it.',\n    result: { percent: 12, trend: 'down', label: 'fewer missed time slots' },\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/testimonials-05/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "testimonials"
  ],
  "type": "registry:block"
}