-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6111 from signalco-io/feat/ui-primitives/tooltip
Feat/UI primitives/tooltip
- Loading branch information
Showing
5 changed files
with
130 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Info } from "@signalco/ui-icons"; | ||
import { Stack } from "@signalco/ui-primitives/Stack"; | ||
import { Tooltip, TooltipTrigger, TooltipContent } from "@signalco/ui-primitives/Tooltip"; | ||
import { Typography } from "@signalco/ui-primitives/Typography"; | ||
import { StoryObj } from "@storybook/react"; | ||
|
||
export default { | ||
component: Tooltip, | ||
tags: ['autodocs'], | ||
args: { | ||
delayDuration: 0, | ||
children: ( | ||
<> | ||
<TooltipTrigger> | ||
<Info /> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<Stack> | ||
<Typography level="body1">Tooltip content</Typography> | ||
<Typography level="body2">Example of tooltip with components as children</Typography> | ||
</Stack> | ||
</TooltipContent> | ||
</> | ||
) | ||
} | ||
}; | ||
type Story = StoryObj<typeof Tooltip>; | ||
|
||
export const Default: Story = { | ||
decorators: [ | ||
(Story) => ( | ||
<div className="p-8 flex flex-col items-center"> | ||
<Story /> | ||
</div> | ||
) | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use client'; | ||
|
||
export * from './Tooltip'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.