-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add tooltip * add `@radix-ui/react-tooltip` package * update styles & add story --------- Co-authored-by: BrickheadJohnny <[email protected]>
- Loading branch information
1 parent
d8d321d
commit f6694f4
Showing
6 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,29 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { Button } from "./Button" | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./Tooltip" | ||
|
||
const TooltipExample = () => ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button variant="outline" size="sm"> | ||
Hover me! | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>This is a tooltip!</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
) | ||
|
||
const meta: Meta<typeof TooltipExample> = { | ||
title: "Design system/Tooltip", | ||
component: TooltipExample, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof TooltipExample> | ||
|
||
export const Default: Story = {} |
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 @@ | ||
"use client" | ||
|
||
import * as TooltipPrimitive from "@radix-ui/react-tooltip" | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const TooltipProvider = TooltipPrimitive.Provider | ||
|
||
const Tooltip: React.FC< | ||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> | ||
> = ({ ...props }) => <TooltipPrimitive.Root delayDuration={0} {...props} /> | ||
|
||
const TooltipTrigger = TooltipPrimitive.Trigger | ||
|
||
const TooltipContent = React.forwardRef< | ||
React.ElementRef<typeof TooltipPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> | ||
>(({ className, sideOffset = 4, children, ...props }, ref) => ( | ||
<TooltipPrimitive.Content | ||
ref={ref} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"bg-tooltip text-tooltip-foreground z-50 overflow-hidden rounded-xl px-3 py-1.5 text-sm shadow-md duration-0 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} | ||
> | ||
{children} | ||
{/* <TooltipPrimitive.Arrow className="fill-popover-foreground" /> */} | ||
</TooltipPrimitive.Content> | ||
)) | ||
TooltipContent.displayName = TooltipPrimitive.Content.displayName | ||
|
||
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } |
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