{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"iphone-mockup","type":"registry:ui","title":"iPhone Mockup","description":"A realistic, pure-CSS titanium phone frame with dynamic island, side buttons, status bar and a moving glass glare that tilts toward the pointer. Renders any children or an image as the screen.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/ui/iphone-mockup.tsx","type":"registry:ui","content":"\"use client\";\n/* eslint-disable @next/next/no-img-element */\n\nimport { type PointerEvent, type ReactNode } from \"react\";\nimport { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type IphoneColor = \"natural\" | \"black\" | \"white\" | \"blue\" | \"desert\";\n\nexport interface IphoneMockupProps {\n  /** Screen image. Ignored when children are given. */\n  src?: string;\n  alt?: string;\n  /** Anything to render as the screen (390 x 844 aspect). */\n  children?: ReactNode;\n  /** Titanium finish. */\n  color?: IphoneColor;\n  /** Rendered width in px; everything scales with it. */\n  width?: number;\n  /** Tilt toward the pointer in 3D. */\n  tilt?: boolean;\n  /** Max tilt angle in degrees. */\n  tiltAmount?: number;\n  /** Diagonal glass reflection over the screen. */\n  glare?: boolean;\n  /** Status bar text color, or hide it. */\n  statusBar?: \"light\" | \"dark\" | \"none\";\n  /** Time shown in the status bar. */\n  time?: string;\n  className?: string;\n}\n\n// [edge highlight, body, shadow side]\nconst FINISH: Record<IphoneColor, [string, string, string]> = {\n  natural: [\"#d9d4cb\", \"#a9a49b\", \"#6f6b64\"],\n  black: [\"#5a5a5e\", \"#2e2e31\", \"#141416\"],\n  white: [\"#f4f2ee\", \"#d6d3cd\", \"#a19e98\"],\n  blue: [\"#6b7a8f\", \"#3c4859\", \"#1f2631\"],\n  desert: [\"#e2cbb3\", \"#b99c80\", \"#7d654f\"],\n};\n\n// 1em = 1% of the phone's width, so every measurement below scales together.\nconst H = 100 / 0.4884; // real 15 Pro outline ratio\n\nfunction StatusBar({ tone, time }: { tone: \"light\" | \"dark\"; time: string }) {\n  const c = tone === \"light\" ? \"#fff\" : \"#000\";\n  return (\n    <div\n      aria-hidden\n      className=\"pointer-events-none absolute inset-x-0 top-0 z-20 flex items-center justify-between font-semibold\"\n      style={{ height: \"13em\", padding: \"0 8.5em 0 11em\", color: c, fontSize: \"1em\" }}\n    >\n      <span style={{ fontSize: \"4.6em\", letterSpacing: \"-0.01em\" }}>{time}</span>\n      <span className=\"flex items-center\" style={{ gap: \"1.6em\" }}>\n        {/* signal */}\n        <svg viewBox=\"0 0 18 12\" style={{ width: \"5.6em\" }} fill={c}>\n          <rect x=\"0\" y=\"8\" width=\"3\" height=\"4\" rx=\"0.8\" />\n          <rect x=\"5\" y=\"5.5\" width=\"3\" height=\"6.5\" rx=\"0.8\" />\n          <rect x=\"10\" y=\"3\" width=\"3\" height=\"9\" rx=\"0.8\" />\n          <rect x=\"15\" y=\"0\" width=\"3\" height=\"12\" rx=\"0.8\" />\n        </svg>\n        {/* wifi */}\n        <svg viewBox=\"0 0 16 12\" style={{ width: \"5em\" }} fill={c}>\n          <path d=\"M8 2.2c2.4 0 4.6.9 6.2 2.5l1.3-1.4A10.6 10.6 0 0 0 8 .3 10.6 10.6 0 0 0 .5 3.3l1.3 1.4A8.7 8.7 0 0 1 8 2.2Zm0 3.7c1.4 0 2.7.5 3.6 1.4L13 6a7 7 0 0 0-10 0l1.4 1.3c.9-.9 2.2-1.4 3.6-1.4Zm0 3.7c-.5 0-1 .2-1.3.5L8 11.7l1.3-1.6c-.3-.3-.8-.5-1.3-.5Z\" />\n        </svg>\n        {/* battery */}\n        <svg viewBox=\"0 0 27 13\" style={{ width: \"8.4em\" }}>\n          <rect x=\"0.5\" y=\"0.5\" width=\"23\" height=\"12\" rx=\"3.8\" fill=\"none\" stroke={c} strokeOpacity=\"0.4\" />\n          <rect x=\"2\" y=\"2\" width=\"17\" height=\"9\" rx=\"2.4\" fill={c} />\n          <path d=\"M25 4.5v4c.8-.3 1.3-1.1 1.3-2s-.5-1.7-1.3-2Z\" fill={c} fillOpacity=\"0.45\" />\n        </svg>\n      </span>\n    </div>\n  );\n}\n\nexport function IphoneMockup({\n  src,\n  alt = \"\",\n  children,\n  color = \"natural\",\n  width = 300,\n  tilt = true,\n  tiltAmount = 14,\n  glare = true,\n  statusBar = \"light\",\n  time = \"9:41\",\n  className,\n}: IphoneMockupProps) {\n  const reduce = useReducedMotion();\n  const [hi, body, lo] = FINISH[color] ?? FINISH.natural;\n  const px = useMotionValue(0.5);\n  const py = useMotionValue(0.5);\n  const spring = { stiffness: 160, damping: 18, mass: 0.6 };\n  const rx = useSpring(useTransform(py, [0, 1], [tiltAmount, -tiltAmount]), spring);\n  const ry = useSpring(useTransform(px, [0, 1], [-tiltAmount, tiltAmount]), spring);\n  const glareX = useSpring(useTransform(px, [0, 1], [-30, 30]), spring);\n  const glareBg = useMotionTemplate`linear-gradient(118deg, transparent calc(18% + ${glareX}%), rgba(255,255,255,.16) calc(30% + ${glareX}%), rgba(255,255,255,.05) calc(44% + ${glareX}%), transparent calc(45% + ${glareX}%))`;\n  const canTilt = tilt && !reduce;\n\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    if (!canTilt) return;\n    const r = e.currentTarget.getBoundingClientRect();\n    px.set((e.clientX - r.left) / r.width);\n    py.set((e.clientY - r.top) / r.height);\n  };\n  const onLeave = () => {\n    px.set(0.5);\n    py.set(0.5);\n  };\n\n  const metal = `linear-gradient(135deg, ${hi} 0%, ${body} 18%, ${lo} 50%, ${body} 82%, ${hi} 100%)`;\n  const button = (side: \"left\" | \"right\", top: number, h: number) => (\n    <span\n      aria-hidden\n      className=\"absolute\"\n      style={{\n        [side]: \"-0.9em\",\n        top: `${top}em`,\n        width: \"1.4em\",\n        height: `${h}em`,\n        borderRadius: side === \"left\" ? \"0.8em 0 0 0.8em\" : \"0 0.8em 0.8em 0\",\n        background: `linear-gradient(${side === \"left\" ? 90 : 270}deg, ${lo}, ${hi} 55%, ${body})`,\n        boxShadow: \"inset 0 0.2em 0.2em rgba(255,255,255,.25), inset 0 -0.2em 0.2em rgba(0,0,0,.3)\",\n      }}\n    />\n  );\n\n  return (\n    <div\n      className={cn(\"relative shrink-0 select-none\", className)}\n      style={{ width, fontSize: width / 100, perspective: `${width * 4}px` }}\n      onPointerMove={onMove}\n      onPointerLeave={onLeave}\n    >\n      <motion.div\n        className=\"relative\"\n        style={{ width: \"100em\", height: `${H}em`, rotateX: canTilt ? rx : 0, rotateY: canTilt ? ry : 0, transformStyle: \"preserve-3d\" }}\n      >\n        {/* ground shadow */}\n        <div\n          aria-hidden\n          className=\"absolute rounded-[50%] bg-black/50 blur-2xl\"\n          style={{ left: \"10em\", right: \"10em\", bottom: \"-7em\", height: \"10em\", transform: \"translateZ(-40px)\" }}\n        />\n        {button(\"left\", 36, 7)}\n        {button(\"left\", 52, 13)}\n        {button(\"left\", 69, 13)}\n        {button(\"right\", 56, 21)}\n\n        {/* titanium band */}\n        <div\n          className=\"absolute inset-0\"\n          style={{\n            borderRadius: \"17em\",\n            background: metal,\n            padding: \"1.25em\",\n            boxShadow: `0 3em 6em -1em rgba(0,0,0,.55), inset 0 0 0 0.3em ${hi}55, inset 0 0 0.8em 0.35em rgba(0,0,0,.35)`,\n          }}\n        >\n          {/* black glass bezel */}\n          <div\n            className=\"relative size-full bg-black\"\n            style={{ borderRadius: \"15.8em\", padding: \"3.2em\", boxShadow: \"inset 0 0 0 0.25em #1a1a1a\" }}\n          >\n            {/* screen */}\n            <div className=\"relative size-full overflow-hidden bg-neutral-900\" style={{ borderRadius: \"12.6em\", fontSize: \"1em\" }}>\n              <div className=\"absolute inset-0 overflow-hidden\" style={{ fontSize: 16 }}>\n                {children ?? (src ? <img src={src} alt={alt} draggable={false} className=\"size-full object-cover\" /> : null)}\n              </div>\n\n              {statusBar !== \"none\" && <StatusBar tone={statusBar} time={time} />}\n\n              {/* dynamic island */}\n              <div\n                aria-hidden\n                className=\"absolute left-1/2 z-30 -translate-x-1/2 bg-black\"\n                style={{ top: \"2.9em\", width: \"30em\", height: \"8.8em\", borderRadius: \"999px\" }}\n              >\n                <span\n                  className=\"absolute rounded-full\"\n                  style={{\n                    right: \"3em\",\n                    top: \"2.6em\",\n                    width: \"3.6em\",\n                    height: \"3.6em\",\n                    background: \"radial-gradient(circle at 35% 35%, #2b3a5c 0 22%, #0c1220 45%, #050608 70%)\",\n                  }}\n                />\n              </div>\n\n              {/* home indicator */}\n              <div\n                aria-hidden\n                className=\"absolute left-1/2 z-20 -translate-x-1/2 rounded-full\"\n                style={{\n                  bottom: \"2.2em\",\n                  width: \"36em\",\n                  height: \"1.4em\",\n                  background: statusBar === \"dark\" ? \"rgba(0,0,0,.85)\" : \"rgba(255,255,255,.9)\",\n                }}\n              />\n\n              {glare && (\n                <motion.div\n                  aria-hidden\n                  className=\"pointer-events-none absolute inset-0 z-40\"\n                  style={{ background: canTilt ? glareBg : \"linear-gradient(118deg, transparent 18%, rgba(255,255,255,.16) 30%, rgba(255,255,255,.05) 44%, transparent 45%)\" }}\n                />\n              )}\n            </div>\n          </div>\n        </div>\n      </motion.div>\n    </div>\n  );\n}\n"}]}