{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "project-explorer",
  "type": "registry:ui",
  "title": "Interactive Project Explorer",
  "description": "An IDE-style project showcase with collapsible year folders, status badges, and floating cursor image hover previews.",
  "author": "Aditya Ojha <https://akoder.xyz>",
  "categories": [
    "portfolio",
    "projects",
    "showcase",
    "motion"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "meta": {
    "docs": "https://akoder.xyz/components/project-explorer",
    "source": "https://github.com/AdityaKodez/adityaojha/blob/main/components/project-explorer.tsx"
  },
  "files": [
    {
      "path": "components/project-explorer.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n  ArrowUpRight,\n  ImageIcon,\n} from \"lucide-react\";\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  useSpring,\n} from \"motion/react\";\nimport Image from \"next/image\";\nimport Link from \"next/link\";\nimport { useCallback, useEffect, useId, useMemo, useState, useSyncExternalStore } from \"react\";\n\nexport type ProjectStatus = \"building\" | \"new\" | \"shipped\";\n\nexport interface ProjectExplorerItem {\n  id: string;\n  title: string;\n  year: number;\n  description?: string;\n  category?: string;\n  status?: ProjectStatus;\n  href?: string;\n  liveUrl?: string;\n  githubUrl?: string;\n  image?: string;\n  imageAlt?: string;\n  showImage?: boolean;\n  enabled?: boolean;\n  order?: number;\n}\n\nconst defaultSampleProjects: ProjectExplorerItem[] = [\n  {\n    id: \"zeno\",\n    title: \"Zeno — AI Assistant for PostgreSQL\",\n    year: 2025,\n    status: \"building\",\n    category: \"ai-tool\",\n    href: \"https://zeno.example.com\",\n    image: \"/zeno.png\",\n  },\n  {\n    id: \"gridly\",\n    title: \"Gridly — Modern UI Component Library\",\n    year: 2025,\n    status: \"new\",\n    category: \"design-system\",\n    href: \"https://gridly.example.com\",\n  },\n  {\n    id: \"rixel\",\n    title: \"Rixel — High Performance Pixel Canvas\",\n    year: 2024,\n    status: \"shipped\",\n    category: \"webgl\",\n    href: \"https://rixel.example.com\",\n    image: \"/rixel.png\",\n  },\n  {\n    id: \"aura\",\n    title: \"Aura — Ambient Audio Workspace\",\n    year: 2024,\n    status: \"shipped\",\n    category: \"audio\",\n    href: \"https://aura.example.com\",\n  },\n];\n\nconst HOVER_QUERY = \"(hover: hover) and (pointer: fine)\";\n\nfunction subscribeHoverCapability(callback: () => void) {\n  const mql = window.matchMedia(HOVER_QUERY);\n  mql.addEventListener(\"change\", callback);\n  return () => mql.removeEventListener(\"change\", callback);\n}\n\nconst getHoverSnapshot = () => window.matchMedia(HOVER_QUERY).matches;\nconst getServerSnapshot = () => false;\n\nconst PREVIEW_WIDTH = 300;\nconst PREVIEW_HEIGHT = 240;\nconst PAPER_EDGE =\n  \"polygon(1% 2%, 12% 0.5%, 25% 1.5%, 38% 0%, 54% 1%, 69% 0.5%, 83% 1.5%, 98% 0%, 99% 14%, 98.5% 31%, 100% 48%, 99% 65%, 99.5% 82%, 98% 99%, 84% 98%, 70% 100%, 55% 98.5%, 40% 99.5%, 25% 98%, 11% 99.5%, 0% 98%, 1% 82%, 0% 65%, 1.5% 48%, 0.5% 31%, 1% 15%)\";\nconst PAPER_TEXTURE = {\n  backgroundImage:\n    \"radial-gradient(var(--foreground, #171717) 0.45px, transparent 0.65px)\",\n  backgroundSize: \"3px 3px\",\n};\n\nfunction PaperFolderIcon({\n  open,\n  className,\n}: {\n  open: boolean;\n  className?: string;\n}) {\n  const patternId = useId();\n  const silhouette = \"m4 7 15-2 5 5 17-1 2 5 3 1-6 21-33 1-3-5Z\";\n  const front = open\n    ? \"M4 17 15 16 18 18 43 15 37 33 8 34Z\"\n    : \"M7 15 18 14 21 16 39 15 38 33 8 34Z\";\n\n  return (\n    <svg\n      viewBox=\"0 0 48 40\"\n      aria-hidden=\"true\"\n      focusable=\"false\"\n      color=\"var(--cutout-ink, var(--foreground))\"\n      className={cn(\n        \"h-8 w-10 shrink-0 overflow-visible\",\n        \"[--cutout-paper:var(--background)] dark:[--cutout-paper:var(--foreground)] dark:[--cutout-ink:var(--background)]\",\n        className,\n      )}\n      fill=\"none\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    >\n      <defs>\n        <pattern\n          id={patternId}\n          width=\"3\"\n          height=\"3\"\n          patternUnits=\"userSpaceOnUse\"\n        >\n          <circle cx=\"1\" cy=\"1\" r=\"0.5\" className=\"fill-current opacity-30\" />\n        </pattern>\n      </defs>\n      <g stroke=\"currentColor\">\n        <path\n          d={silhouette}\n          transform=\"translate(1 2)\"\n          fill=\"currentColor\"\n          strokeWidth=\"4\"\n          opacity=\"0.1\"\n        />\n        <path\n          d={silhouette}\n          fill=\"var(--cutout-paper, var(--background))\"\n          stroke=\"var(--cutout-paper, var(--background))\"\n          strokeWidth=\"4\"\n        />\n        <path\n          d={silhouette}\n          fill=\"color-mix(in oklch, var(--chart-2, #3b82f6) 14%, var(--cutout-paper, var(--background)))\"\n        />\n        {open && (\n          <path\n            d=\"m7 12 12-2 5 5 15-1-1 19-29 2Z\"\n            fill=\"currentColor\"\n            fillOpacity=\"0.12\"\n            strokeWidth=\"1\"\n          />\n        )}\n        <path\n          d=\"m8 10 9-1 3 3-12 1Z\"\n          fill=\"var(--chart-2, #3b82f6)\"\n          fillOpacity=\"0.85\"\n          strokeWidth=\"0.8\"\n        />\n        <path\n          d={front}\n          fill=\"var(--cutout-paper, var(--background))\"\n          strokeWidth=\"1.2\"\n        />\n        <path d={front} fill={`url(#${patternId})`} stroke=\"none\" />\n        <path\n          d=\"m12 21 10-1v4l-10 1Z\"\n          fill=\"var(--chart-1, #f97316)\"\n          fillOpacity=\"0.7\"\n          stroke=\"none\"\n        />\n        <path\n          d=\"m12 28 20-1m-20 3 14-1\"\n          strokeWidth=\"0.7\"\n          opacity=\"0.55\"\n        />\n      </g>\n    </svg>\n  );\n}\n\nfunction StatusBadge({ status }: { status: ProjectStatus }) {\n  if (status === \"shipped\") return null;\n\n  if (status === \"building\") {\n    return (\n      <span className=\"inline-flex shrink-0 items-center gap-1.5 rounded-sm bg-blue-500/10 px-1.5 py-0.5 font-sans text-[10px] leading-none text-blue-600 dark:text-blue-400\">\n        <span className=\"relative flex size-1.5\">\n          <span className=\"absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-500 opacity-60 motion-reduce:animate-none\" />\n          <span className=\"relative inline-flex size-1.5 rounded-full bg-blue-500\" />\n        </span>\n        building&hellip;\n      </span>\n    );\n  }\n\n  return (\n    <span className=\"inline-flex shrink-0 items-center rounded-sm bg-amber-500/10 px-1.5 py-0.5 font-sans text-[10px] leading-none text-amber-600 dark:text-amber-400\">\n      new\n    </span>\n  );\n}\n\ninterface PreviewHandlers {\n  onPreviewStart: (project: ProjectExplorerItem, anchor?: DOMRect) => void;\n  onPreviewEnd: () => void;\n  showHoverPreview: boolean;\n  onProjectClick?: (project: ProjectExplorerItem, targetType: \"case_study\" | \"external_url\", url: string) => void;\n}\n\nfunction WorkRow({\n  project,\n  onPreviewStart,\n  onPreviewEnd,\n  showHoverPreview,\n  onProjectClick,\n}: { project: ProjectExplorerItem } & PreviewHandlers) {\n  const [name, subtitle] = project.title.split(\" — \");\n  const href = project.href ?? project.liveUrl ?? (project.id ? `/project/${project.id}` : \"#\");\n  const isExternal = Boolean(\n    project.liveUrl ||\n      (project.href &&\n        (project.href.startsWith(\"http://\") ||\n          project.href.startsWith(\"https://\"))),\n  );\n\n  const handleClick = () => {\n    onProjectClick?.(project, isExternal ? \"external_url\" : \"case_study\", href);\n  };\n\n  return (\n    <li className=\"relative\">\n      <Link\n        href={href}\n        onClick={handleClick}\n        {...(isExternal\n          ? { target: \"_blank\", rel: \"noopener noreferrer\" }\n          : {})}\n        onMouseEnter={\n          showHoverPreview ? () => onPreviewStart(project) : undefined\n        }\n        onMouseLeave={showHoverPreview ? onPreviewEnd : undefined}\n        onFocus={\n          showHoverPreview\n            ? (event) =>\n                onPreviewStart(\n                  project,\n                  event.currentTarget.getBoundingClientRect(),\n                )\n            : undefined\n        }\n        onBlur={showHoverPreview ? onPreviewEnd : undefined}\n        className=\"group micro-transition flex min-h-11 items-center gap-2 rounded-sm px-3 py-2 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/20\"\n      >\n        <span className=\"min-w-0 flex-1 truncate text-sm font-medium transition-colors group-hover:text-primary group-focus-visible:text-primary\">\n          {subtitle ? (\n            <>\n                <span className=\"inline font-medium text-foreground group-hover:text-primary group-focus-visible:text-primary\">\n                {name}\n              </span>\n              <span className=\"ml-2 inline font-normal text-muted-foreground md:ml-4\">\n                {subtitle}\n              </span>\n            </>\n          ) : (\n            name\n          )}\n        </span>\n\n        {project.status ? <StatusBadge status={project.status} /> : null}\n\n        <ArrowUpRight\n          aria-hidden=\"true\"\n          className=\"size-3.5 shrink-0 text-muted-foreground/30 transition-all duration-200 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-primary group-focus-visible:-translate-y-0.5 group-focus-visible:translate-x-0.5 group-focus-visible:text-primary\"\n        />\n      </Link>\n    </li>\n  );\n}\n\nexport type ProjectExplorerProps = {\n  /** The list of projects to display. If omitted, sample projects will be shown. */\n  projects?: ProjectExplorerItem[];\n  /** Section heading text. Default: \"Featured Projects\". */\n  title?: string;\n  /** Hide the section label when the explorer lives inside an already-labelled surface.\n   *  Also drops the section's top rule. */\n  showHeading?: boolean;\n  /** Choose whether every year or only the most recent year starts expanded. */\n  defaultOpen?: \"all\" | \"latest\";\n  /** Enable or disable the floating cursor hover image preview card. Default: true */\n  showHoverPreview?: boolean;\n  /** Optional callback fired when a project link is clicked. */\n  onProjectClick?: (project: ProjectExplorerItem, targetType: \"case_study\" | \"external_url\", url: string) => void;\n  /** Optional callback fired when a year folder is expanded or collapsed. */\n  onYearToggle?: (year: number, action: \"expand\" | \"collapse\") => void;\n  /** Optional DOM id for the section container */\n  id?: string;\n  /** Additional classes for the container section */\n  className?: string;\n};\n\nexport function ProjectExplorer({\n  projects = defaultSampleProjects,\n  title = \"Featured Projects\",\n  showHeading = true,\n  defaultOpen = \"all\",\n  showHoverPreview = true,\n  id,\n  onProjectClick,\n  onYearToggle,\n  className,\n}: ProjectExplorerProps) {\n  const [activeProject, setActiveProject] = useState<ProjectExplorerItem | null>(null);\n\n  const projectsByYear = useMemo(() => {\n    const enabledProjects = projects\n      .filter((item) => item.enabled !== false)\n      .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));\n\n    return enabledProjects\n      .reduce<{ year: number; projects: ProjectExplorerItem[] }[]>((groups, project) => {\n        const group = groups.find((g) => g.year === project.year);\n        if (group) {\n          group.projects.push(project);\n        } else {\n          groups.push({ year: project.year, projects: [project] });\n        }\n        return groups;\n      }, [])\n      .sort((a, b) => b.year - a.year);\n  }, [projects]);\n\n  const [openYears, setOpenYears] = useState<Record<number, boolean>>(() => {\n    const initial: Record<number, boolean> = {};\n    projectsByYear.forEach((group, index) => {\n      initial[group.year] = defaultOpen === \"all\" || index === 0;\n    });\n    return initial;\n  });\n\n  const toggleYear = useCallback((year: number) => {\n    setOpenYears((prev) => {\n      const willBeOpen = !prev[year];\n      onYearToggle?.(year, willBeOpen ? \"expand\" : \"collapse\");\n      return {\n        ...prev,\n        [year]: willBeOpen,\n      };\n    });\n  }, [onYearToggle]);\n\n  const canHover = useSyncExternalStore(\n    subscribeHoverCapability,\n    getHoverSnapshot,\n    getServerSnapshot,\n  );\n  const prefersReducedMotion = useReducedMotion();\n\n  const springX = useSpring(0, { stiffness: 260, damping: 26, mass: 0.6 });\n  const springY = useSpring(0, { stiffness: 260, damping: 26, mass: 0.6 });\n\n  useEffect(() => {\n    const hide = () => setActiveProject(null);\n    window.addEventListener(\"scroll\", hide, { passive: true });\n    return () => window.removeEventListener(\"scroll\", hide);\n  }, []);\n\n  const handleMouseMove = useCallback(\n    (event: React.MouseEvent) => {\n      if (!showHoverPreview || !activeProject) return;\n      const flip = event.clientX > window.innerWidth - PREVIEW_WIDTH - 48;\n      springX.set(event.clientX + (flip ? -(PREVIEW_WIDTH + 24) : 24));\n      springY.set(\n        Math.max(\n          16,\n          Math.min(\n            event.clientY - PREVIEW_HEIGHT / 2,\n            window.innerHeight - PREVIEW_HEIGHT - 24,\n          ),\n        ),\n      );\n    },\n    [springX, springY, showHoverPreview, activeProject],\n  );\n\n  const handlePreviewStart = useCallback(\n    (project: ProjectExplorerItem, anchor?: DOMRect) => {\n      if (!showHoverPreview) return;\n      setActiveProject(project);\n      if (anchor) {\n        const flip = anchor.right > window.innerWidth - PREVIEW_WIDTH - 48;\n        springX.set(\n          flip ? anchor.left - PREVIEW_WIDTH - 16 : anchor.right + 16,\n        );\n        springY.set(\n          Math.max(\n            16,\n            Math.min(anchor.top, window.innerHeight - PREVIEW_HEIGHT - 24),\n          ),\n        );\n      }\n    },\n    [springX, springY, showHoverPreview],\n  );\n\n  const handlePreviewEnd = useCallback(() => setActiveProject(null), []);\n\n  const showPreview = showHoverPreview && canHover && !prefersReducedMotion && Boolean(activeProject);\n\n  const hasImage = Boolean(\n    activeProject?.image && activeProject?.showImage !== false,\n  );\n\n  return (\n    <section\n      id={id}\n      className={cn(showHeading && \"border-t border-dashed\", \"pt-6\", className)}\n    >\n      {showHeading ? (\n        <h2 className=\"no-js-visible section-heading mb-3\">\n          {title}\n        </h2>\n      ) : null}\n\n      <div\n        className=\"flex flex-col gap-5 px-4 sm:px-6\"\n        onMouseMove={handleMouseMove}\n        onMouseLeave={handlePreviewEnd}\n      >\n        {projectsByYear.map((group) => {\n          const isOpen = openYears[group.year] ?? true;\n\n          return (\n            <div key={group.year}>\n              <button\n                type=\"button\"\n                onClick={() => toggleYear(group.year)}\n                aria-expanded={isOpen}\n                className=\"group mb-1 flex min-h-10 cursor-pointer select-none items-center gap-1.5 rounded-sm px-1 py-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/40\"\n              >\n                <PaperFolderIcon\n                  open={isOpen}\n                  className=\"-rotate-6 transition-transform duration-200 motion-safe:group-hover:-translate-y-0.5 motion-safe:group-hover:-rotate-12 motion-safe:group-focus-visible:-translate-y-0.5 motion-safe:group-focus-visible:-rotate-12 motion-reduce:rotate-0 motion-reduce:transition-none\"\n                />\n                <span className=\"relative isolate -rotate-2 px-2.5 py-1 font-serif text-xl italic leading-none text-foreground transition-transform duration-200 motion-safe:group-hover:rotate-0 motion-safe:group-focus-visible:rotate-0 motion-reduce:rotate-0 motion-reduce:transition-none\">\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"absolute inset-0 -z-10 bg-muted/70\"\n                    style={{ clipPath: PAPER_EDGE }}\n                  />\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"absolute inset-0 -z-10 opacity-[0.08]\"\n                    style={{ ...PAPER_TEXTURE, clipPath: PAPER_EDGE }}\n                  />\n                  {group.year}\n                </span>\n              </button>\n\n              <AnimatePresence initial={false}>\n                {isOpen && (\n                  <motion.ul\n                    initial={{ opacity: 0, height: 0 }}\n                    animate={{ opacity: 1, height: \"auto\" }}\n                    exit={{ opacity: 0, height: 0 }}\n                    transition={{ duration: 0.2, ease: [0.22, 1, 0.36, 1] }}\n                    className=\"ml-2 overflow-hidden\"\n                  >\n                    {group.projects.map((project) => (\n                      <WorkRow\n                        key={project.id}\n                        project={project}\n                        onPreviewStart={handlePreviewStart}\n                        onPreviewEnd={handlePreviewEnd}\n                        showHoverPreview={showHoverPreview}\n                        onProjectClick={onProjectClick}\n                      />\n                    ))}\n                  </motion.ul>\n                )}\n              </AnimatePresence>\n            </div>\n          );\n        })}\n      </div>\n\n      <AnimatePresence>\n        {showPreview && activeProject ? (\n          <motion.div\n            key={activeProject.id}\n            aria-hidden=\"true\"\n            initial={{ opacity: 0, scale: 0.92, rotate: -2 }}\n            animate={{ opacity: 1, scale: 1, rotate: 1.5 }}\n            exit={{ opacity: 0, scale: 0.95, rotate: 0 }}\n            transition={{ duration: 0.18, ease: [0.22, 1, 0.36, 1] }}\n            style={{ x: springX, y: springY }}\n            className=\"pointer-events-none fixed left-0 top-0 z-50 w-[300px] drop-shadow-[2px_4px_6px_var(--border)]\"\n          >\n            <div\n              className=\"relative isolate bg-card p-3 text-card-foreground\"\n              style={{ clipPath: PAPER_EDGE }}\n            >\n              <div\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute inset-0 -z-10 opacity-[0.08]\"\n                style={PAPER_TEXTURE}\n              />\n              <div className=\"relative overflow-hidden bg-muted/40\">\n                {hasImage ? (\n                  <Image\n                    src={activeProject.image!}\n                    alt={activeProject.imageAlt ?? \"\"}\n                    width={600}\n                    height={338}\n                    sizes=\"276px\"\n                    className=\"aspect-video w-full object-cover saturate-[0.7]\"\n                  />\n                ) : (\n                  <div className=\"flex aspect-video w-full items-center justify-center text-muted-foreground\">\n                    <ImageIcon aria-hidden=\"true\" className=\"size-8 stroke-[1.25]\" />\n                  </div>\n                )}\n                <div\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute inset-0 opacity-[0.12] mix-blend-multiply dark:mix-blend-screen\"\n                  style={PAPER_TEXTURE}\n                />\n              </div>\n              <div className=\"flex items-start gap-3 pt-2\">\n                <div className=\"line-clamp-2 min-w-0 flex-1 font-serif text-lg italic leading-5\">\n                  {activeProject.title}\n                </div>\n                <span className=\"shrink-0 pt-1 font-mono text-[10px] text-muted-foreground\">\n                  {activeProject.year}\n                </span>\n              </div>\n            </div>\n          </motion.div>\n        ) : null}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default ProjectExplorer;\n",
      "type": "registry:ui"
    }
  ],
  "docs": "## Installation\n\n```bash\nnpx shadcn@latest add @akoder/project-explorer\n```\n\n## Usage\n\n```tsx\nimport { ProjectExplorer } from \"@/components/project-explorer\";\n\nexport function WorkShowcase() {\n  return <ProjectExplorer />;\n}\n```"
}