-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: add tooltip in TabBar #515
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
mazeincoding
merged 2 commits into
OpenCut-app:staging
from
Pratiyankkumar:tabbar-tooltip
Aug 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 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
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
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 |
|---|---|---|
| @@ -1,32 +1,72 @@ | ||
| "use client"; | ||
| import { cva, type VariantProps } from 'class-variance-authority'; | ||
| import { Tooltip as TooltipPrimitive } from 'radix-ui'; | ||
| import * as React from 'react'; | ||
|
|
||
| import * as React from "react"; | ||
| import { Tooltip as TooltipPrimitive } from "radix-ui"; | ||
|
|
||
| import { cn } from "../../lib/utils"; | ||
| import { cn } from '@/lib/utils'; | ||
|
|
||
| const TooltipProvider = TooltipPrimitive.Provider; | ||
|
|
||
| const Tooltip = TooltipPrimitive.Root; | ||
|
|
||
| const TooltipTrigger = TooltipPrimitive.Trigger; | ||
|
|
||
| const tooltipVariants = cva( | ||
| 'z-50 overflow-visible rounded-sm text-sm 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', | ||
| { | ||
| variants: { | ||
| variant: { | ||
| default: 'bg-popover text-popover-foreground border px-3 py-1.5', | ||
| destructive: | ||
| 'bg-destructive/10 text-destructive dark:bg-destructive/20 border-destructive [border-width:0.5px]', | ||
| outline: 'border-border', | ||
| important: | ||
| 'bg-amber-100/90 text-amber-900 dark:bg-amber-900/20 dark:text-amber-300 border-amber-900 [border-width:0.5px]', | ||
| promotions: | ||
| 'bg-red-100/90 text-red-900 dark:bg-red-900/20 dark:text-red-300 border-red-900 [border-width:0.5px]', | ||
| personal: | ||
| 'bg-green-100/90 text-green-900 dark:bg-green-900/20 dark:text-green-300 border-green-900 [border-width:0.5px]', | ||
| updates: | ||
| 'bg-purple-100/90 text-purple-900 dark:bg-purple-900/20 dark:text-purple-300 border-purple-900 [border-width:0.5px]', | ||
| forums: | ||
| 'bg-blue-100/90 text-blue-900 dark:bg-blue-900/20 dark:text-blue-300 border-blue-900 [border-width:0.5px]', | ||
| sidebar: 'bg-white dark:bg-[#413F3E] p-2.5 flex flex-col gap-2', | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: 'default', | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| interface TooltipContentProps | ||
| extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>, | ||
| VariantProps<typeof tooltipVariants> {} | ||
|
|
||
| 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-foreground px-3 py-1.5 text-xs text-background 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> | ||
| TooltipContentProps | ||
| >(({ className, sideOffset = 4, variant, ...props }, ref) => ( | ||
| <TooltipPrimitive.Content | ||
| ref={ref} | ||
| sideOffset={sideOffset} | ||
| className={cn(tooltipVariants({ variant }), className)} | ||
| {...props} | ||
| > | ||
| {variant === 'sidebar' && ( | ||
| <svg | ||
| width="6" | ||
| height="10" | ||
| viewBox="0 0 6 10" | ||
| fill="none" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| className="absolute left-[-6px] top-1/2 -translate-y-1/2" | ||
| > | ||
| <path d="M6 0L0 5L6 10V0Z" className="fill-white/80 dark:fill-[#413F3E]" /> | ||
| </svg> | ||
| )} | ||
| {props.children} | ||
| </TooltipPrimitive.Content> | ||
| )); | ||
| TooltipContent.displayName = TooltipPrimitive.Content.displayName; | ||
|
|
||
| export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }; | ||
| export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }; | ||
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.
🛠️ Refactor suggestion
Add accessibility attributes to the SVG arrow.
The SVG arrow lacks proper accessibility attributes and could confuse screen readers.
📝 Committable suggestion
🤖 Prompt for AI Agents