{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"photo-folder","type":"registry:component","title":"Photo Folder","description":"A frosted-glass folder with your photos tucked inside and a die-cut sticker on the front. Hover it and the photos spring up and fan out one by one, the flap dips open, the glow brightens and the sticker wiggles.","dependencies":["framer-motion"],"files":[{"path":"registry/dot/photo-folder.tsx","type":"registry:component","target":"components/dot/photo-folder.tsx","content":"\"use client\";\n\nimport { useState, type CSSProperties, type ReactNode } from \"react\";\nimport { motion } from \"framer-motion\";\n\nexport type FolderSticker =\n  | \"talisman\"\n  | \"flame\"\n  | \"eye\"\n  | \"burst\"\n  | \"bolt\"\n  | \"bird\"\n  | \"cat\"\n  | \"flower\"\n  | \"fish\"\n  | \"mushroom\"\n  | \"bug\"\n  | \"star\"\n  | \"heart\";\n\nexport interface PhotoFolderProps {\n  /** Photos inside the folder (up to 5 show); without any, soft colour cards stand in */\n  photos?: string[];\n  /** Folder name under the folder */\n  label?: string;\n  /** Number in the pill under the name; defaults to how many photos there are */\n  count?: number;\n  /** Word after the count */\n  countLabel?: string;\n  /** The built-in sticker on the front of the folder; \"none\" hides it */\n  sticker?: FolderSticker | \"none\";\n  /** Your own sticker image (SVG or transparent PNG), used instead of the built-in one */\n  stickerImage?: string;\n  /** Sticker size, 1 is the standard size (0.6–1.6) */\n  stickerSize?: number;\n  /** Tint of the folder */\n  color?: string;\n  /** Colour of the glow under the folder; empty uses the folder colour */\n  glowColor?: string;\n  /** Folder width in px */\n  size?: number;\n  /** A soft glow under the folder that brightens on hover */\n  glow?: boolean;\n  textColor?: string;\n  className?: string;\n  style?: CSSProperties;\n}\n\n// ─── Stickers: die-cut, a thick white edge around a bold drawing ──────────────\n\nconst INK = \"#15131C\";\nconst STICKERS: Record<FolderSticker, ReactNode> = {\n  // A paper charm with brush-stroke marks\n  talisman: (\n    <>\n      <path d=\"M6.5 1.5h11v17.5l-3.5 3.5h-7.5z\" fill=\"#F5E9C8\" />\n      <path d=\"M17.5 19 14 22.5V19z\" fill=\"#D9C79A\" />\n      <circle cx=\"12\" cy=\"6\" r=\"2.6\" fill=\"#E5384B\" stroke=\"none\" />\n      <path d=\"M9 10.5h6M12 9v9M9.5 13.5l5 2.5M14.5 13.5l-5 2.5\" stroke=\"#C81E35\" strokeWidth={1.6} />\n    </>\n  ),\n  // A blue spirit flame\n  flame: (\n    <>\n      <path d=\"M12 2c1 4 6 6.5 6 12a6 6 0 0 1-12 0c0-3 1.6-4.8 3-6 .2 2 1 3 2 3.5C11 9 10.5 5 12 2z\" fill=\"#4C7DFF\" />\n      <path d=\"M12 12.5c.8 1.8 3 2.6 3 5a3 3 0 0 1-6 0c0-1.6 1-2.8 3-5z\" fill=\"#BFD4FF\" />\n    </>\n  ),\n  // A sharp, glowing eye\n  eye: (\n    <>\n      <path d=\"M1.5 12C4.5 6.8 8 4.5 12 4.5s7.5 2.3 10.5 7.5c-3 5.2-6.5 7.5-10.5 7.5S4.5 17.2 1.5 12z\" fill=\"#FFFFFF\" />\n      <circle cx=\"12\" cy=\"12\" r=\"5\" fill=\"#7A3CFF\" />\n      <circle cx=\"12\" cy=\"12\" r=\"2.2\" fill={INK} stroke=\"none\" />\n      <circle cx=\"13.6\" cy=\"10.3\" r=\"1.1\" fill=\"#FFFFFF\" stroke=\"none\" />\n    </>\n  ),\n  // A comic impact burst\n  burst: (\n    <path\n      d=\"m12 1 2.2 5.6 5.6-2.4-2.4 5.6L23 12l-5.6 2.2 2.4 5.6-5.6-2.4L12 23l-2.2-5.6-5.6 2.4 2.4-5.6L1 12l5.6-2.2-2.4-5.6 5.6 2.4z\"\n      fill=\"#FFD23F\"\n    />\n  ),\n  // A lightning strike\n  bolt: <path d=\"M13.5 1.5 4.5 13.5h6l-2 9 9-12h-6z\" fill=\"#FF4D6D\" />,\n  bird: (\n    <>\n      <path d=\"M9 19.5v2M13 19.5v2\" />\n      <circle cx=\"11\" cy=\"13\" r=\"6.5\" fill=\"#FFE27A\" />\n      <path d=\"M17.2 11.2 20.6 12.6l-3.4 1.3z\" fill=\"#FF9F43\" />\n      <circle cx=\"13.6\" cy=\"11\" r=\"0.95\" fill={INK} stroke=\"none\" />\n      <path d=\"M7.2 13.6c1.2 1.8 3.3 2.2 4.9 1.1\" />\n    </>\n  ),\n  cat: (\n    <>\n      <path d=\"M5 9 6 4l3.5 3h5L18 4l1 5c.7 1.2 1 2.4 1 3.6C20 17 16.4 20 12 20s-8-3-8-7.4c0-1.2.3-2.4 1-3.6z\" />\n      <circle cx=\"9.3\" cy=\"12.5\" r=\"0.9\" fill={INK} stroke=\"none\" />\n      <circle cx=\"14.7\" cy=\"12.5\" r=\"0.9\" fill={INK} stroke=\"none\" />\n      <path d=\"M11 15.2h2l-1 1z\" />\n    </>\n  ),\n  flower: (\n    <>\n      <circle cx=\"12\" cy=\"7\" r=\"3\" fill=\"#FFB3D1\" />\n      <circle cx=\"16.8\" cy=\"10.5\" r=\"3\" fill=\"#FFB3D1\" />\n      <circle cx=\"15\" cy=\"16\" r=\"3\" fill=\"#FFB3D1\" />\n      <circle cx=\"9\" cy=\"16\" r=\"3\" fill=\"#FFB3D1\" />\n      <circle cx=\"7.2\" cy=\"10.5\" r=\"3\" fill=\"#FFB3D1\" />\n      <circle cx=\"12\" cy=\"11.8\" r=\"2\" fill=\"#FFD23F\" />\n    </>\n  ),\n  fish: (\n    <>\n      <path d=\"M3 12c2.5-4 6-6 10-6 4 0 7 3 8 6-1 3-4 6-8 6-4 0-7.5-2-10-6z\" fill=\"#7FD3FF\" />\n      <path d=\"M3 12 1 8v8z\" fill=\"#7FD3FF\" />\n      <circle cx=\"16\" cy=\"11\" r=\"1\" fill={INK} stroke=\"none\" />\n    </>\n  ),\n  mushroom: (\n    <>\n      <path d=\"M3 12c0-4.5 4-8 9-8s9 3.5 9 8c0 .6-.4 1-1 1H4c-.6 0-1-.4-1-1z\" fill=\"#FF5C6C\" />\n      <path d=\"M9 13v5a3 3 0 0 0 6 0v-5\" />\n      <circle cx=\"9\" cy=\"8.5\" r=\"1.2\" />\n      <circle cx=\"14.5\" cy=\"7.5\" r=\"1\" />\n    </>\n  ),\n  bug: (\n    <>\n      <ellipse cx=\"12\" cy=\"13.5\" rx=\"5.5\" ry=\"6.5\" fill=\"#FF5C6C\" />\n      <path d=\"M12 7v13M9 4.5 10.5 7M15 4.5 13.5 7M6.5 11H3.5M6.5 15H3.5M17.5 11h3M17.5 15h3\" />\n    </>\n  ),\n  star: <path d=\"m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z\" fill=\"#FFD23F\" />,\n  heart: <path d=\"M12 20s-7.5-4.6-7.5-10A4.2 4.2 0 0 1 12 7.4 4.2 4.2 0 0 1 19.5 10C19.5 15.4 12 20 12 20z\" fill=\"#FF6B9A\" />,\n};\n\nfunction Sticker({ kind, image, size }: { kind?: FolderSticker; image?: string; size: number }) {\n  if (image) {\n    return (\n      // eslint-disable-next-line @next/next/no-img-element -- any image the user passes\n      <img\n        src={image}\n        alt=\"\"\n        draggable={false}\n        style={{ display: \"block\", width: size, height: size, objectFit: \"contain\", filter: \"drop-shadow(0 2px 4px rgba(0,0,0,0.4))\" }}\n      />\n    );\n  }\n  if (!kind || !STICKERS[kind]) return null;\n  const art = STICKERS[kind];\n  return (\n    <svg width={size} height={size} viewBox=\"-2 -2 28 28\" aria-hidden style={{ display: \"block\", overflow: \"visible\", filter: \"drop-shadow(0 3px 4px rgba(0,0,0,0.45))\" }}>\n      {/* The white die-cut edge, then the drawing on top */}\n      <g fill=\"#FFFFFF\" stroke=\"#FFFFFF\" strokeWidth={6} strokeLinejoin=\"round\" strokeLinecap=\"round\">\n        {art}\n      </g>\n      <g fill=\"#FFFFFF\" stroke={INK} strokeWidth={1.6} strokeLinejoin=\"round\" strokeLinecap=\"round\">\n        {art}\n      </g>\n    </svg>\n  );\n}\n\n// ─── Colour helpers ───────────────────────────────────────────────────────────\n\n/**\n * Any CSS colour (hex, rgb(), hsl(), a name, a CSS variable; Framer hands colours over as rgba()) at\n * an opacity, mixed by the browser so it reads every format and the server writes the same thing\n */\nconst fade = (color: string, a: number) => `color-mix(in srgb, ${color} ${Math.round(a * 100)}%, transparent)`;\nconst rgba = ([r, g, b]: [number, number, number], a: number) => `rgba(${r}, ${g}, ${b}, ${a})`;\nconst WHITE: [number, number, number] = [255, 255, 255];\n\n/** Cards that stand in when no photos are given */\nconst PLACEHOLDERS = [\n  \"linear-gradient(150deg, #2B1B6B, #7A3CFF 60%, #FF6BD6)\",\n  \"linear-gradient(150deg, #0B1E5B, #2E6BFF 55%, #8FE3FF)\",\n  \"linear-gradient(150deg, #3A0A2E, #C81E5B 60%, #FFB27A)\",\n  \"linear-gradient(150deg, #101830, #3B4A8C 55%, #B9C6FF)\",\n  \"linear-gradient(150deg, #1D0B3A, #5B2BD6 55%, #4CE0D2)\",\n];\n\nconst spring = { type: \"spring\" as const, stiffness: 260, damping: 20, mass: 0.8 };\n\n/**\n * A frosted-glass folder with photos tucked inside and a die-cut sticker on the front. Hover it (or\n * tap it) and the photos spring up out of the folder and fan out one after another, the front flap\n * dips open, the glow brightens and the sticker wiggles; hovering a photo lifts it a little higher.\n * Your photos, your sticker (one of the built-in die-cut icons or your own image), your colours, name\n * and count.\n */\nexport function PhotoFolder({\n  photos = [],\n  label = \"Dot\",\n  count,\n  countLabel = \"photos\",\n  sticker = \"cat\",\n  stickerImage,\n  stickerSize = 1,\n  color = \"#F4A6C8\",\n  glowColor = \"\",\n  size = 240,\n  glow = true,\n  textColor = \"#F5F5F7\",\n  className,\n  style,\n}: PhotoFolderProps) {\n  const [open, setOpen] = useState(false);\n  const [lifted, setLifted] = useState(-1);\n  const S = Math.max(120, size);\n  const tint = color.trim() || \"#F4A6C8\";\n  const glowTint = glowColor.trim() || tint;\n  const text = textColor.trim() || \"#F5F5F7\";\n  const shown = (photos.length ? photos : PLACEHOLDERS).slice(0, 5);\n  const n = shown.length;\n  const total = count ?? (photos.length || n);\n  const stickerPx = S * 0.17 * Math.max(0.4, Math.min(2, stickerSize));\n\n  const cardW = S * 0.4;\n  const cardH = S * 0.32;\n  const backTop = S * 0.3;\n  const frontTop = S * 0.4;\n  const stageH = S * 0.9;\n\n  return (\n    <div\n      className={className}\n      style={{ position: \"relative\", width: \"100%\", height: \"100%\", display: \"flex\", alignItems: \"center\", justifyContent: \"center\", ...style }}\n    >\n      <div style={{ display: \"flex\", flexDirection: \"column\", alignItems: \"center\", gap: S * 0.07 }}>\n        <motion.div\n          role=\"button\"\n          tabIndex={0}\n          aria-label={`${label}, ${total} ${countLabel}`}\n          aria-expanded={open}\n          onHoverStart={() => setOpen(true)}\n          onHoverEnd={() => {\n            setOpen(false);\n            setLifted(-1);\n          }}\n          onTap={(e) => {\n            // Touch: tap to open and close\n            if ((e as PointerEvent).pointerType !== \"mouse\") setOpen((o) => !o);\n          }}\n          onFocus={() => setOpen(true)}\n          onBlur={() => setOpen(false)}\n          style={{ position: \"relative\", width: S, height: stageH, cursor: \"pointer\", perspective: S * 4, outline: \"none\" }}\n        >\n          {/* Glow: soft at rest, brighter on hover */}\n          {glow && (\n            <motion.div\n              aria-hidden\n              animate={{ opacity: open ? 0.85 : 0.5, scale: open ? 1.12 : 1 }}\n              transition={{ duration: 0.5 }}\n              style={{\n                position: \"absolute\",\n                left: \"8%\",\n                right: \"8%\",\n                top: frontTop + S * 0.12,\n                height: S * 0.5,\n                borderRadius: \"50%\",\n                background: fade(glowTint, 0.75),\n                filter: `blur(${S * 0.16}px)`,\n              }}\n            />\n          )}\n\n          {/* Back of the folder, with its tab */}\n          <div\n            aria-hidden\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              top: backTop,\n              bottom: S * 0.02,\n              borderRadius: S * 0.07,\n              background: `linear-gradient(180deg, ${fade(tint, 0.95)}, ${fade(tint, 0.55)})`,\n              boxShadow: `inset 0 1px 0 ${rgba(WHITE, 0.3)}`,\n            }}\n          />\n          <div\n            aria-hidden\n            style={{\n              position: \"absolute\",\n              left: S * 0.04,\n              top: backTop - S * 0.05,\n              width: S * 0.34,\n              height: S * 0.12,\n              borderRadius: `${S * 0.05}px ${S * 0.05}px 0 0`,\n              background: fade(tint, 0.95),\n            }}\n          />\n\n          {/* Photos: tucked in at rest, springing up and fanning out on hover */}\n          {shown.map((src, i) => {\n            const c = i - (n - 1) / 2;\n            const up = lifted === i;\n            return (\n              <motion.div\n                key={`${src}-${i}`}\n                initial={false}\n                animate={\n                  open\n                    ? { x: c * S * 0.27, y: -S * 0.4 + Math.abs(c) * S * 0.06 - (up ? S * 0.08 : 0), rotate: c * 11, scale: up ? 1.14 : 1.05 }\n                    : { x: c * S * 0.09, y: 0, rotate: c * 5, scale: 1 }\n                }\n                transition={{ ...spring, delay: open ? i * 0.045 : (n - 1 - i) * 0.03 }}\n                onHoverStart={() => setLifted(i)}\n                onHoverEnd={() => setLifted((l) => (l === i ? -1 : l))}\n                style={{\n                  position: \"absolute\",\n                  left: (S - cardW) / 2,\n                  top: frontTop - cardH * 0.62,\n                  width: cardW,\n                  height: cardH,\n                  borderRadius: S * 0.035,\n                  border: `${Math.max(3, S * 0.016)}px solid #FFFFFF`,\n                  background: src.startsWith(\"linear-gradient\") ? src : `#222 center / cover no-repeat url(\"${src}\")`,\n                  boxShadow: \"0 6px 16px rgba(0,0,0,0.4)\",\n                  zIndex: up ? 20 : 2 + i,\n                  transformOrigin: \"50% 100%\",\n                }}\n              />\n            );\n          })}\n\n          {/* Frosted front: dips open on hover */}\n          <motion.div\n            aria-hidden\n            animate={{ rotateX: open ? -16 : 0, y: open ? S * 0.015 : 0 }}\n            transition={spring}\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              top: frontTop,\n              bottom: 0,\n              borderRadius: S * 0.07,\n              background: `linear-gradient(165deg, ${rgba(WHITE, 0.3)}, ${rgba(WHITE, 0.12)} 50%, ${fade(tint, 0.3)})`,\n              backdropFilter: `blur(${Math.round(S * 0.05)}px) saturate(1.3) brightness(1.06)`,\n              WebkitBackdropFilter: `blur(${Math.round(S * 0.05)}px) saturate(1.3) brightness(1.06)`,\n              border: `1px solid ${rgba(WHITE, 0.4)}`,\n              boxShadow: `inset 0 1px 0 ${rgba(WHITE, 0.55)}, 0 10px 30px ${rgba([0, 0, 0], 0.3)}`,\n              transformOrigin: \"50% 100%\",\n              zIndex: 30,\n            }}\n          >\n            <div style={{ position: \"absolute\", left: \"8%\", right: \"8%\", bottom: \"12%\", height: 2, borderRadius: 2, background: rgba(WHITE, 0.3) }} />\n            {(stickerImage || sticker !== \"none\") && (\n              <motion.div\n                animate={open ? { rotate: [-8, 8, -3, -6], scale: [1, 1.12, 1.04, 1.06] } : { rotate: -8, scale: 1 }}\n                transition={{ duration: 0.6 }}\n                style={{ position: \"absolute\", right: \"11%\", bottom: \"20%\" }}\n              >\n                <Sticker kind={sticker === \"none\" ? undefined : sticker} image={stickerImage} size={stickerPx} />\n              </motion.div>\n            )}\n          </motion.div>\n\n        </motion.div>\n\n        {label && <div style={{ color: text, fontSize: S * 0.09, fontWeight: 600, letterSpacing: \"-0.01em\", lineHeight: 1.1 }}>{label}</div>}\n        <div\n          style={{\n            color: fade(text, 0.72),\n            fontSize: S * 0.06,\n            padding: `${S * 0.012}px ${S * 0.04}px`,\n            borderRadius: 999,\n            background: fade(text, 0.1),\n          }}\n        >\n          {total} {countLabel}\n        </div>\n      </div>\n    </div>\n  );\n}\n"}],"docs":"Photo Folder is ready. Props and a live canvas: https://bydot.co/component/photo-folder","meta":{"tier":"free","category":"Interactive","version":"1.0.0"}}