-
Notifications
You must be signed in to change notification settings - Fork 876
chore: add Tooltip component #16444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore: add Tooltip component #16444
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
chore: add Tooltip component
- Loading branch information
commit fc59e89ec46947756ffea8d27b9338753268656c
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,32 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "./Tooltip"; | ||
import { Button } from "components/Button/Button"; | ||
|
||
const meta: Meta<typeof TooltipProvider> = { | ||
title: "components/Tooltip", | ||
component: TooltipProvider, | ||
args: { | ||
children: ( | ||
<> | ||
<TooltipProvider> | ||
<Tooltip open> | ||
<TooltipTrigger asChild> | ||
<Button variant="outline">Hover</Button> | ||
</TooltipTrigger> | ||
<TooltipContent>Add to library</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</> | ||
), | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Tooltip>; | ||
|
||
export const Default: Story = {}; |
This file contains hidden or 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,34 @@ | ||
/** | ||
* Copied from shadc/ui on 02/05/2025 | ||
* @see {@link https://ui.shadcn.com/docs/components/tooltip} | ||
*/ | ||
import * as React from "react"; | ||
import * as TooltipPrimitive from "@radix-ui/react-tooltip"; | ||
import { cn } from "utils/cn"; | ||
|
||
export const TooltipProvider = TooltipPrimitive.Provider; | ||
|
||
export const Tooltip = TooltipPrimitive.Root; | ||
|
||
export const TooltipTrigger = TooltipPrimitive.Trigger; | ||
|
||
export const TooltipContent = React.forwardRef< | ||
React.ElementRef<typeof TooltipPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> | ||
>(({ className, sideOffset = 4, ...props }, ref) => ( | ||
<TooltipPrimitive.Portal> | ||
<TooltipPrimitive.Content | ||
ref={ref} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"z-50 overflow-hidden rounded-md bg-primary px-3 py-2 text-xs font-medium text-content-secondary", | ||
"border border-solid border-border 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} | ||
/> | ||
</TooltipPrimitive.Portal> | ||
)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bg-primary
should be changed to one of the surface colors