{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-parts",
  "title": "Hero parts",
  "description": "What the Hero blocks share: the announcement above the title, the title, description and actions, the frame the product shot sits in, the backdrop, and the entrance they play once, in sequence.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/cut.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/lib/hero-parts.tsx",
      "content": "'use client'\n\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { CutTooltip } from '@/registry/lib/cut'\nimport type { ComponentProps, ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * What the Hero blocks share: the announcement above the title, the title,\n * description and actions, the frame the product shot sits in, the backdrop,\n * and the entrance they play once, in sequence.\n *\n * The entrance is CSS alone, on `starting:` styles, so it plays as the page\n * is first painted, before any script has loaded, and the hero is never\n * hidden waiting for one. The title never starts invisible, so the browser\n * counts its first paint as the page's largest one.\n */\n\n/** The heading levels a hero's title can take: the page's `h1`, unless it sits lower in a page. */\ntype HeroHeading = 'h1' | 'h2'\n\n/** What every Hero block takes. */\ninterface HeroProps extends Omit<ComponentProps<'section'>, 'title' | 'children'> {\n  title: ReactNode\n  description?: ReactNode\n  /** A link to what's new, above the title: a `HeroAnnouncement`. */\n  announcement?: ReactNode\n  /** Links in a Button's look: the main one first. */\n  actions?: ReactNode\n  /** The product, in a `HeroShot`. */\n  shot?: ReactNode\n  /** The title's level: the page's `h1`, unless the hero sits lower in a page. */\n  heading?: HeroHeading\n}\n\n/**\n * Each part's place in the entrance, as the share of the `enter` role's\n * duration it waits, so they arrive one after another.\n */\nconst ENTER_ORDER = {\n  announcement: '[--hero-wait:0]',\n  title: '[--hero-wait:0.1]',\n  description: '[--hero-wait:0.2]',\n  actions: '[--hero-wait:0.3]',\n  shot: '[--hero-wait:0.45]',\n} as const\n\ntype HeroPart = keyof typeof ENTER_ORDER\n\n/** A part rises into place as the page is first painted, after the parts before it. */\nconst riseClassName =\n  'transition-[opacity,translate] duration-(--motion-enter-duration) ease-[var(--motion-enter-fade-easing),var(--motion-enter-easing)] delay-[calc(var(--motion-enter-duration)*var(--hero-wait))] starting:opacity-0 motion-safe:starting:translate-y-(--hero-rise,0.75rem) motion-reduce:transition-[opacity]'\n\n/** The title rises like the other words, but from a faint first frame rather than nothing, so the page's largest text is painted at once. */\nconst titleRiseClassName =\n  'transition-[opacity,translate] duration-(--motion-enter-duration) ease-[var(--motion-enter-fade-easing),var(--motion-enter-easing)] delay-[calc(var(--motion-enter-duration)*var(--hero-wait))] starting:opacity-40 motion-safe:starting:translate-y-(--hero-rise,0.75rem) motion-reduce:transition-[opacity]'\n\n/** The shot rises further than the words, as the largest thing arriving. */\nconst shotRiseClassName =\n  'transition-[opacity,translate] duration-(--motion-enter-duration) ease-[var(--motion-enter-fade-easing),var(--motion-enter-easing)] delay-[calc(var(--motion-enter-duration)*var(--hero-wait))] starting:opacity-0 motion-safe:starting:translate-y-(--hero-shot-rise,2rem) motion-reduce:transition-[opacity]'\n\n/** The classes that play a part's entrance in its place in the sequence. */\nfunction heroEnter(part: HeroPart) {\n  return cn(\n    ENTER_ORDER[part],\n    part === 'title'\n      ? titleRiseClassName\n      : part === 'shot'\n        ? shotRiseClassName\n        : riseClassName,\n  )\n}\n\n/**\n * An arrow that points on along the line, and nudges that way while the link\n * around it, marked `group/nudge`, is hovered: the Hero's announcement and a\n * feature's link. It sits beside text, so it is 16px, as every icon there is.\n */\nfunction NudgeArrow({ className }: { className?: string }) {\n  return (\n    <IconPlaceholder\n      lucide='ArrowRightIcon'\n      tabler='IconArrowRight'\n      hugeicons='ArrowRight01Icon'\n      phosphor='ArrowRightIcon'\n      remixicon='RiArrowRightLine'\n      aria-hidden\n      className={cn(\n        'size-4 shrink-0 transition-transform duration-(--motion-press-duration) ease-(--motion-press-easing) group-hover/nudge:translate-x-0.5 motion-reduce:transition-none rtl:-scale-x-100 rtl:group-hover/nudge:-translate-x-0.5',\n        className,\n      )}\n    />\n  )\n}\n\n/**\n * A quiet link: its words, then an arrow that nudges along the line on\n * hover. A feature's link to more, and the Call to action's second way in\n * beside its main button.\n */\nfunction NudgeLink({ className, children, ...props }: ComponentProps<'a'>) {\n  return (\n    <a\n      data-slot='nudge-link'\n      className={cn(\n        'group/nudge text-foreground inline-flex min-h-6 items-center gap-1 font-medium underline-offset-4 hover:underline focus-visible:rounded-(--control-radius-xs) focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden',\n        className,\n      )}\n      {...props}\n    >\n      {children}\n      <NudgeArrow />\n    </a>\n  )\n}\n\n/** A link to what's new, above the title: a badge, a line and an arrow that nudges on hover. */\nfunction HeroAnnouncement({\n  badge,\n  className,\n  children,\n  ...props\n}: ComponentProps<'a'> & {\n  /** A word before the line, such as New. */\n  badge?: ReactNode\n}) {\n  return (\n    <CutTooltip\n      render={\n        <a\n          data-slot='hero-announcement'\n          className={cn(\n            'group/nudge bg-background text-foreground hover:bg-muted inline-flex max-w-full min-w-0 items-center gap-2 rounded-(--control-radius) border py-1 ps-1 pe-3 text-sm shadow-xs transition-[background-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing) focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden',\n            // Without a badge the line needs its own room at the start.\n            !badge && 'ps-3',\n            className,\n          )}\n          {...props}\n        >\n          {badge ? (\n            <span className='bg-primary text-primary-foreground inline-flex h-5 shrink-0 items-center rounded-(--control-radius-xs) px-1.5 text-xs font-medium'>\n              {badge}\n            </span>\n          ) : null}\n          <bdi data-cut className='min-w-0 truncate'>\n            {children}\n          </bdi>\n          <NudgeArrow className='text-muted-foreground' />\n        </a>\n      }\n    />\n  )\n}\n\n/**\n * A landing page's display type, at any size: tight and balanced across its\n * lines. Display type closes up: a body's tracking leaves gaps between\n * letters this large. The Hero's title and the Call to action's.\n */\nconst displayTitleClassName =\n  'leading-[1.05] font-medium tracking-[-0.035em] text-balance'\n\n/** The title's look: display type, larger as the hero widens. */\nconst heroTitleClassName = cn(\n  displayTitleClassName,\n  'text-4xl @2xl/hero:text-5xl @5xl/hero:text-6xl',\n)\n\n/**\n * What the hero stands on: a fine grid that fades out from the top centre,\n * and in the dark a light from above in the primary colour, so the page has\n * depth without a picture. Gradients, not blurs, so they cost nothing to\n * draw while the page scrolls. The section it sits in is `relative isolate`.\n */\nfunction HeroBackdrop({ className, ...props }: ComponentProps<'div'>) {\n  return (\n    <div\n      aria-hidden\n      data-slot='hero-backdrop'\n      className={cn(\n        'pointer-events-none absolute inset-0 -z-10 overflow-hidden forced-colors:hidden',\n        className,\n      )}\n      {...props}\n    >\n      {/* Lines a column's width apart, centred, so the grid sits square with the content. */}\n      <div className='absolute inset-0 bg-[linear-gradient(to_right,--alpha(var(--color-border)/70%)_1px,transparent_1px),linear-gradient(to_bottom,--alpha(var(--color-border)/70%)_1px,transparent_1px)] bg-size-[4rem_4rem] bg-position-[50%_0] [mask-image:radial-gradient(ellipse_60%_50%_at_50%_0%,#000_10%,transparent_90%)]' />\n      <div className='absolute inset-x-0 top-0 hidden h-[36rem] bg-[radial-gradient(ellipse_50%_70%_at_50%_0%,--alpha(var(--color-primary)/14%),transparent)] dark:block' />\n    </div>\n  )\n}\n\n/** The section's look: what every arrangement stands in. */\nconst heroSectionClassName =\n  '@container/hero relative isolate flex min-h-full w-full min-w-0 flex-col overflow-x-clip'\n\n/**\n * A landing page's column: as wide as a page's, with a gutter that grows with\n * the room of the container around it. The Hero's content and the Site\n * header's bar both sit in it, so their edges line up.\n */\nconst pageColumnClassName =\n  'mx-auto w-full max-w-7xl min-w-0 px-(--surface-padding) @3xl:px-10'\n\n/**\n * A landing page's section in that column, with a section's room above and\n * below: the Call to action's and the FAQ's.\n */\nconst sectionColumnClassName = cn(pageColumnClassName, 'py-16 @3xl:py-24')\n\n/**\n * The words of a hero that reads top to bottom: the announcement, then the\n * title with its description close under it, then the actions, each group\n * further apart than the lines within it.\n */\nfunction HeroWords({\n  titleId,\n  title,\n  description,\n  announcement,\n  actions,\n  heading = 'h1',\n  align = 'center',\n  titleClassName,\n}: Pick<HeroProps, 'title' | 'description' | 'announcement' | 'actions' | 'heading'> & {\n  titleId: string\n  align?: 'center' | 'start'\n  /** Sizes of the title's own, where the arrangement gives it less room. */\n  titleClassName?: string\n}) {\n  const Title = heading\n  return (\n    <header\n      className={cn(\n        // As wide as its column, so a long announcement shortens rather than widening it.\n        'flex w-full min-w-0 flex-col gap-8',\n        align === 'center' ? 'items-center text-center' : 'items-start',\n      )}\n    >\n      {announcement ? (\n        <div className={cn('max-w-full', heroEnter('announcement'))}>{announcement}</div>\n      ) : null}\n      <div\n        className={cn(\n          'flex min-w-0 flex-col gap-4',\n          align === 'center' ? 'max-w-3xl items-center' : 'items-start',\n        )}\n      >\n        <Title\n          id={titleId}\n          className={cn(heroTitleClassName, titleClassName, heroEnter('title'))}\n        >\n          {/* Its own direction, so its words read the same way round right to left. */}\n          <bdi>{title}</bdi>\n        </Title>\n        {description ? (\n          <p\n            className={cn(\n              align === 'center' ? 'max-w-2xl' : 'max-w-xl',\n              heroEnter('description'),\n            )}\n          >\n            <bdi>{description}</bdi>\n          </p>\n        ) : null}\n      </div>\n      {actions ? (\n        <div\n          className={cn(\n            'flex flex-wrap items-center gap-3',\n            align === 'center' && 'justify-center',\n            heroEnter('actions'),\n          )}\n        >\n          {actions}\n        </div>\n      ) : null}\n    </header>\n  )\n}\n\n/** The description's look: the title's quieter second voice. */\nconst heroDescriptionClassName =\n  'text-muted-foreground text-base text-pretty @2xl/hero:text-lg'\n\n/**\n * The frame the product shot sits in: a window on a soft bezel. The shot is\n * a picture of the product, so it is one image to a screen reader, named by\n * `label`, and nothing in it takes focus or a click. A `decorative` one,\n * whose words beside it say what it shows, is hidden from screen readers.\n */\nfunction HeroShot({\n  label,\n  decorative,\n  className,\n  children,\n  ...props\n}: Omit<ComponentProps<'div'>, 'role' | 'aria-label'> &\n  (\n    | {\n        /** What the shot shows, as the image's alternative text. */\n        label: string\n        decorative?: never\n      }\n    | {\n        /** The words beside it say what it shows: it is hidden from screen readers. */\n        decorative: true\n        label?: never\n      }\n  )) {\n  return (\n    <div\n      data-slot='hero-shot'\n      role={decorative ? undefined : 'img'}\n      aria-label={label}\n      aria-hidden={decorative}\n      className={cn(\n        // A bezel as wide as its padding, so the window's corner nests inside its own.\n        'bg-foreground/[0.03] ring-foreground/8 relative rounded-[calc(var(--surface-radius)+--spacing(1.5))] p-1.5 ring-1 dark:bg-white/[0.04]',\n        // A line of light along the bezel's top edge, as if lit from above.\n        'before:pointer-events-none before:absolute before:inset-x-[12%] before:top-0 before:h-px before:bg-linear-to-r before:from-transparent before:via-foreground/25 before:to-transparent dark:before:via-white/50',\n        className,\n      )}\n      {...props}\n    >\n      <div\n        inert\n        // In the dark the window is the card's step above the page, so it stands off it.\n        className='bg-background dark:bg-card overflow-hidden rounded-(--surface-radius) border shadow-[0_24px_64px_-24px_--alpha(var(--color-black)/25%)] dark:shadow-[0_24px_64px_-16px_--alpha(var(--color-black)/70%)]'\n      >\n        {children}\n      </div>\n    </div>\n  )\n}\n\nexport {\n  displayTitleClassName,\n  HeroAnnouncement,\n  HeroBackdrop,\n  heroDescriptionClassName,\n  heroEnter,\n  type HeroProps,\n  heroSectionClassName,\n  HeroShot,\n  HeroWords,\n  NudgeArrow,\n  NudgeLink,\n  pageColumnClassName,\n  sectionColumnClassName,\n}\n",
      "type": "registry:lib",
      "target": "@lib/hero-parts.tsx"
    }
  ],
  "type": "registry:lib"
}