Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix(web): show the Space mark beside the creator in the sidebar switcher

johnnyjoygh0db0025d3207
diff --git a/web/src/components/AppSidebar/SpaceSwitcher.tsx b/web/src/components/AppSidebar/SpaceSwitcher.tsx
index f2206ed1b..d797530ab 100644
--- a/web/src/components/AppSidebar/SpaceSwitcher.tsx
+++ b/web/src/components/AppSidebar/SpaceSwitcher.tsx
@@ -44,6 +44,16 @@ const BrowseLink = ({ to, current, icon: Icon, label }: { to: string; current: b
</Link>
);
+/**
+ * The creator avatar shares the Space mark's slot but draws 2px smaller: a solid circle carries
+ * more visual weight than the pale Space tile, so equal boxes would make the person look larger.
+ */
+const CreatorAvatar = ({ avatarUrl, name, size }: { avatarUrl?: string; name?: string; size: "md" | "header" }) => (
+ <span className={cn("flex shrink-0 items-center justify-center", size === "header" ? "size-6" : "size-7")}>
+ <UserAvatar avatarUrl={avatarUrl} name={name} className={size === "header" ? "size-[22px]" : "size-[26px]"} />
+ </span>
+);
+
function SpaceSwitcher({ className, size = "md" }: { className?: string; size?: "md" | "header" }) {
const t = useTranslate();
const location = useLocation();
@@ -98,8 +108,26 @@ function SpaceSwitcher({ className, size = "md" }: { className?: string; size?:
<MemosLogo compact size={size === "header" ? "header" : "md"} />
) : (
<span className="flex min-w-0 items-center gap-2 overflow-hidden">
- {creatorUsername ? (
- <UserAvatar avatarUrl={selectedCreator?.avatarUrl} name={creatorLabel} className="size-6 shrink-0 rounded-[6px]" />
+ {creatorUsername && selectedSpaceName ? (
+ // With a Space selected, the creator recedes to its avatar (its name stays in the tooltip)
+ // so the Space title keeps the width.
+ <span className="flex shrink-0 items-center gap-1">
+ <CreatorAvatar avatarUrl={selectedCreator?.avatarUrl} name={creatorLabel} size={size} />
+ <svg
+ aria-hidden="true"
+ viewBox="0 0 10 20"
+ className="h-5 w-2.5 shrink-0 text-muted-foreground/35"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={1.25}
+ strokeLinecap="round"
+ >
+ <path d="M8 3 2 17" />
+ </svg>
+ <SpaceMark icon={selectedSpace?.icon} size={size === "header" ? "header" : "md"} />
+ </span>
+ ) : creatorUsername ? (
+ <CreatorAvatar avatarUrl={selectedCreator?.avatarUrl} name={creatorLabel} size={size} />
) : (
<SpaceMark icon={selectedSpace?.icon} size={size === "header" ? "header" : "md"} />
)}
@@ -110,7 +138,7 @@ function SpaceSwitcher({ className, size = "md" }: { className?: string; size?:
size === "header" ? "text-[15px] font-semibold leading-5" : "text-[14px] font-medium leading-4",
)}
>
- {contextLabel}
+ {creatorUsername && selectedSpaceName ? spaceLabel : contextLabel}
</span>
</span>
)}
diff --git a/web/src/components/AttachmentLibrary/AttachmentLibraryPrimitives.tsx b/web/src/components/AttachmentLibrary/AttachmentLibraryPrimitives.tsx
index a28ad7270..5cc114dc5 100644
--- a/web/src/components/AttachmentLibrary/AttachmentLibraryPrimitives.tsx
+++ b/web/src/components/AttachmentLibrary/AttachmentLibraryPrimitives.tsx
@@ -42,7 +42,7 @@ export const AttachmentCreator = ({ creatorName, user }: AttachmentCreatorProps)
className="inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
viewTransition
>
- <UserAvatar className="size-4 rounded-[4px]" avatarUrl={user?.avatarUrl} name={displayName} />
+ <UserAvatar className="size-4" avatarUrl={user?.avatarUrl} name={displayName} />
<span className="truncate">{displayName}</span>
</Link>
);
diff --git a/web/src/components/MemoActionMenu/MemoShareImagePreview.tsx b/web/src/components/MemoActionMenu/MemoShareImagePreview.tsx
index 64b372110..5ff105497 100644
--- a/web/src/components/MemoActionMenu/MemoShareImagePreview.tsx
+++ b/web/src/components/MemoActionMenu/MemoShareImagePreview.tsx
@@ -29,7 +29,7 @@ const MemoShareImagePreview = forwardRef<HTMLDivElement, { width: number }>(({ w
<div className="overflow-hidden rounded-lg border border-border/60 bg-background p-4 sm:p-5">
<div className="flex items-start gap-3">
<div className="flex min-w-0 items-center gap-2.5">
- <UserAvatar avatarUrl={preview.avatarUrl} name={preview.displayName} className="h-8 w-8 rounded-xl" />
+ <UserAvatar avatarUrl={preview.avatarUrl} name={preview.displayName} className="h-8 w-8" />
<div className="min-w-0">
<div className="truncate text-[13px] font-semibold text-foreground">{preview.displayName}</div>
{preview.formattedDisplayTime && <div className="truncate text-xs text-muted-foreground">{preview.formattedDisplayTime}</div>}
diff --git a/web/src/components/MemoView/components/MemoCommentListView.tsx b/web/src/components/MemoView/components/MemoCommentListView.tsx
index b46df357f..8ea58a084 100644
--- a/web/src/components/MemoView/components/MemoCommentListView.tsx
+++ b/web/src/components/MemoView/components/MemoCommentListView.tsx
@@ -61,11 +61,7 @@ const MemoCommentListView: React.FC = () => {
className={METADATA_ROW_CLASSES}
>
<span className={METADATA_ROW_SLOT_CLASSES} aria-hidden="true">
- <UserAvatar
- className="size-4 rounded-[4px]"
- avatarUrl={creator?.avatarUrl}
- name={creator?.displayName || creator?.username}
- />
+ <UserAvatar className="size-4" avatarUrl={creator?.avatarUrl} name={creator?.displayName || creator?.username} />
</span>
<MemoPreview
className="min-w-0 flex-1"
diff --git a/web/src/components/MemoView/components/MemoHeader.tsx b/web/src/components/MemoView/components/MemoHeader.tsx
index b8ee57429..7f5773731 100644
--- a/web/src/components/MemoView/components/MemoHeader.tsx
+++ b/web/src/components/MemoView/components/MemoHeader.tsx
@@ -119,7 +119,7 @@ const CreatorDisplay: React.FC<{ creator: User }> = ({ creator }) => (
viewTransition
>
<span className="flex size-5 shrink-0 items-center justify-center">
- <UserAvatar className="size-5 rounded-[5px]" avatarUrl={creator.avatarUrl} name={creator.displayName || creator.username} />
+ <UserAvatar className="size-5" avatarUrl={creator.avatarUrl} name={creator.displayName || creator.username} />
</span>
<span className="min-w-0 truncate">{creator.displayName || creator.username}</span>
</Link>
diff --git a/web/src/components/MemosLogo.tsx b/web/src/components/MemosLogo.tsx
index c66fff21a..bf8a07a4f 100644
--- a/web/src/components/MemosLogo.tsx
+++ b/web/src/components/MemosLogo.tsx
@@ -33,7 +33,8 @@ function MemosLogo(props: Props) {
compact ? cn("px-0", scale.gap) : collapsed ? "px-1" : "gap-2 px-3",
)}
>
- <UserAvatar className={cn("shrink-0", compact && scale.mark)} avatarUrl={avatarUrl} />
+ {/* The instance logo is a brand, not a person, so it keeps a square mark. */}
+ <UserAvatar className={cn("shrink-0", compact ? scale.mark : "rounded-xl")} avatarUrl={avatarUrl} />
{!collapsed && (
<span
className={cn(
diff --git a/web/src/components/Settings/InviteSpaceMemberDialog.tsx b/web/src/components/Settings/InviteSpaceMemberDialog.tsx
index 4879bd25e..f7a0295b4 100644
--- a/web/src/components/Settings/InviteSpaceMemberDialog.tsx
+++ b/web/src/components/Settings/InviteSpaceMemberDialog.tsx
@@ -149,11 +149,7 @@ const InviteSpaceMemberDialog = ({ open, onOpenChange, space, viewerName, member
: "flex w-full items-center gap-3 rounded-lg border border-border px-3 py-2 text-left transition-colors hover:bg-muted/40 disabled:cursor-not-allowed disabled:opacity-60"
}
>
- <UserAvatar
- className="size-8 rounded-lg"
- avatarUrl={candidate.avatarUrl}
- name={candidate.displayName || candidate.username}
- />
+ <UserAvatar className="size-8" avatarUrl={candidate.avatarUrl} name={candidate.displayName || candidate.username} />
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-medium">{candidate.displayName || `@${candidate.username}`}</p>
<p className="truncate text-xs text-muted-foreground">
diff --git a/web/src/components/Settings/MemberSection.tsx b/web/src/components/Settings/MemberSection.tsx
index 58e8d5163..aa18fd940 100644
--- a/web/src/components/Settings/MemberSection.tsx
+++ b/web/src/components/Settings/MemberSection.tsx
@@ -123,7 +123,7 @@ const MemberSection = () => {
header: t("setting.member.member-column"),
render: (_, user: User) => (
<div className="flex min-w-[18rem] items-start gap-3">
- <UserAvatar className="h-10 w-10 shrink-0 rounded-xl" avatarUrl={user.avatarUrl} name={user.displayName || user.username} />
+ <UserAvatar className="h-10 w-10 shrink-0" avatarUrl={user.avatarUrl} name={user.displayName || user.username} />
<div className="flex min-w-0 flex-1 flex-col">
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
<span
diff --git a/web/src/components/Settings/SpacesSection.tsx b/web/src/components/Settings/SpacesSection.tsx
index 8d124c1fc..cc2e1756f 100644
--- a/web/src/components/Settings/SpacesSection.tsx
+++ b/web/src/components/Settings/SpacesSection.tsx
@@ -66,7 +66,7 @@ const MemberIdentity = ({ member, user, isCurrentUser }: { member: SpaceMember;
return (
<div className="flex min-w-0 items-center gap-3">
- <UserAvatar className="size-10 rounded-xl" avatarUrl={user?.avatarUrl} name={displayName} />
+ <UserAvatar className="size-10" avatarUrl={user?.avatarUrl} name={displayName} />
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-1.5">
<p className="truncate text-sm font-medium">{displayName}</p>
@@ -84,7 +84,7 @@ const InvitationIdentity = ({ invitation, user }: { invitation: SpaceInvitation;
return (
<div className="flex min-w-0 items-center gap-3">
- <UserAvatar className="size-10 rounded-xl" avatarUrl={user?.avatarUrl} name={displayName} />
+ <UserAvatar className="size-10" avatarUrl={user?.avatarUrl} name={displayName} />
<div className="min-w-0">
<p className="truncate text-sm font-medium">{displayName}</p>
<p className="mt-0.5 truncate text-xs text-muted-foreground">@{username}</p>
diff --git a/web/src/components/UserAvatar.tsx b/web/src/components/UserAvatar.tsx
index 4bd35173c..6fad91d43 100644
--- a/web/src/components/UserAvatar.tsx
+++ b/web/src/components/UserAvatar.tsx
@@ -18,7 +18,7 @@ const UserAvatar = (props: Props) => {
return (
<div
className={cn(
- "flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-xl",
+ "flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full",
avatarUrl
? "border border-border"
: title
diff --git a/web/src/components/UserMenu.tsx b/web/src/components/UserMenu.tsx
index 3b232502a..502e118c0 100644
--- a/web/src/components/UserMenu.tsx
+++ b/web/src/components/UserMenu.tsx
@@ -172,7 +172,7 @@ const UserMenu = ({ onClose }: { onClose: () => void }) => {
<>
<div className="flex h-8 items-center gap-2 px-2">
<span className="relative flex size-5 shrink-0 items-center justify-center">
- <UserAvatar avatarUrl={currentUser.avatarUrl} name={accountLabel} className="size-5 rounded-[5px]" />
+ <UserAvatar avatarUrl={currentUser.avatarUrl} name={accountLabel} className="size-5" />
{sseStatus !== "connected" && (
<span
role="img"
diff --git a/web/tests/space-switcher.test.tsx b/web/tests/space-switcher.test.tsx
index cc0a69e51..5ea5073ce 100644
--- a/web/tests/space-switcher.test.tsx
+++ b/web/tests/space-switcher.test.tsx
@@ -161,7 +161,10 @@ describe("SpaceSwitcher", () => {
state.selectedSpace = state.spaces[0];
renderAt("/spaces/product?creator=alice", "header");
const trigger = screen.getByRole("button", { name: "space.switch: Alice / Product" });
- expect(within(trigger).getByText("Alice / Product")).toHaveClass("truncate");
+ // With a Space selected, the creator shows as an avatar only; its name stays in the tooltip.
+ expect(trigger).toHaveAttribute("title", "Alice / Product");
+ expect(within(trigger).queryByText("Alice")).not.toBeInTheDocument();
+ expect(within(trigger).getByText("Product")).toHaveClass("truncate");
expect(trigger).toHaveClass("h-9", "gap-2", "px-2");
openSwitcher();
expect(screen.queryByRole("navigation", { name: "common.browse" })).not.toBeInTheDocument();