{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dock-motion",
  "title": "Dock (Motion)",
  "author": "AlgorizeTech",
  "description": "A macOS-style dock where icons magnify as the pointer approaches. Use it for app launchers and playful navigation bars.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/motion/DockBlock.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n  AnimatePresence,\n  motion,\n  useMotionValue,\n  type MotionValue,\n  useSpring,\n  useTransform,\n} from \"motion/react\";\nimport React, { useEffect, useRef, useState } from \"react\";\n\nexport interface DockItem {\n  id: string;\n  label: string;\n  icon: React.ReactNode;\n  onClick?: () => void;\n  isActive?: boolean;\n  badge?: string | number;\n}\n\nexport interface DockProps extends React.HTMLAttributes<HTMLDivElement> {\n  items: DockItem[];\n  baseSize?: number;\n  magnification?: number;\n  distance?: number;\n  containerHeight?: number | string;\n  gap?: number;\n}\n\nexport const Dock = React.forwardRef<HTMLDivElement, DockProps>(\n  (\n    {\n      items,\n      baseSize = 48,\n      magnification = 80,\n      distance = 140,\n      containerHeight = 64,\n      gap = 12,\n      className,\n      style,\n      ...props\n    },\n    ref,\n  ) => {\n    const mouseX = useMotionValue(Infinity);\n    const [screenTier, setScreenTier] = useState<\"desktop\" | \"tablet\" | \"mobile\">(\"desktop\");\n\n    // Automatically detect small screens to scale down physics on touch devices\n    useEffect(() => {\n      const handleResize = () => {\n        const w = window.innerWidth;\n        if (w < 480) {\n          setScreenTier(\"mobile\");\n        } else if (w < 640) {\n          setScreenTier(\"tablet\");\n        } else {\n          setScreenTier(\"desktop\");\n        }\n      };\n      handleResize();\n      window.addEventListener(\"resize\", handleResize);\n      return () => window.removeEventListener(\"resize\", handleResize);\n    }, []);\n\n    const isSmallMobile = screenTier === \"mobile\";\n    const isTablet = screenTier === \"tablet\";\n    const isMobile = isSmallMobile || isTablet;\n    const isCrowded = items.length >= 7;\n\n    // Responsive physics sizing fallbacks for mobile viewports\n    const effectiveBaseSize = isSmallMobile && isCrowded\n      ? Math.min(baseSize, 28)\n      : isMobile\n      ? Math.min(baseSize, isCrowded ? 34 : 36)\n      : baseSize;\n\n    const effectiveMagnification = isSmallMobile && isCrowded\n      ? Math.min(magnification, 40)\n      : isMobile\n      ? Math.min(magnification, isCrowded ? 48 : 52)\n      : magnification;\n\n    const effectiveDistance = isSmallMobile && isCrowded\n      ? Math.min(distance, 70)\n      : isMobile\n      ? Math.min(distance, 100)\n      : distance;\n\n    const effectiveGap = isSmallMobile && isCrowded\n      ? Math.min(gap, 4)\n      : isMobile\n      ? Math.min(gap, 6)\n      : gap;\n\n    const dynamicHeight = typeof containerHeight === \"number\"\n      ? `${\n          isSmallMobile && isCrowded\n            ? Math.min(containerHeight, 52)\n            : isMobile\n            ? Math.min(containerHeight, 60)\n            : containerHeight\n        }px`\n      : containerHeight;\n\n    return (\n      <div\n        ref={ref}\n        onMouseMove={(e) => mouseX.set(e.clientX)}\n        onMouseLeave={() => mouseX.set(Infinity)}\n        style={{\n          height: dynamicHeight,\n          gap: `${effectiveGap}px`,\n          ...style,\n        }}\n        className={cn(\n          \"mx-auto flex items-end justify-center rounded-2xl shadow-2xl transition-all duration-300\",\n          isSmallMobile && isCrowded\n            ? \"px-1.5 pt-1 pb-0.5\"\n            : \"px-2 sm:px-4 pt-1 sm:pt-2.5 pb-0.5 sm:pb-2.5\",\n          \"bg-card/70 backdrop-blur-xl border border-border/80\",\n          \"ring-1 ring-foreground/5\",\n          \"w-fit max-w-[calc(100%-0.5rem)] sm:max-w-full overflow-visible\",\n          className,\n        )}\n        {...props}\n      >\n        {items.map((item) => (\n          <DockIcon\n            key={item.id}\n            item={item}\n            mouseX={mouseX}\n            baseSize={effectiveBaseSize}\n            magnification={effectiveMagnification}\n            distance={effectiveDistance}\n            isMobile={isMobile}\n          />\n        ))}\n      </div>\n    );\n  },\n);\n\nDock.displayName = \"Dock\";\n\ninterface DockIconProps {\n  item: DockItem;\n  mouseX: MotionValue<number>;\n  baseSize: number;\n  magnification: number;\n  distance: number;\n  isMobile: boolean;\n}\n\nconst DockIcon: React.FC<DockIconProps> = ({\n  item,\n  mouseX,\n  baseSize,\n  magnification,\n  distance,\n}) => {\n  const iconRef = useRef<HTMLButtonElement>(null);\n  const [isHovered, setIsHovered] = useState(false);\n\n  const distanceFromMouse = useTransform(mouseX, (val: number) => {\n    const bounds = iconRef.current?.getBoundingClientRect() ?? {\n      x: 0,\n      width: 0,\n    };\n    return val - bounds.x - bounds.width / 2;\n  });\n\n  const widthSync = useTransform(\n    distanceFromMouse,\n    [-distance, 0, distance],\n    [baseSize, magnification, baseSize],\n  );\n\n  const width = useSpring(widthSync, {\n    mass: 0.1,\n    stiffness: 150,\n    damping: 12,\n  });\n\n  return (\n    <div className=\"relative flex flex-col items-center shrink-0\">\n      {/* Floating Tooltip (Renders on all devices on hover/touch) */}\n      <AnimatePresence>\n        {isHovered && (\n          <motion.div\n            initial={{ opacity: 0, y: 10, scale: 0.8 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: 5, scale: 0.8 }}\n            transition={{ duration: 0.15 }}\n            className=\"absolute -top-6 sm:-top-9 px-1.5 py-0.5 rounded text-[8px] sm:text-xs font-semibold whitespace-nowrap pointer-events-none shadow-md bg-primary text-primary-foreground border border-foreground z-50\"\n          >\n            {item.label}\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      {/* Interactive Dock Button */}\n      <motion.button\n        ref={iconRef}\n        style={{ width, height: width }}\n        onMouseEnter={() => setIsHovered(true)}\n        onMouseLeave={() => setIsHovered(false)}\n        onClick={() => {\n          if (item.onClick) item.onClick();\n          setIsHovered(false);\n        }}\n        aria-label={item.label}\n        className={cn(\n          \"relative flex items-center justify-center rounded-xl shadow-lg transition-colors cursor-pointer select-none shrink-0\",\n          \"bg-gradient-to-t from-muted to-card\",\n          \"border border-border/80 hover:border-foreground/30\",\n          \"text-foreground active:scale-95\",\n        )}\n      >\n        {/* Notification Badge */}\n        {item.badge && (\n          <span className=\"absolute -top-1 -right-1 flex h-3.5 w-3.5 sm:h-4 sm:min-w-4 items-center justify-center rounded-full bg-rose-500 px-1 text-[9px] sm:text-[10px] font-semibold text-white shadow-sm border border-card animate-pulse\">\n            {item.badge}\n          </span>\n        )}\n\n        {/* Scaled Icon Container */}\n        <div className=\"flex items-center justify-center w-3/5 h-3/5 pointer-events-none\">\n          {item.icon}\n        </div>\n      </motion.button>\n\n      {/* Active Dot Indicator */}\n      <div className=\"h-1 sm:h-1.5 w-full flex items-center justify-center mt-1\">\n        {item.isActive && (\n          <motion.div\n            layoutId=\"active-dot\"\n            className=\"w-1 h-1 sm:w-1.5 sm:h-1.5 rounded-full bg-primary shadow-sm\"\n          />\n        )}\n      </div>\n    </div>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/custom/blocks/DockBlock.tsx"
    }
  ],
  "docs": "Motion build of `dock` — same props, markup and install path; install one or the other. Named exports: Dock, DockItem. `items` take { id, label, icon, onClick?, isActive?, badge? }. `magnification` sets peak scale and `distance` the falloff radius. Pointer-driven — on touch devices it degrades to a plain icon row.",
  "categories": [
    "navigation"
  ],
  "type": "registry:component"
}
