Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): restyle the Cmd+K menu (#18906)

Trang Nguyen095b682536ba
diff --git a/web/src/components/ui/command.tsx b/web/src/components/ui/command.tsx
index 7bf2e81748..aee64a41b6 100644
--- a/web/src/components/ui/command.tsx
+++ b/web/src/components/ui/command.tsx
@@ -47,13 +47,12 @@ const CommandDialog = ({
<DialogContent
className={cn(
commandDialogSurfaceClass,
- // Dark-mode depth: two near-black ambient layers (background is 6%
- // lightness in dark mode, visually black at these alphas) plus a
- // faint foreground-tinted hairline ring.
- "dark:border-border-contrast/70 top-[calc(var(--banner-offset)+clamp(4rem,14dvh,8rem))] translate-y-0 overflow-hidden border p-0 shadow-2xl dark:shadow-[0_32px_96px_-28px_hsl(var(--background)/0.95),0_16px_40px_-24px_hsl(var(--background)/0.9),0_0_0_1px_hsl(var(--foreground)/0.1)]",
+ // Dark-mode depth: two near-black ambient layers.
+ "top-[calc(var(--banner-offset)+clamp(4rem,20dvh,12rem))] translate-y-0 overflow-hidden p-0 shadow-2xl dark:shadow-[0_32px_96px_-28px_hsl(var(--background)/0.95),0_16px_40px_-24px_hsl(var(--background)/0.9)]",
)}
closeOnInteractionOutside
- overlayMode="invisible"
+ overlayMode="soft"
+ showCloseButton={false}
>
<DialogHeader className="sr-only p-0">
<DialogTitle>Search</DialogTitle>
@@ -63,7 +62,7 @@ const CommandDialog = ({
filter={filter}
className={cn(
commandDialogSurfaceClass,
- "**:[[cmdk-group-heading]]:text-muted-foreground pb-1 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-bold **:[[cmdk-group]]:px-2 **:[[cmdk-input]]:h-12",
+ "**:[[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-item]_svg]:icon-base [&_[cmdk-item]_svg]:text-muted-foreground [&_[cmdk-item][data-selected=true]]:text-primary **:[[cmdk-input]]:text-primary **:[[cmdk-list]]:scroll-fade-b [&_.cmdk-input-wrapper>svg]:left-4 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-item]]:py-2.5 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-normal **:[[cmdk-group]]:px-2 **:[[cmdk-input]]:h-11 **:[[cmdk-input]]:pl-8.5 **:[[cmdk-list]]:max-h-[min(24rem,calc(100dvh-var(--banner-offset)-clamp(4rem,20dvh,12rem)-4.5rem))] **:[[cmdk-list]]:scroll-py-2 **:[[cmdk-list]]:pb-1",
)}
>
{children}
diff --git a/web/src/components/ui/dialog.tsx b/web/src/components/ui/dialog.tsx
index 93ccf6497f..9ad369a066 100644
--- a/web/src/components/ui/dialog.tsx
+++ b/web/src/components/ui/dialog.tsx
@@ -27,10 +27,11 @@ DialogPortal.displayName = "DialogPortal";
const DialogClose = DialogPrimitive.Close;
-type DialogOverlayMode = "subtle" | "invisible" | "blocking";
+type DialogOverlayMode = "subtle" | "invisible" | "blocking" | "soft";
const dialogOverlayClasses: Record<DialogOverlayMode, string> = {
invisible: "bg-transparent",
+ soft: "bg-black/10 dark:bg-black/65",
subtle: "bg-black/25 dark:bg-black/45",
blocking: "bg-black/50 dark:bg-black/65",
};
@@ -87,6 +88,7 @@ const DialogContent = React.forwardRef<
overlayMode?: DialogOverlayMode;
overlayClassName?: string;
stopPropagationOnEnterSpace?: boolean;
+ showCloseButton?: boolean;
} & VariantProps<typeof dialogContentVariants>,
"onPointerDownOutside" | "onInteractOutside"
>
@@ -100,6 +102,7 @@ const DialogContent = React.forwardRef<
overlayMode = "subtle",
overlayClassName,
stopPropagationOnEnterSpace = true,
+ showCloseButton = true,
onEscapeKeyDown,
onClick,
size,
@@ -159,12 +162,14 @@ const DialogContent = React.forwardRef<
{...props}
>
{children}
- <div className="[&:has(.dialog-header)]:hidden [&:not(:has(.dialog-header))]:absolute [&:not(:has(.dialog-header))]:top-3 [&:not(:has(.dialog-header))]:right-3 [&:not(:has(.dialog-header))]:z-20">
- <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
- <X className="icon-base" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- </div>
+ {showCloseButton && (
+ <div className="[&:has(.dialog-header)]:hidden [&:not(:has(.dialog-header))]:absolute [&:not(:has(.dialog-header))]:top-3 [&:not(:has(.dialog-header))]:right-3 [&:not(:has(.dialog-header))]:z-20">
+ <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
+ <X className="icon-base" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </div>
+ )}
</DialogPrimitive.Content>
</DialogPortal>
);
diff --git a/web/src/features/command-k-menu/CommandMenu.tsx b/web/src/features/command-k-menu/CommandMenu.tsx
index 3572bb2296..3e5d81cfa5 100644
--- a/web/src/features/command-k-menu/CommandMenu.tsx
+++ b/web/src/features/command-k-menu/CommandMenu.tsx
@@ -9,6 +9,13 @@ import {
CommandSeparator,
} from "@/src/components/ui/command";
import { useRouter } from "next/router";
+import {
+ Grid2X2,
+ LayoutDashboard,
+ ListTree,
+ Settings,
+ type LucideIcon,
+} from "lucide-react";
import { useEffect, memo, useState } from "react";
import { useSession } from "next-auth/react";
import { env } from "@/src/env.mjs";
@@ -79,14 +86,14 @@ function MainNavigationGroup({
navItems,
onNavigate,
}: {
- navItems: Array<{ title: string; url: string }>;
+ navItems: Array<{ title: string; url: string; icon?: LucideIcon }>;
onNavigate: (item: { title: string; url: string }) => void;
}) {
const router = useRouter();
const capture = usePostHogClientCapture();
return (
- <CommandGroup heading="Main Navigation">
+ <CommandGroup heading="Go to">
{navItems.map((item) => (
<CommandItem
key={item.url}
@@ -102,6 +109,7 @@ function MainNavigationGroup({
onNavigate(item);
}}
>
+ {item.icon && <item.icon className="icon-base" />}
{item.title}
</CommandItem>
))}
@@ -136,6 +144,7 @@ function ProjectsGroup({ onNavigate }: { onNavigate: () => void }) {
onNavigate();
}}
>
+ <Grid2X2 className="icon-base" />
{item.title}
</CommandItem>
))}
@@ -194,6 +203,7 @@ function DashboardsGroup({ onNavigate }: { onNavigate: () => void }) {
onNavigate();
}}
>
+ <LayoutDashboard className="icon-base" />
{dashboard.name}
</CommandItem>
))}
@@ -221,7 +231,7 @@ function ProjectSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
return (
<>
<CommandSeparator />
- <CommandGroup heading="Project Settings">
+ <CommandGroup heading="Project settings">
{projectSettingsItems.map((item) => (
<CommandItem
key={item.url}
@@ -237,6 +247,7 @@ function ProjectSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
onNavigate();
}}
>
+ <Settings className="icon-base" />
{item.title}
</CommandItem>
))}
@@ -264,7 +275,7 @@ function OrganizationSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
return (
<>
<CommandSeparator />
- <CommandGroup heading="Organization Settings">
+ <CommandGroup heading="Organization settings">
{orgSettingsItems.map((item) => (
<CommandItem
key={item.url}
@@ -280,6 +291,7 @@ function OrganizationSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
onNavigate();
}}
>
+ <Settings className="icon-base" />
{item.title}
</CommandItem>
))}
@@ -306,7 +318,7 @@ function AccountSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
return (
<>
<CommandSeparator />
- <CommandGroup heading="Account Settings">
+ <CommandGroup heading="Account settings">
{accountSettingsItems.map((item) => (
<CommandItem
key={item.url}
@@ -322,6 +334,7 @@ function AccountSettingsGroup({ onNavigate }: { onNavigate: () => void }) {
onNavigate();
}}
>
+ <Settings className="icon-base" />
{item.title}
</CommandItem>
))}
@@ -358,12 +371,14 @@ function CommandMenuComponent({
return item.items.map((child) => ({
title: `${item.title} > ${child.title}`,
url: child.url,
+ icon: item.icon,
}));
}
return [
{
title: item.title,
url: item.url,
+ icon: item.icon,
},
];
})
@@ -411,8 +426,8 @@ function CommandMenuComponent({
}}
>
<CommandInput
- placeholder="Type a command or search..."
- className="border-none focus:border-none focus:ring-0 focus:ring-transparent focus:outline-hidden"
+ placeholder="Search pages, projects, dashboards…"
+ className="border-none text-lg focus:border-none focus:ring-0 focus:ring-transparent focus:outline-hidden"
value={search}
onValueChange={(value) => {
setSearch(value);
@@ -433,6 +448,7 @@ function CommandMenuComponent({
handleNavigate();
}}
>
+ <ListTree className="icon-base" />
{idNavigationItem.title}
</CommandItem>
</CommandGroup>
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index 8eb02869b7..b472ba0e84 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -986,6 +986,37 @@
);
}
+/* Fades a scrollport's bottom edge while more content is below, and clears
+ it as the end is reached. Browsers without scroll-driven animations show
+ no fade. */
+@property --scroll-fade-b {
+ syntax: "<length>";
+ inherits: false;
+ initial-value: 0px;
+}
+
+@keyframes scroll-fade-b {
+ from {
+ --scroll-fade-b: calc(var(--spacing) * 8);
+ }
+ to {
+ --scroll-fade-b: 0px;
+ }
+}
+
+@utility scroll-fade-b {
+ @supports (animation-timeline: scroll()) {
+ mask-image: linear-gradient(
+ to bottom,
+ black calc(100% - var(--scroll-fade-b)),
+ transparent
+ );
+ animation: scroll-fade-b linear both;
+ animation-timeline: scroll(self);
+ animation-range: calc(100% - var(--spacing) * 8) 100%;
+ }
+}
+
@utility scrollbar-visible {
&::-webkit-scrollbar {
width: 8px;