mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-23 11:23:00 +03:00
1d7bc8a5bc
* remove duplicate import * 🚧 add new linter configuration * 🧑💻 add and run prettier * 🐛 add babel parser for linter * 🧑💻 add lint-fix command * 🚨 use lint-fix * 🚨 remove 'FC' as a type. Use const and JSX.Element * 🚨 enforce arrow function rule from linter * 🔥 delete unused file * 🚨 adding /* eslint-disable */ in failing files * 💩 add ts-expect-error to Victory components
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
"use client";
|
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
import { AnimatePresence, motion } from "framer-motion";
|
|
import { ReactNode, useState } from "react";
|
|
|
|
interface TooltipProps {
|
|
children?: ReactNode;
|
|
tooltip?: ReactNode;
|
|
}
|
|
|
|
const Tooltip = ({ children, tooltip }: TooltipProps): JSX.Element => {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
return (
|
|
<TooltipPrimitive.Provider>
|
|
<TooltipPrimitive.Root onOpenChange={setOpen} open={open}>
|
|
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
|
<AnimatePresence>
|
|
{open && (
|
|
<TooltipPrimitive.Portal forceMount>
|
|
<TooltipPrimitive.Content sideOffset={5} asChild>
|
|
<motion.div
|
|
initial={{ y: 10, opacity: 0 }}
|
|
animate={{
|
|
y: 0,
|
|
opacity: 1,
|
|
transition: { ease: "easeOut", duration: 0.1 },
|
|
}}
|
|
exit={{
|
|
y: 10,
|
|
opacity: 0,
|
|
transition: { ease: "easeIn", duration: 0.1 },
|
|
}}
|
|
// transition={{ duration: 0.2, ease: "circInOut" }}
|
|
className="select-none rounded-md border border-black/10 dark:border-white/25 bg-white dark:bg-gray-800 px-5 py-3 text-sm leading-none shadow-lg dark:shadow-primary/25"
|
|
>
|
|
{tooltip}
|
|
<TooltipPrimitive.Arrow className="fill-white dark:fill-black" />
|
|
</motion.div>
|
|
</TooltipPrimitive.Content>
|
|
</TooltipPrimitive.Portal>
|
|
)}
|
|
</AnimatePresence>
|
|
</TooltipPrimitive.Root>
|
|
</TooltipPrimitive.Provider>
|
|
);
|
|
};
|
|
|
|
export default Tooltip;
|