quivr/frontend/lib/components/ui/Tooltip.tsx
Zineb El Bachiri f4aa22417f
Refactor/front (#313)
* 🚚 move footer component

* 🚚 move navbar component

* 🚚 move ui components

* 🚚 move browser tab icon to public folder

* 🚚 move Chat Provider

* 🚚 move hooks to lib

* 🚚  move helpers to lib

* 🚚 move types to lib
2023-06-13 16:33:41 +02:00

49 lines
1.7 KiB
TypeScript

"use client";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { AnimatePresence, motion } from "framer-motion";
import { FC, ReactNode, useState } from "react";
interface TooltipProps {
children?: ReactNode;
tooltip?: ReactNode;
}
const Tooltip: FC<TooltipProps> = ({ children, tooltip }) => {
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;