feat(sidebar): introduce SidebarButtonBadge for improved badge display

- Added SidebarButtonBadge component to encapsulate badge styling and functionality.
- Updated Sidebar to utilize SidebarButtonBadge for displaying new item notifications, enhancing visual clarity.
- Adjusted SidebarUserProfile layout for better alignment in collapsed view.
This commit is contained in:
Anish Sarkar 2026-07-07 22:48:23 +05:30
parent 2670ad96c8
commit d6fbbb97d4
4 changed files with 25 additions and 11 deletions

View file

@ -19,7 +19,7 @@ import { ChatListItem } from "./ChatListItem";
import { CreditBalanceDisplay } from "./CreditBalanceDisplay";
import { DocumentsSidebar } from "./DocumentsSidebar";
import { NavSection } from "./NavSection";
import { SidebarButton } from "./SidebarButton";
import { SidebarButton, SidebarButtonBadge } from "./SidebarButton";
import { SidebarCollapseButton } from "./SidebarCollapseButton";
import { SidebarHeader } from "./SidebarHeader";
import { SidebarSection } from "./SidebarSection";
@ -246,14 +246,7 @@ export function Sidebar({
onClick={() => onNavItemClick?.(playgroundItem)}
isCollapsed={isCollapsed}
isActive={playgroundItem.isActive}
badge={
<Badge
variant="secondary"
className="h-5 shrink-0 rounded-sm border-0 bg-popover-foreground/10 px-1.5 text-[11px] text-popover-foreground hover:bg-popover-foreground/10"
>
New
</Badge>
}
badge={<SidebarButtonBadge>New</SidebarButtonBadge>}
tooltipContent={isCollapsed ? playgroundItem.title : undefined}
/>
)}

View file

@ -2,6 +2,7 @@
import type { LucideIcon } from "lucide-react";
import type React from "react";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
@ -28,6 +29,26 @@ const baseClassName = cn(
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
);
export function SidebarButtonBadge({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}) {
return (
<Badge
variant="secondary"
className={cn(
"h-5 shrink-0 rounded-sm border-0 bg-popover-foreground/10 px-1.5 text-[11px] text-popover-foreground hover:bg-popover-foreground/10",
className
)}
>
{children}
</Badge>
);
}
export function SidebarButton({
icon: Icon,
label,

View file

@ -414,7 +414,7 @@ export function SidebarUserProfile({
// Collapsed view - just show avatar with dropdown
if (isCollapsed) {
return (
<div className="relative w-full px-1.5 py-2 before:absolute before:inset-x-3 before:top-0 before:h-px before:bg-border">
<div className="relative w-full px-1.5 py-2 before:absolute before:inset-x-1.5 before:top-0 before:h-px before:bg-border">
<div className="flex flex-col items-center gap-2">
{topContent}
{showDownloadCta && (

View file

@ -29,7 +29,7 @@ export function ConnectAgentDialog({ className }: { className?: string }) {
)}
>
<Cable className="h-3.5 w-3.5 shrink-0" />
<span className="min-w-0 flex-1 truncate">Connect your AI Agent</span>
<span className="min-w-0 flex-1 truncate">Connect your agent</span>
</DialogTrigger>
<DialogContent className="max-h-[85vh] overflow-y-auto sm:max-w-2xl">
<DialogHeader>