MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / ToolTip

Function ToolTip

app/components/ToolTip.tsx:12–54  ·  view source on GitHub ↗
({ children, className, arrow }: ToolTipProps)

Source from the content-addressed store, hash-verified

10export type ArrowDirection = "top" | "bottom" | "left" | "right";
11
12export function ToolTip({ children, className, arrow }: ToolTipProps) {
13 const [isShown, setIsShown] = useState(false);
14 const arrowStyle = () => {
15 if (!arrow) {
16 return "";
17 }
18 switch (arrow) {
19 case "top":
20 return "top-[40px] after:bg-white after:border-[1px] after:border-t-slate-300 after:border-r-transparent after:border-b-transparent after:border-l-slate-300 after:dark:border-t-slate-600 after:dark:border-r-transprent after:dark:border-b-transparent after:dark:border-l-slate-600 after:dark:bg-slate-700 after:h-[14px] after:w-[14px] after:top-[-8px] after:left-[calc(50%-7px)] after:content-[''] after:absolute after:bg-white after:rotate-45";
21 case "bottom":
22 return "bottom-[49px] after:bg-white after:border-[1px] after:border-t-transparent after:border-r-transparent after:border-b-slate-300 after:border-l-slate-300 after:dark:border-t-transprent after:dark:border-r-transprent after:dark:border-b-slate-600 after:dark:border-l-slate-600 after:dark:bg-slate-700 after:h-[14px] after:w-[14px] after:left-[-8px] after:top-[calc(50%-7px)] after:content-[''] after:absolute after:bg-white after:rotate-45";
23 case "left":
24 return "left-[49px] after:bg-white after:border-[1px] after:border-t-transparent after:border-r-transparent after:border-b-slate-300 after:border-l-slate-300 after:dark:border-t-transprent after:dark:border-r-transprent after:dark:border-b-slate-600 after:dark:border-l-slate-600 after:dark:bg-slate-700 after:h-[14px] after:w-[14px] after:left-[-8px] after:top-[calc(50%-7px)] after:content-[''] after:absolute after:bg-white after:rotate-45";
25 case "right":
26 return "right-[49px] after:bg-white after:border-[1px] after:border-t-transparent after:border-r-transparent after:border-b-slate-300 after:border-l-slate-300 after:dark:border-t-transprent after:dark:border-r-transprent after:dark:border-b-slate-600 after:dark:border-l-slate-600 after:dark:bg-slate-700 after:h-[14px] after:w-[14px] after:left-[-8px] after:top-[calc(50%-7px)] after:content-[''] after:absolute after:bg-white after:rotate-45";
27 }
28 };
29
30 return (
31 <motion.div
32 animate={{}}
33 initial={{ scale: 0.97, opacity: 0.5 }}
34 transition={{ duration: 0.2 }}
35 whileHover={{ scale: 1, opacity: 1 }}
36 whileTap={{
37 scale: 1,
38 }}
39 onMouseOver={() => setIsShown(true)}
40 onMouseOut={() => setIsShown(false)}
41 className={`${className} absolute flex justify-center top-0 text-center z-10 h-full w-full text-slate-800 transtition dark:text-slate-200`}
42 >
43 <div
44 className={`absolute flex items-center ${
45 isShown
46 ? `${arrowStyle()} pl-3 pr-2 py-2 w-max shadow rounded-sm border-slate-300 border-[1px] bg-white dark:bg-slate-700 dark:border-slate-600`
47 : ""
48 }`}
49 >
50 {isShown && children}
51 </div>
52 </motion.div>
53 );
54}

Callers

nothing calls this directly

Calls 1

arrowStyleFunction · 0.85

Tested by

no test coverage detected