Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(ui): give tooltips a dark surface in both themes (MUL-8140) (#9407)
Jiayuan Zhang6a70ec535294
diff --git a/packages/ui/components/ui/kbd.tsx b/packages/ui/components/ui/kbd.tsxindex 439695a14c..2884c6d066 100644--- a/packages/ui/components/ui/kbd.tsx+++ b/packages/ui/components/ui/kbd.tsx@@ -5,10 +5,9 @@ function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {<kbddata-slot="kbd"className={cn(- // No in-tooltip color overrides: upstream shadcn inverts its tooltip- // (dark surface in light mode), but our TooltipContent keeps the- // popover surface, so the regular muted keycap colors stay readable.- "pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-caption font-medium text-muted-foreground select-none [&_svg:not([class*='size-'])]:size-3",+ // In a tooltip the keycap is a translucent light fill: the solid muted+ // fill sits below the tooltip surface's lightness in dark mode.+ "pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-caption font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-foreground/12 [&_svg:not([class*='size-'])]:size-3",className)}{...props}diff --git a/packages/ui/components/ui/tooltip.tsx b/packages/ui/components/ui/tooltip.tsxindex e7927c293b..80e7546f96 100644--- a/packages/ui/components/ui/tooltip.tsx+++ b/packages/ui/components/ui/tooltip.tsx@@ -39,6 +39,10 @@ function TooltipContent({TooltipPrimitive.Positioner.Props,"align" | "alignOffset" | "side" | "sideOffset" | "anchor">) {+ // The popup is a `.dark` scope, so the text, status colors, and keycaps+ // inside it take dark-theme values against the dark tooltip surface in both+ // page themes. Its own fill and shadow are resolved on the positioner, which+ // is still in the page theme.return (<TooltipPrimitive.Portal><TooltipPrimitive.Positioner@@ -47,12 +51,12 @@ function TooltipContent({side={side}sideOffset={sideOffset}anchor={anchor}- className="isolate z-50"+ className="isolate z-50 [--tooltip-fill:var(--tooltip)] [--tooltip-elevation:var(--tooltip-shadow)]"><TooltipPrimitive.Popupdata-slot="tooltip-content"className={cn(- "z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg border border-border bg-popover px-2.5 py-1 text-caption text-popover-foreground has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "dark z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg bg-(--tooltip-fill) px-2.5 py-1 text-caption text-foreground shadow-(--tooltip-elevation) has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}diff --git a/packages/ui/styles/tokens.css b/packages/ui/styles/tokens.cssindex 3565863da5..a6c4405892 100644--- a/packages/ui/styles/tokens.css+++ b/packages/ui/styles/tokens.css@@ -173,6 +173,12 @@so they carry a lighter shadow than window-level overlays (dialogs,sheets), which keep --floating-shadow. */--menu-shadow: 0 8px 24px rgb(15 23 42 / 0.08), 0 2px 6px rgb(15 23 42 / 0.05);+ /* Tooltips are a dark surface in both themes, so a passive label never+ reads as one of the interactive panels above. Near-black here; in dark+ mode it sits one step above every surface and carries a ring instead of+ a drop shadow. */+ --tooltip: oklch(0.21 0.006 285.885);+ --tooltip-shadow: 0 4px 12px rgb(15 23 42 / 0.16), 0 1px 3px rgb(15 23 42 / 0.12);--background: var(--page-canvas);--foreground: oklch(0.141 0.005 285.823);--card: var(--surface);@@ -260,6 +266,8 @@--surface-shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 1px 1px rgb(0 0 0 / 0.16);--floating-shadow: 0 20px 48px rgb(0 0 0 / 0.46), 0 4px 12px rgb(0 0 0 / 0.28);--menu-shadow: 0 10px 28px rgb(0 0 0 / 0.3), 0 2px 8px rgb(0 0 0 / 0.18);+ --tooltip: oklch(0.3 0.006 286.033);+ --tooltip-shadow: 0 0 0 1px oklch(1 0 0 / 10%), 0 8px 24px rgb(0 0 0 / 0.4);--background: var(--page-canvas);--foreground: oklch(0.985 0 0);--card: var(--surface);diff --git a/packages/views/settings/components/dingtalk-tab.tsx b/packages/views/settings/components/dingtalk-tab.tsxindex 4ef9f5db4b..23eab77a1b 100644--- a/packages/views/settings/components/dingtalk-tab.tsx+++ b/packages/views/settings/components/dingtalk-tab.tsx@@ -186,7 +186,7 @@ export function DingTalkConnectionLabel({<TooltipContentside="top"align="start"- className="max-w-80 items-start whitespace-normal border-0 bg-surface-raised px-3 py-2 text-popover-foreground shadow-[var(--menu-shadow)] ring-1 ring-surface-border"+ className="max-w-80 items-start whitespace-normal px-3 py-2"><span className="leading-relaxed">{permissionTooltipPrefix}{" "}