Skip to content

Commit

Permalink
feat(ui-primitives): Added Tooltip component
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarDev committed Oct 20, 2024
1 parent e1bca28 commit db7d35c
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 18 deletions.
3 changes: 2 additions & 1 deletion web/packages/ui-primitives/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signalco/ui-primitives",
"version": "0.1.11",
"version": "0.1.12",
"license": "MIT",
"type": "module",
"sideEffects": false,
Expand Down Expand Up @@ -33,6 +33,7 @@
"@radix-ui/react-select": "2.1.2",
"@radix-ui/react-slot": "1.1.0",
"@radix-ui/react-tabs": "1.1.1",
"@radix-ui/react-tooltip": "1.1.3",
"@signalco/eslint-config-signalco": "workspace:*",
"@signalco/hooks": "workspace:*",
"@signalco/js": "workspace:*",
Expand Down
35 changes: 35 additions & 0 deletions web/packages/ui-primitives/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as TooltipPrimitive from "@radix-ui/react-tooltip"

import { ComponentPropsWithoutRef, ElementRef, forwardRef, ReactNode } from "react"
import { cx } from "../cx"
import { TooltipProviderProps } from "@radix-ui/react-tooltip"

const TooltipTrigger = TooltipPrimitive.Trigger

const TooltipContent = forwardRef<
ElementRef<typeof TooltipPrimitive.Content>,
ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cx(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
))
TooltipContent.displayName = TooltipPrimitive.Content.displayName

export function Tooltip({ delayDuration, children }: { children: ReactNode, delayDuration: TooltipProviderProps['delayDuration'] }) {
return (
<TooltipPrimitive.Provider delayDuration={delayDuration}>
<TooltipPrimitive.Root>
{children}
</TooltipPrimitive.Root>
</TooltipPrimitive.Provider>
)
}

export { TooltipTrigger, TooltipContent }
3 changes: 3 additions & 0 deletions web/packages/ui-primitives/src/Tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use client';

export * from './Tooltip';
70 changes: 53 additions & 17 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit db7d35c

Please sign in to comment.