Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions webview-ui/src/components/ui/__tests__/tooltip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ describe("Tooltip", () => {
{ timeout: 1000 },
)
})

it("should apply VSCode native shadow styling", async () => {
const user = userEvent.setup()

render(
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger>Hover me</TooltipTrigger>
<TooltipContent>Tooltip with shadow</TooltipContent>
</Tooltip>
</TooltipProvider>,
)

const trigger = screen.getByText("Hover me")
await user.hover(trigger)

await waitFor(
() => {
const tooltips = screen.getAllByText("Tooltip with shadow")
const visibleTooltip = tooltips.find((el) => el.getAttribute("role") !== "tooltip")
expect(visibleTooltip).toHaveClass("shadow-[0_2px_8px_var(--color-vscode-widget-shadow)]")
},
{ timeout: 1000 },
)
})
})

describe("StandardTooltip", () => {
Expand Down
1 change: 1 addition & 0 deletions webview-ui/src/components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function TooltipContent({
className={cn(
"bg-vscode-editorHoverWidget-background outline outline-vscode-editorHoverWidget-border text-vscode-editorHoverWidget-foreground 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-sm px-2 py-1 text-xs text-balance",
"max-w-[300px] break-words",
"shadow-[0_2px_8px_var(--color-vscode-widget-shadow)]",
className,
)}
{...props}>
Expand Down
6 changes: 6 additions & 0 deletions webview-ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
--color-vscode-editorHoverWidget-foreground: var(--vscode-editorHoverWidget-foreground);
--color-vscode-editorHoverWidget-background: var(--vscode-editorHoverWidget-background);
--color-vscode-editorHoverWidget-border: var(--vscode-editorHoverWidget-border);

/**
* VSCode tooltip shadow - matches native VSCode tooltip styling
* Uses a subtle shadow for better visibility and depth
*/
--color-vscode-widget-shadow: var(--vscode-widget-shadow, rgba(0, 0, 0, 0.36));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment could be more explicit about which VSCode theme variable this maps to. Consider updating it to clarify that this CSS variable maps directly to for better documentation:

}

@layer base {
Expand Down
Loading