{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "tooltip", "dependencies": [ "@radix-ui/react-tooltip" ], "devDependencies": [ "sass" ], "registryDependencies": [ "https://powui.dev/r/utils.json", "https://powui.dev/r/theme.json" ], "files": [ { "path": "src/components/ui/tooltip.tsx", "content": "\"use client\";\n\nimport * as React from \"react\";\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\n\nimport { cn } from \"@/lib/utils\";\n\nimport styles from \"./tooltip.module.scss\";\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps) {\n return (\n \n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps) {\n return (\n \n \n \n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps) {\n return ;\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n shape,\n arrowClassName,\n ...props\n}: React.ComponentProps & {\n shape?: \"elliptical\" | \"square\";\n arrowClassName?: string;\n}) {\n return (\n \n \n \n {children}\n \n \n \n );\n}\n\nconst BubbleSvg = ({ bubblePath = \"\" }: { bubblePath: string }) => {\n const [pathRef, setPathRef] = React.useState(null);\n\n const pathLength = React.useMemo(() => {\n if (pathRef) {\n return pathRef.getTotalLength();\n }\n return 0;\n }, [pathRef]);\n\n const bubbleArc = React.useMemo(() => {\n if (bubblePath === \"arc\") {\n return \"M 50 0 Q 70 60 0 100\";\n }\n if (bubblePath === \"normal\") {\n return \"M 50 0 L 50 100\";\n }\n return bubblePath; // Use custom path if provided\n }, [bubblePath]);\n\n const bubbles = React.useMemo(() => {\n if (!pathLength) return null;\n const bubbleCount = 3;\n const firstBubbleRadius = 8;\n const radiusDiff = 5;\n const animationTime = 300;\n const lastBubbleRadius = firstBubbleRadius + (bubbleCount - 1) * radiusDiff;\n\n const radiusOfAllBubbles = Array.from(\n { length: bubbleCount },\n (_, i) => firstBubbleRadius + i * radiusDiff\n ).reduce((acc, r) => acc + r, 0);\n\n const safetyDistanceOnBothEnds = 5;\n\n const distanceBetweenBubbles =\n (pathLength - 2 * radiusOfAllBubbles - 2 * safetyDistanceOnBothEnds) /\n (bubbleCount - 1);\n\n const allBubblesPositions: number[] = [];\n\n Array.from({ length: bubbleCount }, (_, i) => {\n const currentBubbleRadius = lastBubbleRadius - i * radiusDiff;\n let position = currentBubbleRadius;\n if (i > 0) {\n const prevBubbleRadius = currentBubbleRadius + radiusDiff;\n position +=\n allBubblesPositions[i - 1] +\n prevBubbleRadius +\n distanceBetweenBubbles;\n } else {\n position += safetyDistanceOnBothEnds;\n }\n allBubblesPositions.push(position);\n });\n\n return allBubblesPositions.map((position, index) => (\n \n \n \n ));\n }, [bubbleArc, pathLength]);\n\n const bubbleSVG = React.useMemo(() => {\n return (\n \n \n {/* */}\n {bubbles}\n \n );\n }, [bubbleArc, bubbles]);\n\n return bubbleSVG;\n};\n\nconst TooltipContainer = ({\n triggerContent = \"Hover me\",\n content = \"Tooltip content\",\n className = \"\",\n arrowClassName = \"\",\n side = \"top\",\n sideOffset = 20,\n type = \"normal\",\n bubblePath = \"normal\",\n}: {\n triggerContent?: React.ReactNode;\n content?: React.ReactNode;\n className?: string;\n arrowClassName?: string;\n side?: TooltipPrimitive.TooltipContentProps[\"side\"];\n sideOffset?: TooltipPrimitive.TooltipContentProps[\"sideOffset\"];\n type?: \"normal\" | \"bubbles\";\n bubblePath?: \"normal\" | \"arc\" | string;\n}) => {\n let adjustedSideOffset = sideOffset;\n if (side === \"left\" || side === \"right\") {\n adjustedSideOffset += 12; // Adjust for horizontal sides\n }\n\n return (\n \n {triggerContent}\n \n {content}\n {type === \"normal\" && (\n \n )}\n {type === \"bubbles\" && }\n \n \n );\n};\n\nexport { TooltipContainer as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };\n", "type": "registry:ui" }, { "path": "src/components/ui/tooltip.module.scss", "content": ".comicArrow {\n position: absolute;\n bottom: 0;\n height: 0;\n width: 0;\n border-right: 10px solid transparent;\n border-left: 10px solid transparent;\n border-top: 30px solid black;\n &:before {\n content: \"\";\n display: block;\n translate: -50% calc(-100% - 10px);\n border-right: 10px solid transparent;\n border-left: 10px solid transparent;\n border-top: 30px solid white;\n }\n}\n\n.bub {\n fill: #ffffff;\n stroke: black;\n stroke-width: 1.5;\n}\n\n@keyframes bounceScale {\n 0% {\n scale: 0;\n }\n 70% {\n scale: 1.2;\n }\n 80% {\n scale: 1.2;\n }\n 100% {\n scale: 1;\n }\n}\n\n.bounceMount {\n animation: bounceScale 0.2s ease-in-out;\n}\n", "type": "registry:file", "target": "components/ui/tooltip.module.scss" } ], "type": "registry:ui" }