{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "photo-folder",
  "title": "Photo Folder",
  "author": "VenusUI",
  "description": "A folder that opens on hover and fans out the photos inside it.",
  "files": [
    {
      "path": "registry/default/ui/photo-folder.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface PhotoFolderImage {\n  src: string\n  alt: string\n}\n\ninterface PhotoFolderProps extends Omit<React.ComponentProps<\"button\">, \"children\"> {\n  /** Photos inside the folder. The first three to five fan out; more are counted, not shown. */\n  images: PhotoFolderImage[]\n  /** Folder name, shown under it and used as its accessible name. */\n  label: string\n  /** Second line under the name. Defaults to the number of photos. */\n  description?: string\n  /** Folder color: any CSS color. Darker and lighter shades are mixed from it. */\n  color?: string\n  /** Controlled open state. Leave unset to open on hover and toggle on click. */\n  open?: boolean\n  onOpenChange?: (open: boolean) => void\n}\n\nconst MAX_SHOWN = 5\n\n/** Where each photo sits, closed and open: fanned out evenly around the center. */\nfunction photoPlacement(index: number, count: number) {\n  const spread = count === 1 ? 0 : count === 2 ? 10 : 14\n  const t = count === 1 ? 0 : index / (count - 1) - 0.5 // -0.5 … 0.5\n  return {\n    \"--rest-r\": `${t * 8}deg`,\n    \"--rest-y\": \"10%\",\n    \"--open-x\": `${t * 95}%`,\n    \"--open-y\": `${-74 + Math.abs(t) * 20}%`,\n    \"--open-r\": `${t * spread * 2}deg`,\n    transitionDelay: `${index * 35}ms`,\n    zIndex: index + 1,\n  } as React.CSSProperties\n}\n\n/**\n * A folder that opens to fan out the photos inside. It opens while hovered,\n * and a click, tap, Enter or Space keeps it open (or closes it again). It's\n * a button with `aria-expanded`, named after the folder.\n */\nfunction PhotoFolder({\n  images,\n  label,\n  description,\n  color = \"oklch(0.7 0.14 245)\",\n  open: openProp,\n  onOpenChange,\n  className,\n  style,\n  onClick,\n  onPointerEnter,\n  onPointerLeave,\n  ...props\n}: PhotoFolderProps) {\n  const [hovered, setHovered] = React.useState(false)\n  const [pinned, setPinned] = React.useState(false)\n  const open = openProp ?? (hovered || pinned)\n  const shown = images.slice(0, MAX_SHOWN)\n  const descriptionId = React.useId()\n\n  const setPinnedAndNotify = (next: boolean) => {\n    setPinned(next)\n    onOpenChange?.(next)\n  }\n\n  return (\n    <button\n      type=\"button\"\n      data-slot=\"photo-folder\"\n      data-open={open || undefined}\n      aria-expanded={open}\n      aria-describedby={descriptionId}\n      aria-label={`${label}, ${description ?? `${images.length} ${images.length === 1 ? \"photo\" : \"photos\"}`}`}\n      onPointerEnter={(event) => {\n        onPointerEnter?.(event)\n        if (event.pointerType !== \"touch\") {\n          setHovered(true)\n          if (!pinned) onOpenChange?.(true)\n        }\n      }}\n      onPointerLeave={(event) => {\n        onPointerLeave?.(event)\n        if (event.pointerType !== \"touch\") {\n          setHovered(false)\n          if (!pinned) onOpenChange?.(false)\n        }\n      }}\n      onClick={(event) => {\n        onClick?.(event)\n        // With a mouse the folder is already open from hovering, so a click\n        // pins it (or unpins it); with touch or keys it toggles.\n        setPinnedAndNotify(!pinned)\n      }}\n      className={cn(\n        \"group/folder relative inline-flex w-56 flex-col items-center gap-3 rounded-2xl p-2 text-center outline-none select-none\",\n        \"focus-visible:ring-3 focus-visible:ring-ring/50\",\n        className\n      )}\n      style={\n        {\n          \"--folder\": color,\n          \"--folder-back\": `color-mix(in oklch, ${color} 78%, black)`,\n          \"--folder-front-top\": `color-mix(in oklch, ${color} 72%, white)`,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <span aria-hidden=\"true\" className=\"relative block aspect-[5/4] w-full perspective-[800px]\">\n        {/* Back of the folder, with its tab. */}\n        <span className=\"absolute top-0 left-0 h-[16%] w-[42%] rounded-t-[10%_30%] bg-(--folder-back) [clip-path:polygon(0_0,82%_0,100%_100%,0_100%)]\" />\n        <span className=\"absolute inset-x-0 top-[10%] bottom-0 rounded-[7%/9%] bg-(--folder-back)\" />\n\n        {/* Photos, tucked in and peeking over the front until it opens. */}\n        <span className=\"absolute inset-x-[20%] top-[16%] bottom-[18%]\">\n          {shown.map((image, index) => (\n            <span\n              key={image.src}\n              className={cn(\n                \"absolute inset-0 block overflow-hidden rounded-[6%] border-[3px] border-white bg-white shadow-md\",\n                \"transition-transform duration-500 ease-[cubic-bezier(0.34,1.4,0.64,1)] motion-reduce:transition-none\",\n                \"[transform:translate(0,var(--rest-y))_rotate(var(--rest-r))]\",\n                \"group-data-open/folder:[transform:translate(var(--open-x),var(--open-y))_rotate(var(--open-r))]\"\n              )}\n              style={photoPlacement(index, shown.length)}\n            >\n              <img src={image.src} alt=\"\" loading=\"lazy\" decoding=\"async\" className=\"size-full object-cover\" />\n            </span>\n          ))}\n        </span>\n\n        {/* Front flap: tips forward when the folder opens. */}\n        <span\n          className={cn(\n            \"absolute inset-x-0 bottom-0 z-10 h-[72%] origin-bottom rounded-[7%/10%]\",\n            \"bg-linear-to-b from-(--folder-front-top) to-(--folder) shadow-[inset_0_1px_0_rgb(255_255_255/0.45),0_-1px_6px_rgb(0_0_0/0.12)]\",\n            \"transition-transform duration-500 ease-[cubic-bezier(0.34,1.3,0.64,1)] motion-reduce:transition-none\",\n            \"group-data-open/folder:[transform:rotateX(-24deg)]\"\n          )}\n        />\n      </span>\n\n      <span className=\"flex flex-col gap-0.5\">\n        <span className=\"text-sm font-medium text-foreground\">{label}</span>\n        <span className=\"text-xs text-muted-foreground\">\n          {description ?? `${images.length} ${images.length === 1 ? \"photo\" : \"photos\"}`}\n        </span>\n      </span>\n\n      {/* What's in the folder, for screen readers. */}\n      <span id={descriptionId} className=\"sr-only\">\n        {shown.map((image) => image.alt).join(\". \")}\n      </span>\n    </button>\n  )\n}\n\nexport { PhotoFolder }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "cards",
    "animations"
  ],
  "type": "registry:ui"
}