From 4439e9ec86e0e470ef05d0da8b7788c79c68c8c1 Mon Sep 17 00:00:00 2001 From: arihanv Date: Mon, 10 Jun 2024 19:27:36 -0500 Subject: [PATCH] feat: create tooltip --- src/ui/__fixtures__/tooltip.tsx | 4 +-- src/ui/tooltip.tsx | 60 ++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/ui/__fixtures__/tooltip.tsx b/src/ui/__fixtures__/tooltip.tsx index 5654c76..00b65d1 100644 --- a/src/ui/__fixtures__/tooltip.tsx +++ b/src/ui/__fixtures__/tooltip.tsx @@ -14,8 +14,8 @@ const tooltipFixtures = { - -

Add to library

+ +

Tooltip

diff --git a/src/ui/tooltip.tsx b/src/ui/tooltip.tsx index 2470d0f..739bbd9 100644 --- a/src/ui/tooltip.tsx +++ b/src/ui/tooltip.tsx @@ -1,25 +1,59 @@ -import * as TooltipPrimitive from '@radix-ui/react-tooltip' -import * as React from 'react' +"use client"; -const TooltipProvider = TooltipPrimitive.Provider +import * as React from "react"; +import * as TooltipPrimitive from "@radix-ui/react-tooltip"; -const Tooltip = TooltipPrimitive.Root +import clsx from "clsx"; -const TooltipTrigger = TooltipPrimitive.Trigger +const TooltipProvider = TooltipPrimitive.Provider; + +const Tooltip = TooltipPrimitive.Root; + +const TooltipTrigger = TooltipPrimitive.Trigger; const TooltipContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({className, sideOffset = 6, ...props}, ref) => ( +>(({ className, sideOffset = 4, ...props }, ref) => ( -)) -TooltipContent.displayName = TooltipPrimitive.Content.displayName + > +
+ + {props.children} + + + Tooltip Triangle + + +
+
+)); +TooltipContent.displayName = TooltipPrimitive.Content.displayName; -export {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} +export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };