{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collage-hero",
  "title": "Collage Hero",
  "author": "AlgorizeTech",
  "description": "Ask the user to pick one of 16 hero variants: https://avaraui.com/view/hero. This is the Collage hero. Skip the question if the user already named one. A playful hero: a badge whose name turns around a mark, a serif headline with two coloured words, hashtag pills, a five-column photo collage and a footer with a quote, a scroll pill and a watch-video trigger. Use it for a kindergarten, studio, school or any warm, busy place.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://avaraui.com/r/animated-typography.json",
    "https://avaraui.com/r/button.json",
    "https://avaraui.com/r/circular-text.json",
    "https://avaraui.com/r/dialog.json",
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/CollageHeroBlock.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { ArrowDown, Play } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { AnimatedTypographyBlock } from \"./AnimatedTypographyBlock\";\nimport Button from \"./Button\";\nimport { CircularText } from \"./CircularTextBlock\";\nimport { Dialog, DialogContent, DialogTrigger } from \"./DialogBlock\";\nimport { accentTokens } from \"@/lib/accent\";\n\n// ==========================================\n// COLLAGE HERO\n// A hero for any place that is warm and busy — a school, a studio, a café: a badge that\n// turns slowly, a serif headline with two words in colour, hashtag pills, a\n// collage of seven photographs in five columns, and a footer with a quote,\n// a scroll-down pill and a watch-video trigger. One reveal when it first\n// appears; after that the badge keeps turning and the pointer does the rest.\n// ==========================================\n\nexport interface CollagePhoto {\n  src: string;\n  alt: string;\n  /** CSS object-position for the crop. */\n  position?: string;\n}\n\nexport interface CollageTag {\n  label: string;\n  /** Pill colour: the accent, the highlight, or a soft tint of the accent. */\n  tone?: \"accent\" | \"highlight\" | \"soft\";\n}\n\nexport interface CollageHeroProps extends React.HTMLAttributes<HTMLElement> {\n  /** Words that run around the badge, e.g. the school's name. */\n  brand: string;\n  /** What sits in the middle of the badge. Three dots by default. */\n  logo?: React.ReactNode;\n  /** The headline. Wrap the words to colour in <em>: the first takes the accent, the second the highlight. */\n  heading: React.ReactNode;\n  tags?: CollageTag[];\n  /** Small tracked line over the first photo. */\n  caption?: string;\n  /** Seven photographs, laid out left to right: one, two stacked, one tall, two stacked, one. Fewer are fine — the columns just empty. */\n  photos: CollagePhoto[];\n  quote?: string;\n  /** Label of the scroll pill; `scrollTo` is a selector to scroll to, else the next section. */\n  scrollLabel?: string;\n  scrollTo?: string;\n  /** The watch-video trigger and the embed it opens. */\n  video?: { eyebrow?: string; text: string; url: string; title?: string };\n  /** Accent colour — sets `--primary` for the section; the theme's primary by default. */\n  accent?: string;\n  color?: string;\n  /** The second colour, for the second <em> and the highlight pills. */\n  highlight?: string;\n  reveal?: \"in-view\" | \"immediate\";\n}\n\n// ------------------------------------------\n// Badge — words on a circle, turning (CircularText with the three-dot mark)\n// ------------------------------------------\nfunction Badge({ text, logo }: { text: string; logo?: React.ReactNode }) {\n  return (\n    <CircularText text={text} size={144} speed={22} innerRing className=\"[&>svg]:size-full\">\n      {logo ?? (\n        <span className=\"relative block size-12\" aria-hidden>\n          <span className=\"absolute left-1 top-0 size-6 rounded-full bg-primary\" />\n          <span className=\"absolute left-6 top-4 size-6 rounded-full bg-[var(--kg-highlight)]\" />\n          <span className=\"absolute left-1 top-6 size-6 rounded-full bg-primary\" />\n        </span>\n      )}\n    </CircularText>\n  );\n}\n\n// ------------------------------------------\n// Root\n// ------------------------------------------\nconst TAG_TONES: Record<NonNullable<CollageTag[\"tone\"]>, string> = {\n  accent: \"bg-primary text-primary-foreground\",\n  highlight: \"bg-[var(--kg-highlight)] text-[#2b2306]\",\n  soft: \"bg-primary/15 text-primary\",\n};\n\n// GSAP's power3.out and back.out(2), as CSS easings.\nconst EASE_OUT =\n  \"linear(0, .1945, .3591, .4971, .6115, .7052, .7808, .8409, .8877, .9233, .9497, .9686, .9816, .9901, .9952, .998, .9994, .9999, 1, 1)\";\nconst EASE_POP =\n  \"linear(0, .2225, .4153, .5802, .7191, .8341, .9271, 1, 1.0547, 1.0933, 1.1176, 1.1296, 1.1312, 1.1244, 1.1111, 1.0933, 1.0729, 1.0518, 1.0321, 1.0155, 1.0042, 1)\";\n\n// The reveal. Each keyframe is only the start pose; the element's own style\n// is where it lands.\nconst REVEAL_CSS = `\n@keyframes kg-lead-in { from { opacity: 0; transform: translateY(18px); filter: blur(8px); } }\n@keyframes kg-tag-in { from { opacity: 0; transform: rotate(-12deg) scale(0.6); } }\n@keyframes kg-photo-in { from { opacity: 0; transform: translateY(32px) scale(0.96); } }\n@keyframes kg-foot-in { from { opacity: 0; transform: translateY(12px); } }\n[data-kg-reveal] [data-kg-lead] { animation: kg-lead-in 0.8s ${EASE_OUT} var(--kg-at, 0s) backwards; }\n[data-kg-reveal] [data-kg-tag] { animation: kg-tag-in 0.5s ${EASE_POP} var(--kg-at, 0s) backwards; }\n[data-kg-reveal] [data-kg-photo] { animation: kg-photo-in 0.8s ${EASE_OUT} var(--kg-at, 0s) backwards; }\n[data-kg-reveal] [data-kg-foot] { animation: kg-foot-in 0.6s ${EASE_OUT} var(--kg-at, 0s) backwards; }\n`;\n\n// A photo card: rounded, lifts and zooms a touch on hover.\nfunction Photo({ photo, className }: { photo: CollagePhoto; className?: string }) {\n  return (\n    <figure\n      data-kg-photo=\"\"\n      className={cn(\n        \"group relative overflow-hidden rounded-[22px] bg-foreground/[0.04] transition-transform duration-500 ease-out hover:-translate-y-1\",\n        className,\n      )}\n    >\n      <img\n        src={photo.src}\n        alt={photo.alt}\n        style={photo.position ? { objectPosition: photo.position } : undefined}\n        className=\"absolute inset-0 h-full w-full object-cover transition-transform duration-700 ease-out group-hover:scale-[1.05]\"\n      />\n    </figure>\n  );\n}\n\nexport function CollageHero({\n  brand,\n  logo,\n  heading,\n  tags = [],\n  caption,\n  photos,\n  quote,\n  scrollLabel = \"Keep scrolling\",\n  scrollTo,\n  video,\n  accent,\n  color,\n  highlight = \"#f5c542\",\n  reveal = \"in-view\",\n  className,\n  style,\n  ...props\n}: CollageHeroProps) {\n  const rootRef = useRef<HTMLElement>(null);\n  const [inView, setInView] = useState(reveal === \"immediate\");\n  const [phase, setPhase] = useState<\"idle\" | \"play\" | \"done\">(\"idle\");\n  const [p0, p1, p2, p3, p4, p5, p6] = photos;\n\n  useEffect(() => {\n    if (inView) return;\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") {\n      setInView(true);\n      return;\n    }\n    const io = new IntersectionObserver(\n      (entries) => {\n        if (entries.some((e) => e.isIntersecting)) {\n          setInView(true);\n          io.disconnect();\n        }\n      },\n      { threshold: 0.2 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [inView]);\n\n  // The reveal: headline up out of a blur, the pills pop in with a twist, the\n  // photographs rise one after another, the footer last. Everything renders\n  // opaque on the server; this only plays once the page is live. Each element\n  // gets its start time as `--kg-at` (lead from 0 every 0.12s, pills from\n  // 0.35 every 0.08s, photos from 0.5 every 0.07s, footer from 1.1 every 0.1s)\n  // and the keyframes in REVEAL_CSS hold its start pose until then.\n  useEffect(() => {\n    if (!inView) return;\n    const root = rootRef.current;\n    if (!root) return;\n    const reduced =\n      typeof window !== \"undefined\" && window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n    if (reduced) return;\n    const stagger = (selector: string, start: number, each: number) =>\n      root\n        .querySelectorAll<HTMLElement>(selector)\n        .forEach((el, i) => el.style.setProperty(\"--kg-at\", `${start + i * each}s`));\n    stagger(\"[data-kg-lead], [data-kg-heading]\", 0, 0.12);\n    stagger(\"[data-kg-tag]\", 0.35, 0.08);\n    stagger(\"[data-kg-photo]\", 0.5, 0.07);\n    stagger(\"[data-kg-foot]\", 1.1, 0.1);\n    // Start on the next frame, once the start times above are in place.\n    // Once the footer has landed the keyframes come off, so pills that were\n    // display:none below lg do not replay them when the window widens.\n    let t = 0;\n    const raf = window.requestAnimationFrame(() => {\n      setPhase(\"play\");\n      t = window.setTimeout(() => setPhase(\"done\"), 2000);\n    });\n    return () => {\n      window.cancelAnimationFrame(raf);\n      window.clearTimeout(t);\n    };\n  }, [inView]);\n\n  const onScroll = () => {\n    const root = rootRef.current;\n    const target = scrollTo ? document.querySelector(scrollTo) : root?.nextElementSibling;\n    target?.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n  };\n\n  const vars = {\n    ...accentTokens(accent || color),\n    \"--kg-highlight\": highlight,\n  } as React.CSSProperties;\n\n  return (\n    <section\n      ref={rootRef}\n      data-kg-reveal={phase === \"play\" ? \"\" : undefined}\n      className={cn(\"relative w-full overflow-hidden bg-background text-foreground\", className)}\n      style={{ ...vars, ...style }}\n      {...props}\n    >\n      <style>{REVEAL_CSS}</style>\n      <div className=\"mx-auto max-w-6xl px-5 pb-8 pt-8 sm:px-8 sm:pt-10\">\n        {/* ---- Header: badge / headline / pills ---- */}\n        <div className=\"grid grid-cols-1 items-center gap-6 lg:grid-cols-[10rem_1fr_12rem]\">\n          <div data-kg-lead=\"\" className=\"justify-self-center lg:justify-self-start\">\n            <Badge text={brand} logo={logo} />\n          </div>\n\n          <div className=\"relative text-center\">\n            {/* A hand-drawn curl with an arrowhead, pointing at the words. */}\n            <svg\n              aria-hidden\n              viewBox=\"0 0 120 80\"\n              className=\"absolute -left-4 -top-8 hidden h-16 w-24 text-primary lg:block\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              strokeWidth=\"2.5\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n            >\n              <path d=\"M6 6c10 0 30 6 32 20s-16 24-24 14 8-26 30-24 38 22 62 38\" />\n              <path d=\"M98 44l10 10-14 3\" />\n            </svg>\n            {/* Rises out of a blur with the other leads; data-kg-heading keeps\n                its place in their stagger (0.12s) without the lead keyframes. */}\n            <AnimatedTypographyBlock\n              as=\"h1\"\n              bare\n              variant=\"blur-rise\"\n              play={phase === \"play\"}\n              delay={120}\n              data-kg-heading=\"\"\n              className=\"mx-auto max-w-[19ch] font-serif text-[2.4rem] font-normal leading-[1.08] tracking-[-0.02em] sm:text-[3.3rem] lg:text-[3.7rem] [&_em]:italic [&_em]:text-primary [&_em+em]:text-[var(--kg-highlight)] [&_em:nth-of-type(2)]:text-[var(--kg-highlight)]\"\n            >\n              {heading}\n            </AnimatedTypographyBlock>\n          </div>\n\n          <div className=\"relative hidden min-h-[9rem] lg:block\">\n            {tags.slice(0, 3).map((t, i) => (\n              <span\n                key={t.label}\n                data-kg-tag=\"\"\n                // After the reveal the tilt sits in `transform`, where the pop-in\n                // ends, with `rotate` and `scale` pinned to none.\n                style={\n                  phase === \"idle\"\n                    ? { rotate: `${[-8, 6, -4][i]}deg` }\n                    : { rotate: \"none\", scale: \"none\", transform: `rotate(${[-8, 6, -4][i]}deg) scale(1)` }\n                }\n                className={cn(\n                  \"absolute rounded-full px-4 py-1.5 text-[13px] font-semibold shadow-[0_8px_20px_-12px_rgba(0,0,0,0.35)] transition-transform duration-300 hover:scale-110 hover:!rotate-0\",\n                  i === 0 && \"left-2 top-1\",\n                  i === 1 && \"right-0 top-5\",\n                  i === 2 && \"left-10 top-16\",\n                  TAG_TONES[t.tone ?? ([\"soft\", \"highlight\", \"accent\"][i] as CollageTag[\"tone\"]) ?? \"soft\"],\n                )}\n              >\n                {t.label}\n              </span>\n            ))}\n            {/* Concentric rings, the way a child would draw a sun. */}\n            <svg aria-hidden viewBox=\"0 0 100 100\" className=\"absolute -bottom-16 right-2 size-24 text-primary/70\">\n              {[46, 38, 30, 22, 14, 6].map((r) => (\n                <circle key={r} cx=\"50\" cy=\"50\" r={r} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\" />\n              ))}\n            </svg>\n          </div>\n        </div>\n\n        {/* Pills on small screens: a plain row under the headline. */}\n        {tags.length > 0 && (\n          <div className=\"mt-4 flex flex-wrap justify-center gap-2 lg:hidden\">\n            {tags.slice(0, 3).map((t, i) => (\n              <span\n                key={t.label}\n                className={cn(\n                  \"rounded-full px-3.5 py-1 text-[12px] font-semibold\",\n                  TAG_TONES[t.tone ?? ([\"soft\", \"highlight\", \"accent\"][i] as CollageTag[\"tone\"]) ?? \"soft\"],\n                )}\n              >\n                {t.label}\n              </span>\n            ))}\n          </div>\n        )}\n\n        {/* ---- Collage: five columns, staggered ----\n            Phones: two columns, the tall photo full width between them.\n            Tablets: three columns — the first photo grows to fill its column\n            beside the stack and the tall one, then the last three sit in a\n            row of equal landscapes, so no cell is left empty.\n            Desktop: five staggered columns. */}\n        <div className=\"mt-8 grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4 lg:mt-6 lg:grid-cols-[1fr_1fr_1.15fr_1fr_1fr]\">\n          <div className=\"flex flex-col justify-start gap-4 sm:col-span-1 lg:pt-4\">\n            {caption && (\n              <p data-kg-lead=\"\" className=\"text-[11px] font-semibold uppercase leading-[1.5] tracking-[0.12em] text-foreground/80\">\n                {caption}\n              </p>\n            )}\n            {p0 && <Photo photo={p0} className=\"aspect-square sm:aspect-auto sm:flex-1 lg:flex-none lg:aspect-square\" />}\n          </div>\n          <div className=\"flex flex-col gap-3 sm:gap-4 lg:pt-6\">\n            {p1 && <Photo photo={p1} className=\"aspect-[4/3]\" />}\n            {p2 && <Photo photo={p2} className=\"aspect-[4/5] sm:aspect-square lg:aspect-[4/5]\" />}\n          </div>\n          {p3 && <Photo photo={p3} className=\"col-span-2 aspect-[4/3] sm:col-span-1 sm:aspect-auto\" />}\n          <div className=\"flex flex-col gap-3 sm:col-span-2 sm:flex-row sm:gap-4 lg:col-span-1 lg:flex-col lg:pt-6\">\n            {p4 && <Photo photo={p4} className=\"aspect-[4/3] sm:min-w-0 sm:flex-1 lg:flex-none\" />}\n            {p5 && <Photo photo={p5} className=\"aspect-[4/3] sm:min-w-0 sm:flex-1 lg:flex-none\" />}\n          </div>\n          <div className=\"flex flex-col justify-center lg:pt-16\">\n            {p6 && <Photo photo={p6} className=\"aspect-square sm:aspect-[4/3] lg:aspect-square\" />}\n          </div>\n        </div>\n\n        {/* ---- Footer: quote / scroll / video ---- */}\n        <div className=\"mt-8 grid grid-cols-1 items-center gap-6 sm:grid-cols-[1fr_auto_1fr] cursor-pointer\">\n          <div data-kg-foot=\"\" className=\"max-w-xs\">\n            {quote && (\n              <>\n                <span className=\"block font-serif text-4xl leading-none text-primary\" aria-hidden>\n                  &ldquo;\n                </span>\n                <p className=\"-mt-1 text-[12.5px] leading-relaxed text-foreground/75\">{quote}</p>\n              </>\n            )}\n          </div>\n\n          <div data-kg-foot=\"\" className=\"justify-self-center\">\n            <Button\n              variant=\"ghost\"\n              onClick={onScroll}\n              iconRight={<ArrowDown size={14} className=\"transition-transform duration-300 group-hover:translate-y-0.5\" />}\n              className=\"group h-11 rounded-full border border-primary/70 bg-transparent px-6 text-[14px] font-semibold text-primary shadow-none hover:bg-primary/10 hover:text-primary\"\n            >\n              {scrollLabel}\n            </Button>\n          </div>\n\n          <div data-kg-foot=\"\" className=\"sm:justify-self-end\">\n            {video && (\n              <Dialog>\n                <DialogTrigger className=\"group flex items-center gap-4 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary/50\">\n                  <span className=\"grid size-12 shrink-0 place-items-center rounded-full border-2 border-primary/70 text-primary transition-all duration-300 group-hover:scale-105 group-hover:bg-primary group-hover:text-primary-foreground\">\n                    <Play size={16} className=\"ml-0.5 fill-current\" />\n                  </span>\n                  <span className=\"text-left\">\n                    {video.eyebrow && <span className=\"block text-[11px] text-foreground/50\">{video.eyebrow}</span>}\n                    <span className=\"block max-w-[15rem] text-[13px] font-medium leading-snug\">{video.text}</span>\n                  </span>\n                </DialogTrigger>\n                <DialogContent size=\"lg\" className=\"p-0\">\n                  <div className=\"aspect-video w-full overflow-hidden rounded-2xl bg-black\">\n                    <iframe\n                      src={video.url}\n                      title={video.title ?? video.text}\n                      className=\"h-full w-full\"\n                      allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n                      allowFullScreen\n                    />\n                  </div>\n                </DialogContent>\n              </Dialog>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nCollageHero.Badge = Badge;\nCollageHero.Photo = Photo;\n\nexport default CollageHero;\n",
      "type": "registry:component",
      "target": "components/custom/blocks/CollageHeroBlock.tsx"
    },
    {
      "path": "src/lib/accent.ts",
      "content": "import type { CSSProperties } from \"react\";\n\n/**\n * Bridging the docs colour picker into a preview.\n *\n * Most blocks are already written against the `--primary` token (`bg-primary`,\n * `ring-primary/30`, `text-primary-foreground`…). Rather than teaching each one a\n * bespoke `color` prop, a demo can repoint that token for its own subtree and\n * every one of those classes follows along.\n */\n\n/** The swatches the picker offers, as concrete CSS colours. */\nconst PRESET_HEX: Record<string, string> = {\n  lavender: \"#9b8afb\",\n  indigo: \"#6366f1\",\n  rose: \"#f43f5e\",\n  emerald: \"#10b981\",\n  zinc: \"#18181b\",\n};\n\n/** True when the picker sits on \"Default\" — the page theme should win. */\nexport function isDefaultAccent(color?: string): boolean {\n  return !color || color === \"primary\" || color === \"default\";\n}\n\n/**\n * Turns a picker value into a CSS colour, or null for \"Default\" — meaning\n * nothing should be overridden, so the theme (and the sidebar customizer)\n * keeps control.\n */\nexport function resolveAccent(color?: string): string | null {\n  if (isDefaultAccent(color)) return null;\n  return PRESET_HEX[color as string] ?? (color as string);\n}\n\n/**\n * The picker value in a form every block accepts. Blocks know the older swatch\n * names but not \"lavender\" — and since that is also a CSS named colour\n * (#e6e6fa), a block that passes unknown names straight through would paint\n * the wrong shade, while others fall back to a different palette. Demos that\n * hand the picker value to such a block run it through this first. Every\n * other value is returned untouched.\n */\nexport function toBlockColor(color: string): string;\nexport function toBlockColor(color: string | undefined): string | undefined;\nexport function toBlockColor(color?: string): string | undefined {\n  return color === \"lavender\" ? PRESET_HEX.lavender : color;\n}\n\nfunction parseHex(input: string): [number, number, number] | null {\n  const hex = input.trim().replace(/^#/, \"\");\n  if (/^[a-f\\d]{3}$/i.test(hex)) {\n    const [r, g, b] = hex.split(\"\");\n    return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16)];\n  }\n  if (/^[a-f\\d]{6}$/i.test(hex)) {\n    return [\n      parseInt(hex.slice(0, 2), 16),\n      parseInt(hex.slice(2, 4), 16),\n      parseInt(hex.slice(4, 6), 16),\n    ];\n  }\n  return null;\n}\n\n/** Legible foreground for content sitting on a filled `color` swatch. */\nexport function accentForeground(color: string): string {\n  const rgb = parseHex(color);\n  if (!rgb) return \"#ffffff\";\n  const channel = (v: number) => {\n    const c = v / 255;\n    return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n  };\n  const luminance =\n    0.2126 * channel(rgb[0]) +\n    0.7152 * channel(rgb[1]) +\n    0.0722 * channel(rgb[2]);\n  return luminance > 0.45 ? \"#09090b\" : \"#ffffff\";\n}\n\n/** The theme tokens a picked accent repoints, as `--name` → value. */\nexport function accentTokens(color?: string): Record<string, string> {\n  const resolved = resolveAccent(color);\n  if (!resolved) return {};\n  return {\n    \"--primary\": resolved,\n    \"--primary-foreground\": accentForeground(resolved),\n    \"--ring\": resolved,\n  };\n}\n\n/**\n * Inline style repointing `--primary` at the picked accent for one subtree.\n * `--primary-foreground` is derived alongside it, otherwise a light pick leaves\n * `text-primary-foreground` content unreadable on its own fill. Returns `{}` on\n * \"Default\" so the page theme still wins.\n */\nexport function accentStyle(color?: string): CSSProperties {\n  return accentTokens(color) as CSSProperties;\n}\n",
      "type": "registry:component",
      "target": "lib/accent.ts"
    }
  ],
  "docs": "Named export: CollageHero (plus CollageHero.Badge and CollageHero.Photo). Composed from the button, circular-text and dialog items, which install alongside it. Pass `brand`, `heading` (with <em> for the coloured words), `tags`, `caption`, seven `photos`, `quote`, `scrollLabel`/`scrollTo` and `video` ({ text, url }). `accent` sets --primary for the section, `highlight` the second colour; `reveal` is in-view or immediate.",
  "categories": [
    "marketing",
    "layout"
  ],
  "type": "registry:component"
}
