{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "phone-fan-hero",
  "title": "Phone Fan Hero",
  "description": "An app launch hero: five phones open out from a stack into a fan, and the one you point at rises while its neighbours step aside. Comes with drawn screens, or use screenshots.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/phone-fan-hero/phone-fan-hero.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type PhoneFanTheme = \"dark\" | \"light\";\n\nexport type PhoneFrameColor =\n  \"Natural Titanium\" | \"Blue Titanium\" | \"White Titanium\" | \"Black Titanium\";\n\nexport interface PhoneScreen {\n  /** Read out for the phone, e.g. \"Wallet screen\". */\n  label: string;\n  /** A screenshot. Portrait, roughly 9:19.5. */\n  image?: string;\n  /** Or anything else to render on the screen. Size it in em and it scales with the phone. */\n  content?: React.ReactNode;\n}\n\nexport interface PhoneFanHeroProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: PhoneFanTheme;\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  primaryAction?: { label: string; href?: string; onClick?: () => void } | null;\n  secondaryAction?: {\n    label: string;\n    href?: string;\n    onClick?: () => void;\n  } | null;\n  /** Phones from left to right. Odd numbers fan best. */\n  screens?: PhoneScreen[];\n  /** Degrees between neighbouring phones. */\n  spread?: number;\n  /** Finish of the phone frames. */\n  frameColor?: PhoneFrameColor;\n  /** Height from tablet width up, in px. */\n  minHeight?: number;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    text: \"#F5F5F4\",\n    sub: \"rgba(245,245,244,0.62)\",\n    btn: \"#F5F5F4\",\n    btnText: \"#0A0A0B\",\n    ghost: \"rgba(255,255,255,0.08)\",\n    shadow: \"rgba(0,0,0,0.75)\",\n    glow: \"rgba(120,110,255,0.2)\",\n  },\n  light: {\n    bg: \"#F4F3EF\",\n    text: \"#121211\",\n    sub: \"rgba(18,18,17,0.62)\",\n    btn: \"#121211\",\n    btnText: \"#F4F3EF\",\n    ghost: \"rgba(18,18,17,0.07)\",\n    shadow: \"rgba(40,36,30,0.42)\",\n    glow: \"rgba(120,110,255,0.16)\",\n  },\n};\n\nconst FRAME_COLORS: Record<\n  PhoneFrameColor,\n  {\n    stops: [string, string][];\n    ring: string;\n    from: string;\n    to: string;\n    dark: boolean;\n  }\n> = {\n  \"Natural Titanium\": {\n    stops: [\n      [\"0%\", \"#d8d4ca\"],\n      [\"30%\", \"#bcb8ae\"],\n      [\"60%\", \"#ccc8be\"],\n      [\"100%\", \"#a8a49a\"],\n    ],\n    ring: \"#1c1c1c\",\n    from: \"#b4b0a6\",\n    to: \"#d4d0c6\",\n    dark: false,\n  },\n  \"Blue Titanium\": {\n    stops: [\n      [\"0%\", \"#6e7c8a\"],\n      [\"30%\", \"#525f6c\"],\n      [\"60%\", \"#5f6d7a\"],\n      [\"100%\", \"#3a4550\"],\n    ],\n    ring: \"#10141a\",\n    from: \"#46525e\",\n    to: \"#64727f\",\n    dark: true,\n  },\n  \"White Titanium\": {\n    stops: [\n      [\"0%\", \"#f8f4ec\"],\n      [\"30%\", \"#e9e4d8\"],\n      [\"60%\", \"#f2ede1\"],\n      [\"100%\", \"#ddd7ca\"],\n    ],\n    ring: \"#1c1c1c\",\n    from: \"#d4cfc2\",\n    to: \"#f4efe3\",\n    dark: false,\n  },\n  \"Black Titanium\": {\n    stops: [\n      [\"0%\", \"#2e2e30\"],\n      [\"40%\", \"#1c1c1e\"],\n      [\"100%\", \"#0d0d0e\"],\n    ],\n    ring: \"#0a0a0a\",\n    from: \"#1a1a1a\",\n    to: \"#2e2e2e\",\n    dark: true,\n  },\n};\n\n/** Phone measurements are in points on a 393 x 852 body, scaled to the phone's width. */\nconst pt = (n: number) => `calc(var(--pw) * ${(n / 393).toFixed(5)})`;\n\nfunction roundedRect(x: number, y: number, w: number, h: number, r: number) {\n  return `M${x + r},${y} H${x + w - r} A${r},${r} 0 0 1 ${x + w},${y + r} V${y + h - r} A${r},${r} 0 0 1 ${x + w - r},${y + h} H${x + r} A${r},${r} 0 0 1 ${x},${y + h - r} V${y + r} A${r},${r} 0 0 1 ${x + r},${y} Z`;\n}\n\nfunction PhoneFrame({\n  color,\n  children,\n}: {\n  color: PhoneFrameColor;\n  children: React.ReactNode;\n}) {\n  const id = `phone-frame-${React.useId().replace(/[^a-zA-Z0-9]/g, \"\")}`;\n  const tokens = FRAME_COLORS[color] ?? FRAME_COLORS[\"Natural Titanium\"];\n  const shadow = tokens.dark\n    ? \"0 0 0 1px rgba(255,255,255,0.08), 0 28px 70px rgba(0,0,0,0.6), 0 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06)\"\n    : \"0 0 0 1px rgba(255,255,255,0.6), 0 28px 70px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -1px 0 rgba(0,0,0,0.1)\";\n  const keys: [number, number, \"left\" | \"right\"][] = [\n    [100, 36, \"left\"],\n    [158, 72, \"left\"],\n    [246, 72, \"left\"],\n    [180, 90, \"right\"],\n  ];\n  const glass = {\n    left: pt(10),\n    top: pt(10),\n    right: pt(10),\n    bottom: pt(10),\n    borderRadius: pt(47),\n  };\n  return (\n    <span className=\"relative block size-full\">\n      <span\n        className=\"absolute inset-0\"\n        style={{ borderRadius: pt(56), boxShadow: shadow }}\n      />\n      <span className=\"absolute overflow-hidden bg-black\" style={glass}>\n        {children}\n      </span>\n      <svg\n        viewBox=\"0 0 393 852\"\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 block size-full\"\n      >\n        <defs>\n          <linearGradient id={id} x1=\"35%\" y1=\"0%\" x2=\"65%\" y2=\"100%\">\n            {tokens.stops.map(([offset, stop]) => (\n              <stop key={offset} offset={offset} stopColor={stop} />\n            ))}\n          </linearGradient>\n        </defs>\n        <path\n          d={`${roundedRect(0, 0, 393, 852, 56)} ${roundedRect(6, 6, 381, 840, 51)}`}\n          fill={`url(#${id})`}\n          fillRule=\"evenodd\"\n        />\n        <path\n          d={`${roundedRect(6, 6, 381, 840, 51)} ${roundedRect(10, 10, 373, 832, 47)}`}\n          fill={tokens.ring}\n          fillRule=\"evenodd\"\n        />\n      </svg>\n      {keys.map(([top, height, side]) => (\n        <span\n          key={top}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute\"\n          style={{\n            [side]: pt(-4),\n            top: pt(top),\n            width: pt(5),\n            height: pt(height),\n            background: `linear-gradient(${side === \"left\" ? 90 : 270}deg, ${tokens.from}, ${tokens.to})`,\n            borderRadius: side === \"left\" ? \"4px 0 0 4px\" : \"0 4px 4px 0\",\n            boxShadow: `${side === \"left\" ? -2 : 2}px 0 6px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.5)`,\n          }}\n        />\n      ))}\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute\"\n        style={{\n          ...glass,\n          boxShadow:\n            \"inset 0 0 0 1px rgba(255,255,255,0.08), inset 0 0 24px rgba(255,255,255,0.05)\",\n          background:\n            \"linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 35%, rgba(255,255,255,0) 65%, rgba(255,255,255,0.05) 100%)\",\n        }}\n      />\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute left-1/2 -translate-x-1/2 bg-black\"\n        style={{\n          top: pt(21),\n          width: pt(126),\n          height: pt(37),\n          borderRadius: pt(20),\n        }}\n      />\n    </span>\n  );\n}\n\nconst white = \"#FFFFFF\";\nconst soft = \"rgba(255,255,255,0.68)\";\n\nfunction Wallet() {\n  const rows = [\n    [\"Coffee Lab\", \"−4.60\"],\n    [\"Rent share\", \"−640.00\"],\n    [\"Refund\", \"+22.40\"],\n    [\"Grocer\", \"−38.15\"],\n  ];\n  return (\n    <div\n      className=\"flex h-full flex-col p-[1.5em] pt-[3.6em]\"\n      style={{ background: \"#101014\", color: white }}\n    >\n      <p className=\"m-0 text-[1.05em]\" style={{ color: soft }}>\n        Good morning\n      </p>\n      <div\n        className=\"mt-[1em] rounded-[1.5em] p-[1.3em]\"\n        style={{ background: \"linear-gradient(140deg,#6D5EF5,#C36BEA)\" }}\n      >\n        <p className=\"m-0 text-[0.95em]\" style={{ color: soft }}>\n          Balance\n        </p>\n        <p className=\"m-0 mt-[0.2em] text-[2.3em] font-semibold tracking-[-0.03em]\">\n          $12,480\n        </p>\n      </div>\n      <div className=\"mt-[1.1em] flex flex-col gap-[0.9em]\">\n        {rows.map(([name, amount]) => (\n          <div\n            key={name}\n            className=\"flex items-center justify-between text-[1.05em]\"\n          >\n            <span>{name}</span>\n            <span style={{ color: amount[0] === \"+\" ? \"#7CF0B4\" : soft }}>\n              {amount}\n            </span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction Activity() {\n  const bars = [46, 72, 58, 88, 64, 96, 52];\n  return (\n    <div\n      className=\"flex h-full flex-col p-[1.5em] pt-[3.6em]\"\n      style={{ background: \"#0E2B26\", color: white }}\n    >\n      <p className=\"m-0 text-[1.05em]\" style={{ color: soft }}>\n        This week\n      </p>\n      <p className=\"m-0 mt-[0.2em] text-[2.3em] font-semibold tracking-[-0.03em]\">\n        38.2 km\n      </p>\n      <div className=\"mt-[1.4em] flex h-[13em] items-end justify-between gap-[0.5em]\">\n        {bars.map((h, i) => (\n          <span\n            key={i}\n            className=\"w-full rounded-[0.5em]\"\n            style={{\n              height: `${h}%`,\n              background: i === 5 ? \"#7CF0B4\" : \"rgba(124,240,180,0.3)\",\n            }}\n          />\n        ))}\n      </div>\n      <div\n        className=\"mt-[1.3em] rounded-[1.3em] p-[1em]\"\n        style={{ background: \"rgba(255,255,255,0.08)\" }}\n      >\n        <p className=\"m-0 text-[0.95em]\" style={{ color: soft }}>\n          Best day\n        </p>\n        <p className=\"m-0 text-[1.3em] font-semibold\">Saturday, 9.6 km</p>\n      </div>\n    </div>\n  );\n}\n\nfunction Today() {\n  const items = [\n    [\"09:00\", \"Design review\", \"#FFB86B\"],\n    [\"11:30\", \"Lunch with Mira\", \"#7CC7FF\"],\n    [\"14:00\", \"Pick up parcel\", \"#7CF0B4\"],\n    [\"18:15\", \"Climbing\", \"#FF8FA3\"],\n  ];\n  return (\n    <div\n      className=\"flex h-full flex-col p-[1.5em] pt-[3.6em]\"\n      style={{ background: \"#F6F1E7\", color: \"#1C1A16\" }}\n    >\n      <p className=\"m-0 text-[1.05em]\" style={{ color: \"rgba(28,26,22,0.6)\" }}>\n        Thursday\n      </p>\n      <p className=\"m-0 text-[3.6em] leading-[1.05] font-semibold tracking-[-0.04em]\">\n        Today\n      </p>\n      <div className=\"mt-[1.1em] flex flex-col gap-[0.7em]\">\n        {items.map(([time, name, color]) => (\n          <div\n            key={name}\n            className=\"rounded-[1.1em] p-[0.9em] pl-[1.1em]\"\n            style={{ background: white, borderLeft: `0.35em solid ${color}` }}\n          >\n            <p\n              className=\"m-0 text-[0.9em]\"\n              style={{ color: \"rgba(28,26,22,0.55)\" }}\n            >\n              {time}\n            </p>\n            <p className=\"m-0 text-[1.15em] font-semibold\">{name}</p>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction Player() {\n  return (\n    <div\n      className=\"flex h-full flex-col p-[1.5em] pt-[3.6em]\"\n      style={{ background: \"#2A1020\", color: white }}\n    >\n      <div\n        className=\"aspect-square w-full rounded-[1.5em]\"\n        style={{\n          background:\n            \"radial-gradient(circle at 30% 25%,#FFD08A,#FF6F61 46%,#7A1E5A 100%)\",\n        }}\n      />\n      <p className=\"m-0 mt-[1.1em] text-[1.5em] font-semibold tracking-[-0.02em]\">\n        Slow Harbour\n      </p>\n      <p className=\"m-0 text-[1.05em]\" style={{ color: soft }}>\n        Night Ferry\n      </p>\n      <div\n        className=\"mt-[1.1em] h-[0.35em] rounded-full\"\n        style={{ background: \"rgba(255,255,255,0.2)\" }}\n      >\n        <div\n          className=\"h-full w-[62%] rounded-full\"\n          style={{ background: white }}\n        />\n      </div>\n      <div className=\"mt-[1.3em] flex items-center justify-center gap-[1.8em]\">\n        <span\n          className=\"size-[1.5em] rounded-[0.4em]\"\n          style={{ background: soft }}\n        />\n        <span\n          className=\"grid size-[4em] place-items-center rounded-full\"\n          style={{ background: white }}\n        >\n          <span\n            className=\"block h-[1.4em] w-[1.1em]\"\n            style={{\n              background: \"#2A1020\",\n              clipPath: \"polygon(0 0,100% 50%,0 100%)\",\n            }}\n          />\n        </span>\n        <span\n          className=\"size-[1.5em] rounded-[0.4em]\"\n          style={{ background: soft }}\n        />\n      </div>\n    </div>\n  );\n}\n\nfunction Route() {\n  return (\n    <div\n      className=\"relative h-full overflow-hidden\"\n      style={{ background: \"#DDE7EE\", color: \"#14222B\" }}\n    >\n      <svg\n        viewBox=\"0 0 220 470\"\n        preserveAspectRatio=\"xMidYMid slice\"\n        aria-hidden=\"true\"\n        className=\"absolute inset-0 size-full\"\n      >\n        <path d=\"M0 330 220 250V470H0Z\" fill=\"#BFE0D0\" />\n        <path d=\"M150 0h70v150l-70-30Z\" fill=\"#B9D8EE\" />\n        <g stroke=\"#FFFFFF\" strokeWidth=\"9\" fill=\"none\">\n          <path d=\"M-10 120 230 70M-10 250 230 190M60-10 110 480M170-10 150 480\" />\n        </g>\n        <path\n          d=\"M72 372c18-60 62-52 66-106s-44-54-40-112 46-44 50-84\"\n          stroke=\"#2F6BFF\"\n          strokeWidth=\"6\"\n          fill=\"none\"\n          strokeLinecap=\"round\"\n        />\n        <circle\n          cx=\"72\"\n          cy=\"372\"\n          r=\"9\"\n          fill=\"#FFFFFF\"\n          stroke=\"#2F6BFF\"\n          strokeWidth=\"5\"\n        />\n        <circle cx=\"148\" cy=\"70\" r=\"10\" fill=\"#2F6BFF\" />\n      </svg>\n      <div\n        className=\"absolute inset-x-[1.2em] bottom-[1.2em] rounded-[1.4em] p-[1.1em]\"\n        style={{\n          background: white,\n          boxShadow: \"0 1em 2em -1em rgba(20,34,43,.4)\",\n        }}\n      >\n        <p className=\"m-0 text-[2em] font-semibold tracking-[-0.03em]\">\n          14 min\n        </p>\n        <p className=\"m-0 text-[1.05em]\" style={{ color: \"rgba(20,34,43,.6)\" }}>\n          Arrive 09:42 by bike\n        </p>\n      </div>\n    </div>\n  );\n}\n\nconst DEFAULT_SCREENS: PhoneScreen[] = [\n  { label: \"Activity screen\", content: <Activity /> },\n  { label: \"Wallet screen\", content: <Wallet /> },\n  { label: \"Today screen\", content: <Today /> },\n  { label: \"Music screen\", content: <Player /> },\n  { label: \"Route screen\", content: <Route /> },\n];\n\nfunction Action({\n  action,\n  fill,\n  color,\n}: {\n  action: { label: string; href?: string; onClick?: () => void };\n  fill: string;\n  color: string;\n}) {\n  const cls =\n    \"inline-flex h-11 cursor-pointer items-center rounded-full px-6 text-[14px] font-semibold no-underline transition-opacity hover:opacity-85\";\n  return action.href ? (\n    <a href={action.href} className={cls} style={{ background: fill, color }}>\n      {action.label}\n    </a>\n  ) : (\n    <button\n      type=\"button\"\n      onClick={action.onClick}\n      className={cls}\n      style={{ background: fill, color }}\n    >\n      {action.label}\n    </button>\n  );\n}\n\nexport function PhoneFanHero({\n  theme = \"dark\",\n  eyebrow = \"Now on iPhone and Android\",\n  title = \"Your whole day, in one pocket\",\n  description = \"Money, plans, music and the way home, without switching apps.\",\n  primaryAction = { label: \"Get the app\" },\n  secondaryAction = { label: \"See the tour\" },\n  screens = DEFAULT_SCREENS,\n  spread = 9,\n  frameColor = \"Natural Titanium\",\n  minHeight = 720,\n  className,\n  style,\n  ...props\n}: PhoneFanHeroProps) {\n  const pal = PALETTES[theme];\n  const rootRef = React.useRef<HTMLElement>(null);\n  const middle = (screens.length - 1) / 2;\n  const [active, setActive] = React.useState<number | null>(null);\n  const [fanned, setFanned] = React.useState(false);\n\n  // The phones start as one stack and open out the first time they are seen.\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      ([entry]) => {\n        if (!entry.isIntersecting) return;\n        io.disconnect();\n        setFanned(true);\n      },\n      { threshold: 0.2 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  return (\n    <section\n      ref={rootRef}\n      onPointerLeave={(e) => {\n        if (e.pointerType === \"mouse\") setActive(null);\n      }}\n      className={cn(\"@container relative w-full overflow-hidden\", className)}\n      style={\n        {\n          \"--h\": `${minHeight}px`,\n          \"--pw\": \"clamp(128px, 22cqw, 250px)\",\n          background: pal.bg,\n          color: pal.text,\n          fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div className=\"relative flex min-h-[680px] flex-col items-center @[640px]:min-h-[var(--h)]\">\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 bottom-0 h-3/4\"\n          style={{\n            background: `radial-gradient(60% 70% at 50% 100%, ${pal.glow}, transparent 75%)`,\n          }}\n        />\n        <div className=\"relative z-20 flex flex-col items-center px-5 pt-11 text-center @[640px]:pt-14\">\n          <p\n            className=\"m-0 text-[13.5px] font-medium\"\n            style={{ color: pal.sub }}\n          >\n            {eyebrow}\n          </p>\n          <h1 className=\"m-0 mt-3 max-w-[14ch] text-[38px] leading-[1.03] font-medium tracking-[-0.035em] @[640px]:max-w-[18ch] @[640px]:text-[56px]\">\n            {title}\n          </h1>\n          <p\n            className=\"m-0 mt-3 max-w-[40ch] text-[15.5px] leading-snug\"\n            style={{ color: pal.sub }}\n          >\n            {description}\n          </p>\n          <div className=\"mt-5 flex flex-wrap justify-center gap-2.5\">\n            {primaryAction && (\n              <Action\n                action={primaryAction}\n                fill={pal.btn}\n                color={pal.btnText}\n              />\n            )}\n            {secondaryAction && (\n              <Action\n                action={secondaryAction}\n                fill={pal.ghost}\n                color={pal.text}\n              />\n            )}\n          </div>\n        </div>\n\n        <div\n          role=\"group\"\n          aria-label=\"App screens\"\n          className=\"absolute inset-x-0 bottom-0 h-0\"\n        >\n          {screens.map((screen, i) => {\n            const d = i - middle;\n            const on = active === i;\n            const push =\n              active === null || on ? 0 : Math.sign(i - active) * 0.16;\n            const x = fanned ? d * 0.76 + push : 0;\n            const y = fanned ? 1.02 + d * d * 0.05 - (on ? 0.24 : 0) : 1.3;\n            const r = fanned ? d * spread * (on ? 0.45 : 1) : 0;\n            const depth = active === null ? Math.abs(d) : Math.abs(i - active);\n            return (\n              <button\n                key={screen.label}\n                type=\"button\"\n                aria-label={screen.label}\n                aria-pressed={on}\n                onPointerEnter={(e) => {\n                  if (e.pointerType === \"mouse\") setActive(i);\n                }}\n                onFocus={() => setActive(i)}\n                onClick={() => setActive(on ? null : i)}\n                className=\"absolute bottom-0 left-1/2 block cursor-pointer p-0 text-left outline-none motion-safe:transition-transform motion-safe:duration-[650ms] motion-safe:ease-[cubic-bezier(0.2,0.9,0.25,1.05)]\"\n                style={{\n                  width: \"var(--pw)\",\n                  height: \"calc(var(--pw) * 2.168)\",\n                  fontSize: \"calc(var(--pw) / 22)\",\n                  zIndex: 10 - Math.round(depth),\n                  transformOrigin: \"50% 100%\",\n                  transform: `translateX(calc(-50% + var(--pw) * ${x.toFixed(3)})) translateY(calc(var(--pw) * ${(2.236 - y).toFixed(3)} * 0.5)) rotate(${r.toFixed(2)}deg)`,\n                  transitionDelay:\n                    fanned && active === null ? \"0ms\" : undefined,\n                }}\n              >\n                <PhoneFrame color={frameColor}>\n                  {screen.image ? (\n                    // eslint-disable-next-line @next/next/no-img-element\n                    <img\n                      src={screen.image}\n                      alt=\"\"\n                      draggable={false}\n                      className=\"size-full object-cover select-none\"\n                    />\n                  ) : (\n                    screen.content\n                  )}\n                </PhoneFrame>\n              </button>\n            );\n          })}\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}