Skip to content

The agent that grows with you

feat(desktop): add an accent variant to the popover primitive

Brooklyn Nicholson50f816abaf30
diff --git a/apps/desktop/src/components/ui/popover.tsx b/apps/desktop/src/components/ui/popover.tsx
index 16fa23f7a4c..040bb1f988c 100644
--- a/apps/desktop/src/components/ui/popover.tsx
+++ b/apps/desktop/src/components/ui/popover.tsx
@@ -1,3 +1,4 @@
+import { cva, type VariantProps } from 'class-variance-authority'
import { Popover as PopoverPrimitive } from 'radix-ui'
import * as React from 'react'
@@ -16,6 +17,35 @@ function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitiv
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
}
+// Both variants are the same box, and `--popover-surface` is what the arrow
+// fills itself with — so a variant only ever has to restate the surface.
+const popoverContentVariants = cva(
+ 'z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-lg p-2 outline-hidden data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
+ {
+ variants: {
+ variant: {
+ // Themed glass surface, viewport-aware (Radix flips/shifts off edges).
+ // Border-only (no shadow).
+ default:
+ 'border border-(--ui-stroke-secondary) bg-(--popover-surface) text-popover-foreground backdrop-blur-md [--popover-surface:color-mix(in_srgb,var(--ui-bg-elevated)_92%,transparent)]',
+ // Solid accent. For a surface that has to read as the app SPEAKING
+ // rather than as chrome the user opened — it is loud on purpose, so
+ // it earns its place by being rare. No border: at full-strength fill
+ // an edge only muddies the silhouette, and the arrow reads as a point
+ // on the shape instead of a shape stuck to it. `primary-solid`, not
+ // `primary`: a pale accent would otherwise fill this with a pastel and
+ // pair it with near-black text (themes/context.tsx).
+ accent:
+ 'bg-(--popover-surface) text-(--dt-primary-solid-foreground) [--popover-surface:var(--dt-primary-solid)]'
+ }
+ },
+ defaultVariants: { variant: 'default' }
+ }
+)
+
+interface PopoverContentProps
+ extends React.ComponentProps<typeof PopoverPrimitive.Content>, VariantProps<typeof popoverContentVariants> {}
+
function PopoverContent({
align = 'center',
// Keeps the arrow clear of the rounded corners (rounded-lg = 8px): Radix
@@ -26,8 +56,9 @@ function PopoverContent({
className,
collisionPadding = 8,
sideOffset = 6,
+ variant,
...props
-}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
+}: PopoverContentProps) {
// Portal into the enclosing dialog when nested in one (keeps focus inside so
// the dialog doesn't close on dismiss); document.body otherwise.
const container = usePopoverPortalContainer()
@@ -37,12 +68,7 @@ function PopoverContent({
<PopoverPrimitive.Content
align={align}
arrowPadding={arrowPadding}
- // Themed glass surface, viewport-aware (Radix flips/shifts off edges),
- // standard open/close motion. Border-only (no shadow).
- className={cn(
- 'z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-lg border border-(--ui-stroke-secondary) bg-[var(--popover-surface)] p-2 text-popover-foreground backdrop-blur-md outline-hidden data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 [--popover-surface:color-mix(in_srgb,var(--ui-bg-elevated)_92%,transparent)]',
- className
- )}
+ className={cn(popoverContentVariants({ variant }), className)}
collisionPadding={collisionPadding}
data-slot="popover-content"
sideOffset={sideOffset}
@@ -56,7 +82,15 @@ function PopoverContent({
The square's inner half tucks under the body, opening the border seam. */}
<PopoverPrimitive.Arrow asChild height={7} width={16}>
<span className="relative block h-[7px] w-4 overflow-visible">
- <span className="absolute top-0 left-1/2 size-[11px] -translate-x-1/2 -translate-y-1/2 rotate-45 border-r border-b border-(--ui-stroke-secondary) bg-[var(--popover-surface)] backdrop-blur-md" />
+ <span
+ className={cn(
+ 'absolute top-0 left-1/2 size-[11px] -translate-x-1/2 -translate-y-1/2 rotate-45 bg-(--popover-surface)',
+ variant === 'accent'
+ ? // Borderless and opaque: nothing to seam, nothing to blur.
+ 'rounded-[1px]'
+ : 'border-r border-b border-(--ui-stroke-secondary) backdrop-blur-md'
+ )}
+ />
</span>
</PopoverPrimitive.Arrow>
</PopoverPrimitive.Content>
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css
index 054153e0181..7109409ffd5 100644
--- a/apps/desktop/src/styles.css
+++ b/apps/desktop/src/styles.css
@@ -395,6 +395,11 @@
--dt-popover-foreground: var(--ui-text-primary);
--dt-primary: var(--theme-primary);
--dt-primary-foreground: #fcfcfc;
+ /* Boot-paint fallbacks. themes/context.tsx replaces --dt-primary-solid with
+ the hue deepened until #fcfcfc clears AA on it; until it runs, the raw
+ primary is the closest honest guess. */
+ --dt-primary-solid: var(--theme-primary);
+ --dt-primary-solid-foreground: #fcfcfc;
--dt-secondary: var(--theme-secondary);
--dt-secondary-foreground: var(--ui-text-secondary);
--dt-accent: var(--theme-accent-soft);
diff --git a/apps/desktop/src/themes/context.tsx b/apps/desktop/src/themes/context.tsx
index 6409315d068..d2024906a4d 100644
--- a/apps/desktop/src/themes/context.tsx
+++ b/apps/desktop/src/themes/context.tsx
@@ -20,7 +20,7 @@ import { setAppearance } from '@/store/translucency'
import { $accentOverride } from './accent-override'
import { $backendThemes, $pendingSkinApply } from './backend-sync'
-import { harmonize, hexToRgb, mix, readableOn } from './color'
+import { ensureContrast, harmonize, hexToRgb, mix, readableOn } from './color'
import { BUILTIN_THEME_LIST, DEFAULT_SKIN_NAME, DEFAULT_TYPOGRAPHY, nousTheme } from './presets'
import { retintTheme } from './retint'
import type { DesktopTheme, DesktopThemeColors } from './types'
@@ -178,6 +178,11 @@ function renderedModeFor(colors: DesktopThemeColors, mode: 'light' | 'dark'): 'l
// styles.css --theme-neutral-chrome — keep in sync.
const NEUTRAL_CHROME = { light: '#f3f3f3', dark: '#0d0d0e' } as const
+// The one foreground --dt-primary-solid is built to carry. Fixed rather than
+// measured: the surface is derived to suit IT, not the other way round.
+// styles.css --dt-primary-solid-foreground fallback — keep in sync.
+const PRIMARY_SOLID_FOREGROUND = '#fcfcfc'
+
const chromeBackground = (background: string, isDark: boolean) =>
mix(background, NEUTRAL_CHROME[isDark ? 'dark' : 'light'], isDark ? 0.26 : 0.08)
@@ -238,6 +243,16 @@ function applyTheme(theme: DesktopTheme, mode: 'light' | 'dark') {
'--dt-ring': c.ring,
'--dt-muted': c.muted,
'--dt-midground-foreground': c.midgroundForeground ?? readableOn(midground),
+ // A LOUD fill of the brand colour, for the rare surface that has to read as
+ // the app speaking rather than as chrome. `primary` alone can't do that job:
+ // a pale accent (imported VS Code themes love a pastel pink) is a perfectly
+ // valid primary, and the honest `primaryForeground` for it is near-black —
+ // so the "loud" surface comes out a pastel card with dark text on it,
+ // whispering. Deepening the hue until the LIGHT foreground clears AA keeps
+ // one look across every theme: no-ops on an accent that is already deep,
+ // and only ever darkens, so the hue survives.
+ '--dt-primary-solid': ensureContrast(c.primary, PRIMARY_SOLID_FOREGROUND, 4.5),
+ '--dt-primary-solid-foreground': PRIMARY_SOLID_FOREGROUND,
'--dt-composer-ring': c.composerRing ?? midground,
'--dt-destructive': c.destructive,
'--dt-destructive-foreground': c.destructiveForeground,