{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heroes-05",
  "title": "Hero with a product view",
  "description": "A centred hero over a framed view of the app, where requests arrive and ship on their own: the view starts tilted back in 3D and lays itself flat as the page scrolls.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chip.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/motion-number.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",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/heroes/heroes-05/index.tsx",
      "content": "'use client';\n\nimport { useScroll } from 'motion/react';\nimport { type RefObject, useRef } from 'react';\n\nimport { ArrowRightIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport { HERO } from './data';\nimport { ProductView } from './product-view';\nimport { TiltFrame } from './tilt-frame';\n\nexport type Heroes05Props = {\n  /** The element that scrolls the page when it is not the window, such as a preview frame of your own. */\n  scrollContainerRef?: RefObject<HTMLElement | null>;\n};\n\nexport default function Heroes05({ scrollContainerRef }: Heroes05Props) {\n  const sectionRef = useRef<HTMLElement>(null);\n  /** Tilted while the top of the hero meets the top of the page, flat once the page scrolled 240px past it. */\n  const { scrollYProgress } = useScroll({\n    target: sectionRef,\n    container: scrollContainerRef,\n    offset: ['start start', '240px start'],\n  });\n\n  return (\n    <section ref={sectionRef} className='@container overflow-x-clip'>\n      <div className='mx-auto flex max-w-6xl flex-col items-center px-4 py-16 @2xl:px-6 @2xl:py-24'>\n        <div className='flex max-w-3xl flex-col items-center gap-5 text-center'>\n          <p className='text-primary-ink text-sm font-medium'>{HERO.eyebrow}</p>\n          <h1 className='text-4xl font-semibold text-balance @2xl:text-5xl'>\n            {HERO.title}\n          </h1>\n          <p className='text-muted-foreground max-w-xl text-base text-pretty'>\n            {HERO.description}\n          </p>\n          <div className='flex flex-wrap justify-center gap-2 pt-1'>\n            <Button size='lg' nativeButton={false} render={<a href='#' />}>\n              {HERO.primaryAction}\n              <ArrowRightIcon />\n            </Button>\n            <Button\n              size='lg'\n              variant='outline'\n              nativeButton={false}\n              render={<a href='#' />}\n            >\n              {HERO.secondaryAction}\n            </Button>\n          </div>\n        </div>\n        <div className='mt-12 w-full max-w-5xl @2xl:mt-16'>\n          <TiltFrame progress={scrollYProgress}>\n            <ProductView />\n          </TiltFrame>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-05/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-05/tilt-frame.tsx",
      "content": "'use client';\n\nimport { motion, type MotionValue, useTransform } from 'motion/react';\nimport type { ReactNode } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\n/** Enough to read as a screen leaning back; with the scale, its near edge never gets wider than the page. */\nconst TILT_DEGREES = 16;\n\nconst TILT_SCALE = 0.9;\n\nconst FLAT = { rotateX: 0, scale: 1 };\n\ntype Tilt = {\n  rotateX: MotionValue<number>;\n  scale: MotionValue<number>;\n};\n\nfunction styleOf(shouldReduceMotion: boolean, tilt: Tilt) {\n  if (shouldReduceMotion) {\n    return FLAT;\n  }\n  return tilt;\n}\n\ntype TiltFrameProps = {\n  /** From 0 at the top of the hero to 1 once the page scrolled past the stretch that flattens it. */\n  progress: MotionValue<number>;\n  children: ReactNode;\n};\n\n/**\n * Holds the product view tilted back in 3D and lays it flat as the progress runs. The values are\n * written to the element by the animation library, so a scroll never renders the view again.\n */\nexport function TiltFrame({ progress, children }: TiltFrameProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rotateX = useTransform(progress, [0, 1], [TILT_DEGREES, 0]);\n  const scale = useTransform(progress, [0, 1], [TILT_SCALE, 1]);\n  const tilt: Tilt = { rotateX, scale };\n  const style = styleOf(shouldReduceMotion, tilt);\n\n  return (\n    <div className='[perspective:1600px]'>\n      <motion.div style={style} className='origin-top'>\n        {children}\n      </motion.div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-05/tilt-frame.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-05/product-view.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport {\n  type AutoplayStep,\n  useAutoplay,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  ArrowUpIcon,\n  BookOpenIcon,\n  type Icon,\n  InboxIcon,\n  MessageSquareIcon,\n  RouteIcon,\n  UsersIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { countOf } from '@/registry/ndeko/lib/words';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\n\nimport {\n  ARRIVING,\n  type FeatureRequest,\n  FILTERS,\n  NAV,\n  type NavItem,\n  REQUESTS,\n  type RequestStatus,\n  WORKSPACE,\n} from './data';\n\ntype StatusLook = {\n  label: string;\n  color: string;\n};\n\nconst STATUS: Record<RequestStatus, StatusLook> = {\n  open: { label: 'Open', color: 'var(--muted-foreground)' },\n  planned: { label: 'Planned', color: 'var(--info)' },\n  building: { label: 'In progress', color: 'var(--warning)' },\n  shipped: { label: 'Shipped', color: 'var(--success)' },\n};\n\nconst NAV_ICONS: Record<NavItem['id'], Icon> = {\n  inbox: InboxIcon,\n  requests: MessageSquareIcon,\n  roadmap: RouteIcon,\n  changelog: BookOpenIcon,\n  customers: UsersIcon,\n};\n\nconst ACTIVE_NAV: NavItem['id'] = 'requests';\n\nconst LOOP_AFTER_MS = 3200;\n\nfunction askedByOf(request: FeatureRequest) {\n  if (request.others === 0) {\n    return request.company;\n  }\n  const others = countOf(request.others, 'other');\n  return `${request.company} and ${others}`;\n}\n\nfunction withArrival(requests: FeatureRequest[]) {\n  const isHere = requests.some((request) => request.id === ARRIVING.id);\n  if (isHere) {\n    return requests;\n  }\n  return [ARRIVING, ...requests];\n}\n\n/** A vote is one more customer asking, so the line of who asked counts them too. */\nfunction withVote(requests: FeatureRequest[], id: string) {\n  return requests.map((request) => {\n    if (request.id !== id) {\n      return request;\n    }\n    const votes = request.votes + 1;\n    const others = request.others + 1;\n    return { ...request, votes, others };\n  });\n}\n\nfunction withStatus(\n  requests: FeatureRequest[],\n  id: string,\n  status: RequestStatus\n) {\n  return requests.map((request) => {\n    if (request.id !== id) {\n      return request;\n    }\n    return { ...request, status };\n  });\n}\n\nfunction NavRow({ item }: { item: NavItem }) {\n  const Glyph = NAV_ICONS[item.id];\n  const isActive = item.id === ACTIVE_NAV;\n  const hasCount = item.count !== undefined;\n\n  return (\n    <li\n      className={cn(\n        'text-muted-foreground flex h-7 items-center gap-2 rounded-md px-2 text-[13px]',\n        isActive && 'bg-foreground/[0.06] text-foreground'\n      )}\n    >\n      <Glyph className='size-4 shrink-0' />\n      <span className='min-w-0 flex-1 truncate'>{item.label}</span>\n      {hasCount && <span className='text-xs tabular-nums'>{item.count}</span>}\n    </li>\n  );\n}\n\nfunction Sidebar() {\n  return (\n    <div className='hidden w-44 shrink-0 flex-col gap-4 p-2 @2xl:flex'>\n      <div className='flex items-center gap-2 px-1.5 pt-1'>\n        <CompanyMark seed={WORKSPACE} />\n        <span className='truncate text-[13px] font-medium'>{WORKSPACE}</span>\n      </div>\n      <ul className='flex flex-col gap-0.5'>\n        {NAV.map((item) => (\n          <NavRow key={item.id} item={item} />\n        ))}\n      </ul>\n    </div>\n  );\n}\n\nfunction filterLookOf(index: number) {\n  if (index === 0) {\n    return 'bg-card text-foreground shadow-[0_1px_2px_rgb(0_0_0/0.08)] dark:bg-foreground/[0.09]';\n  }\n  return 'text-muted-foreground';\n}\n\nfunction ListHeader({ count }: { count: number }) {\n  return (\n    <div className='flex items-center gap-2 px-4 pt-3.5 pb-2'>\n      <span className='text-sm font-medium'>Requests</span>\n      <MotionNumber value={count} className='text-muted-foreground text-xs' />\n      <span className='bg-foreground/[0.05] ms-auto hidden rounded-lg p-0.5 @md:flex'>\n        {FILTERS.map((filter, index) => (\n          <span\n            key={filter}\n            className={cn(\n              'rounded-md px-2.5 py-0.5 text-xs',\n              filterLookOf(index)\n            )}\n          >\n            {filter}\n          </span>\n        ))}\n      </span>\n    </div>\n  );\n}\n\nfunction RequestRow({ request }: { request: FeatureRequest }) {\n  const status = STATUS[request.status];\n  const askedBy = askedByOf(request);\n\n  return (\n    <div className='flex items-center gap-3 rounded-lg px-2 py-2'>\n      <span className='keycap-3d flex w-10 shrink-0 flex-col items-center gap-0.5 rounded-lg py-1'>\n        <ArrowUpIcon className='text-muted-foreground size-3' />\n        <MotionNumber value={request.votes} className='text-xs font-medium' />\n      </span>\n      <span className='flex min-w-0 flex-1 flex-col gap-0.5'>\n        <span className='truncate text-[13px] font-medium'>\n          {request.title}\n        </span>\n        <span className='text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs'>\n          <CompanyMark seed={request.company} size='sm' />\n          <span className='truncate'>{askedBy}</span>\n        </span>\n      </span>\n      <Swap swapKey={request.status} className='shrink-0'>\n        <Chip color={status.color}>{status.label}</Chip>\n      </Swap>\n    </div>\n  );\n}\n\n/**\n * The app the hero sells, drawn with the look of our blocks and playing on its own: a request\n * arrives at the top, a vote lands and one request ships. It is a picture, so nothing in it is\n * reachable; the first click on it ends the demonstration.\n */\nexport function ProductView() {\n  const [requests, setRequests] = useState<FeatureRequest[]>(REQUESTS);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n\n  function startOver() {\n    setRequests(REQUESTS);\n  }\n\n  const steps: AutoplayStep[] = [\n    { after: 1800, run: () => setRequests(withArrival) },\n    {\n      after: 1500,\n      run: () => setRequests((current) => withVote(current, 'csv')),\n    },\n    {\n      after: 1600,\n      run: () =>\n        setRequests((current) => withStatus(current, 'dark', 'shipped')),\n    },\n    {\n      after: 1500,\n      run: () => setRequests((current) => withVote(current, ARRIVING.id)),\n    },\n  ];\n  const { ref } = useAutoplay(steps, {\n    loopAfter: LOOP_AFTER_MS,\n    onReset: startOver,\n  });\n\n  return (\n    <div ref={ref} className='@container'>\n      <div\n        inert\n        aria-hidden='true'\n        className='bg-foreground/[0.025] flex gap-2 rounded-2xl p-2 select-none'\n      >\n        <Sidebar />\n        <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex min-w-0 flex-1 flex-col rounded-[calc(var(--radius-2xl)-0.5rem)] shadow-[0_1px_2px_rgb(0_0_0/0.04),0_12px_32px_-16px_rgb(0_0_0/0.12)]'>\n          <ListHeader count={requests.length} />\n          <ul className='h-[19rem] overflow-hidden mask-b-from-75% px-2 pb-2'>\n            <AnimatePresence initial={false}>\n              {requests.map((request) => (\n                <motion.li\n                  key={request.id}\n                  {...presence}\n                  className='overflow-hidden'\n                >\n                  <RequestRow request={request} />\n                </motion.li>\n              ))}\n            </AnimatePresence>\n          </ul>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-05/product-view.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-05/data.ts",
      "content": "export type RequestStatus = 'open' | 'planned' | 'building' | 'shipped';\n\nexport type FeatureRequest = {\n  id: string;\n  title: string;\n  /** The customer who asked first; the others who asked are counted. */\n  company: string;\n  others: number;\n  votes: number;\n  status: RequestStatus;\n};\n\nexport type NavItem = {\n  id: 'inbox' | 'requests' | 'roadmap' | 'changelog' | 'customers';\n  label: string;\n  count?: number;\n};\n\nexport const HERO = {\n  eyebrow: 'Feedback, roadmap and changelog in one place',\n  title: 'Hear every customer, then ship what they asked for',\n  description:\n    'Requests from email, chat and calls land in one list, ranked by how many customers asked. Mark one shipped and everyone who asked hears about it.',\n  primaryAction: 'Start for free',\n  secondaryAction: 'Book a demo',\n};\n\nexport const WORKSPACE = 'Harbor & Pine';\n\nexport const NAV: NavItem[] = [\n  { id: 'inbox', label: 'Inbox', count: 12 },\n  { id: 'requests', label: 'Requests' },\n  { id: 'roadmap', label: 'Roadmap' },\n  { id: 'changelog', label: 'Changelog' },\n  { id: 'customers', label: 'Customers' },\n];\n\nexport const FILTERS = ['Open', 'Planned', 'Shipped'];\n\nexport const REQUESTS: FeatureRequest[] = [\n  {\n    id: 'csv',\n    title: 'Export reports to CSV',\n    company: 'Lumen Labs',\n    others: 47,\n    votes: 48,\n    status: 'planned',\n  },\n  {\n    id: 'dark',\n    title: 'Dark mode for the dashboard',\n    company: 'Northwind Atelier',\n    others: 40,\n    votes: 41,\n    status: 'building',\n  },\n  {\n    id: 'key',\n    title: 'Sign in with a security key',\n    company: 'Brightwater Clinic',\n    others: 32,\n    votes: 33,\n    status: 'planned',\n  },\n  {\n    id: 'tags',\n    title: 'Edit the tags of many requests at once',\n    company: 'Copperfield and Co',\n    others: 26,\n    votes: 27,\n    status: 'open',\n  },\n  {\n    id: 'digest',\n    title: 'A weekly digest by email',\n    company: 'Sable Studio',\n    others: 1,\n    votes: 2,\n    status: 'open',\n  },\n];\n\n/** The request the demonstration brings in at the top of the list. */\nexport const ARRIVING: FeatureRequest = {\n  id: 'share',\n  title: 'Share a saved view with a link',\n  company: 'Pinecone Bakery',\n  others: 0,\n  votes: 1,\n  status: 'open',\n};\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-05/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "heroes"
  ],
  "type": "registry:block"
}