From aab19379e2fd7762165a9426d615228ac4bd1aad Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 13 May 2026 00:50:46 +0200 Subject: [PATCH] feat: route account avatars through shared Avatar component #278 --- components/layout/account-switcher.tsx | 21 +++++++++---------- components/layout/navigation-rail.tsx | 15 ++++++++----- .../protocol/protocol-account-picker.tsx | 18 +++++++++------- components/ui/avatar.tsx | 10 ++++++--- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/components/layout/account-switcher.tsx b/components/layout/account-switcher.tsx index b0764e98..24df5725 100644 --- a/components/layout/account-switcher.tsx +++ b/components/layout/account-switcher.tsx @@ -6,9 +6,10 @@ import { Check, Plus, LogOut, Star, ChevronDown, AlertCircle } from "lucide-reac import { useTranslations } from "next-intl"; import { useAccountStore, type AccountEntry } from "@/stores/account-store"; import { useAuthStore } from "@/stores/auth-store"; -import { getInitials, getMaxAccounts } from "@/lib/account-utils"; +import { getMaxAccounts } from "@/lib/account-utils"; import { cn } from "@/lib/utils"; import { useRouter } from "@/i18n/navigation"; +import { Avatar } from "@/components/ui/avatar"; interface AccountSwitcherProps { /** "rail" = small avatar only (NavigationRail), "expanded" = avatar + name + email (Sidebar) */ @@ -17,17 +18,15 @@ interface AccountSwitcherProps { } function AccountAvatar({ account, size = "sm" }: { account: AccountEntry; size?: "sm" | "md" }) { - const initials = getInitials(account.displayName || account.label, account.email || account.username); - const sizeClasses = size === "sm" ? "w-8 h-8 text-xs" : "w-9 h-9 text-sm"; - return ( -
- {initials} -
+ ); } diff --git a/components/layout/navigation-rail.tsx b/components/layout/navigation-rail.tsx index 5053d6ec..6bb3db36 100644 --- a/components/layout/navigation-rail.tsx +++ b/components/layout/navigation-rail.tsx @@ -17,11 +17,12 @@ import { useAuthStore } from "@/stores/auth-store"; import { useAccountStore } from "@/stores/account-store"; import { useUpdateStore, selectHasUpdate } from "@/stores/update-store"; import { getActiveAccountSlotHeaders } from "@/lib/auth/active-account-slot"; -import { getInitials, getMaxAccounts } from "@/lib/account-utils"; +import { getMaxAccounts } from "@/lib/account-utils"; import { cn, formatFileSize } from "@/lib/utils"; import { PluginSlot } from "@/components/plugins/plugin-slot"; import { KeyboardShortcutsModal } from "@/components/keyboard-shortcuts-modal"; import { apiFetch } from "@/lib/browser-navigation"; +import { Avatar } from "@/components/ui/avatar"; interface NavItem { id: string; @@ -610,7 +611,6 @@ export function NavigationRail({
{accounts.map((account) => { const isActive = account.id === activeAccountId; - const initials = getInitials(account.displayName || account.label, account.email || account.username); return (