Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(core): make better Avatar Ui component, kill unused sizes, use correctly (#3110)

Seamus07d418b55ddc
diff --git a/js/app/packages/app/component/auth/Signup.tsx b/js/app/packages/app/component/auth/Signup.tsx
index 327b056c68..b3d988e196 100644
--- a/js/app/packages/app/component/auth/Signup.tsx
+++ b/js/app/packages/app/component/auth/Signup.tsx
@@ -81,21 +81,16 @@ export function Signup() {
</div>
<div class="w-full max-w-105 login-card">
- <Panel depth={1}>
- <div class="login-stagger">
- <div class="flex items-center justify-center py-10">
- <LogoIcon class="size-20 text-accent" />
- </div>
- <div class="text-center text-lg font-medium">
- Welcome to Macro
- </div>
- <div class="px-8 pb-4 pt-2 text-center text-sm text-ink/60 leading-relaxed">
- Sign up with Google to sync your inbox and set up your
- workspace.
- </div>
- <div class="w-full">
- <LoginOptions signupMode setStage={(_stage: Stage) => {}} />
- </div>
+ <Panel depth={1} class="login-stagger">
+ <div class="flex items-center justify-center py-10">
+ <LogoIcon class="size-20 text-accent" />
+ </div>
+ <div class="text-center text-lg font-medium">Welcome to Macro</div>
+ <div class="px-8 pb-4 pt-2 text-center text-sm text-ink/60 leading-relaxed">
+ Sign up with Google to sync your inbox and set up your workspace.
+ </div>
+ <div class="w-full">
+ <LoginOptions signupMode setStage={(_stage: Stage) => {}} />
</div>
</Panel>
</div>
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
index ac384c4b5c..c77ce02178 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
@@ -162,7 +162,7 @@ export const MobileFilterDrawer = () => {
icon: () => (
<UserIcon
id={contact.id}
- size="xs"
+ size="sm"
suppressClick
showTooltip={false}
/>
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
index 409ea6219d..b8f960b172 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
@@ -87,7 +87,7 @@ function usePersonPicker() {
label:
s.id === uid ? `${s.data.name || 'Me'} (me)` : s.data.name || s.id,
icon: () => (
- <UserIcon id={s.id} size="xs" suppressClick showTooltip={false} />
+ <UserIcon id={s.id} size="sm" suppressClick showTooltip={false} />
),
};
if (s.id === uid) me = opt;
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-operator-autocomplete.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-operator-autocomplete.tsx
index 61e3ff91b9..34ba58633a 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-operator-autocomplete.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-operator-autocomplete.tsx
@@ -57,7 +57,7 @@ export const SearchOperatorAutocomplete = (
? `${c.data.name || 'Me'} (me)`
: c.data.name || c.id,
icon: () => (
- <UserIcon id={c.id} size="xs" suppressClick showTooltip={false} />
+ <UserIcon id={c.id} size="sm" suppressClick showTooltip={false} />
),
};
if (c.id === currentUserId) {
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
index ad98c641da..1ed4709e6f 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
@@ -717,7 +717,7 @@ export const UnifiedFilterDropdown = () => {
icon: () => (
<UserIcon
id={contact.id}
- size="xs"
+ size="sm"
suppressClick
showTooltip={false}
/>
diff --git a/js/app/packages/app/component/settings/Account.tsx b/js/app/packages/app/component/settings/Account.tsx
index b25f0ca30d..e701d5da07 100644
--- a/js/app/packages/app/component/settings/Account.tsx
+++ b/js/app/packages/app/component/settings/Account.tsx
@@ -1,4 +1,3 @@
-import { uploadProfilePicture } from '@core/component/ProfilePicture';
import EditableField from '@core/component/EditableField';
import { capitalize } from '@block-pdf/util/StringUtils';
import { useHasPaidAccess } from '@core/auth/license';
@@ -6,6 +5,8 @@ import { UserIcon } from '@core/component/UserIcon';
import { useLogout } from '@core/auth/logout';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { toast } from '@core/component/Toast/Toast';
+import { staticFileIdEndpoint } from '@core/constant/servers';
+import { createStaticFile } from '@core/util/create';
import { Dialog, Button, Panel } from '@ui';
import {
blockNameToFileExtensions,
@@ -46,6 +47,26 @@ import { invoke } from '@tauri-apps/api/core';
// NOTE: solid directives
false && fileSelector;
+// 16 megabytes
+const MAX_PROFILE_PICTURE_SIZE = 16 * 1000 * 1000;
+
+async function uploadProfilePicture(
+ file: File
+): Promise<{ id: string; url: string } | void> {
+ if (file.size > MAX_PROFILE_PICTURE_SIZE) {
+ return toast.failure('Image size too large');
+ }
+
+ try {
+ const id = await createStaticFile(file);
+ const url = staticFileIdEndpoint(id);
+ await authServiceClient.putProfilePicture({ url });
+ return { id, url };
+ } catch (_error) {
+ return toast.failure('Failed to upload profile picture');
+ }
+}
+
function formatBundleUpdateStatus(status: BundleUpdateStatus): string {
switch (status.status) {
case 'Idle': return 'Idle';
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index 405b26d2c0..a12aaf6d68 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -377,6 +377,11 @@ if (LOCAL_ONLY) {
'hotkey-debugger',
lazy(() => import('@app/component/HotkeyDebugger'))
);
+
+ registerComponent(
+ 'user-icon',
+ lazy(() => import('@core/internal/UserIconDemo'))
+ );
}
if (DEV_MODE_ENV) {
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index a0d379ffbb..40b5dd1398 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -14,9 +14,7 @@ import SplitIcon from '@icon/regular/square-half.svg';
import CloseIcon from '@icon/regular/x.svg';
import { Button } from '@ui/components/Button';
import {
- createEffect,
createMemo,
- createSignal,
type ParentProps,
type Setter,
Show,
@@ -229,24 +227,16 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
);
}
-export function SplitHeaderLeft(props: ParentProps<{ order?: number }>) {
+export function SplitHeaderLeft(props: ParentProps) {
const ctx = useContext(SplitPanelContext);
if (!ctx)
throw new Error('<SplitHeaderLeft> must be used within a <SplitLayout>');
- const [portalRef, setPortalRef] = createSignal<HTMLDivElement | null>(null);
- createEffect(() => {
- const ref = portalRef();
- if (!ref) return;
- ref.style.order = props.order?.toString() ?? '0';
- });
+
return (
<Show when={ctx.layoutRefs.headerLeft}>
<Portal
mount={ctx.layoutRefs.headerLeft}
- ref={(div) => {
- setPortalRef(div);
- div.style.display = 'contents';
- }}
+ ref={(div) => (div.style.display = 'contents')}
>
{props.children}
</Portal>
@@ -254,24 +244,16 @@ export function SplitHeaderLeft(props: ParentProps<{ order?: number }>) {
);
}
-export function SplitHeaderRight(props: ParentProps<{ order?: number }>) {
+export function SplitHeaderRight(props: ParentProps) {
const ctx = useContext(SplitPanelContext);
if (!ctx)
throw new Error('<SplitHeaderRight> must be used within a <SplitLayout>');
- const [portalRef, setPortalRef] = createSignal<HTMLDivElement | null>(null);
- createEffect(() => {
- const ref = portalRef();
- if (!ref) return;
- ref.style.order = props.order?.toString() ?? '0';
- });
+
return (
<Show when={ctx.layoutRefs.headerRight}>
<Portal
mount={ctx.layoutRefs.headerRight}
- ref={(div) => {
- setPortalRef(div);
- div.style.display = 'contents';
- }}
+ ref={(div) => (div.style.display = 'contents')}
>
{props.children}
</Portal>
diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx
index aed7120d76..daf302e871 100644
--- a/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx
+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingParticipants.tsx
@@ -69,7 +69,7 @@ export function CallRecordingParticipantsSection(props: {
<div class="shrink-0">
<UserIcon
id={participant.userId}
- size="xs"
+ size="sm"
isDeleted={false}
/>
</div>
diff --git a/js/app/packages/block-canvas/component/TopBar.tsx b/js/app/packages/block-canvas/component/TopBar.tsx
index d1e8b3682a..d638dd273f 100644
--- a/js/app/packages/block-canvas/component/TopBar.tsx
+++ b/js/app/packages/block-canvas/component/TopBar.tsx
@@ -169,7 +169,9 @@ export function TopBar() {
<BlockItemSplitLabel />
</SplitHeaderLeft>
<SplitHeaderRight>
- <BlockLiveIndicators />
+ <div class="-order-1">
+ <BlockLiveIndicators />
+ </div>
</SplitHeaderRight>
<ResponsivePermissionsBadge />
<ResponsiveBlockToolbar
diff --git a/js/app/packages/block-channel/component/Top.tsx b/js/app/packages/block-channel/component/Top.tsx
index 37a54841a9..c3541579bf 100644
--- a/js/app/packages/block-channel/component/Top.tsx
+++ b/js/app/packages/block-channel/component/Top.tsx
@@ -46,7 +46,7 @@ function TopIcon(props: TopIconProps) {
>
{(recipient) => {
return (
- <UserIcon id={recipient().user_id} isDeleted={false} size="xs" />
+ <UserIcon id={recipient().user_id} isDeleted={false} size="sm" />
);
}}
</Show>
diff --git a/js/app/packages/block-md/component/TopBar.tsx b/js/app/packages/block-md/component/TopBar.tsx
index 83bf191d60..46b0e5d4eb 100644
--- a/js/app/packages/block-md/component/TopBar.tsx
+++ b/js/app/packages/block-md/component/TopBar.tsx
@@ -280,7 +280,9 @@ export function TopBar() {
</SplitHeaderLeft>
<SplitHeaderRight>
- <BlockLiveIndicators />
+ <div class="-order-1">
+ <BlockLiveIndicators />
+ </div>
</SplitHeaderRight>
<ResponsivePermissionsBadge />
diff --git a/js/app/packages/block-pdf/component/TopBar.tsx b/js/app/packages/block-pdf/component/TopBar.tsx
index 198865b796..87bb1e3ce7 100644
--- a/js/app/packages/block-pdf/component/TopBar.tsx
+++ b/js/app/packages/block-pdf/component/TopBar.tsx
@@ -267,7 +267,9 @@ export function TopBar() {
<BlockItemSplitLabel />
</SplitHeaderLeft>
<SplitHeaderRight>
- <BlockLiveIndicators />
+ <div class="-order-1">
+ <BlockLiveIndicators />
+ </div>
</SplitHeaderRight>
<ResponsivePermissionsBadge />
<SplitToolbarLeft>
diff --git a/js/app/packages/channel/Attachments/AttachmentEntityRow.tsx b/js/app/packages/channel/Attachments/AttachmentEntityRow.tsx
index 1c2254d892..db870ccdd3 100644
--- a/js/app/packages/channel/Attachments/AttachmentEntityRow.tsx
+++ b/js/app/packages/channel/Attachments/AttachmentEntityRow.tsx
@@ -24,7 +24,7 @@ export function AttachmentEntityRow(props: {
<Show when={props.senderId}>
{(id) => (
<div class="shrink-0">
- <UserIcon id={id()} size="xs" suppressClick showTooltip />
+ <UserIcon id={id()} size="sm" suppressClick showTooltip />
</div>
)}
</Show>
diff --git a/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx b/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx
index 7196263fee..415d37a3de 100644
--- a/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx
+++ b/js/app/packages/channel/Call/InCallPanel/InCallAvatarPlaceholder.tsx
@@ -5,22 +5,18 @@ import type { UserIconProps } from '@core/component/UserIcon';
import { cn } from '@ui/utils/classname';
export function inCallAvatarPlaceholderClasses(size: UserIconProps['size']) {
- const s = size ?? 'md';
+ const s = size ?? 'sm';
const container = cn(
'flex shrink-0 items-center justify-center rounded-full bg-ink-extra-muted text-panel leading-none',
- s === 'xs' && 'size-4',
- s === 'sm' && 'size-6',
- s === 'md' && 'size-8',
+ s === 'sm' && 'size-4',
+ s === 'md' && 'size-6',
s === 'lg' && 'size-10',
- s === 'xl' && 'size-25',
- s === 'fill' && 'size-8 w-full h-full'
+ s === 'fill' && 'size-full'
);
const icon = cn(
- s === 'xs' && 'w-2 h-2',
- s === 'sm' && 'w-3 h-3',
- s === 'md' && 'w-4 h-4',
+ s === 'sm' && 'w-2 h-2',
+ s === 'md' && 'w-3 h-3',
s === 'lg' && 'w-5 h-5',
- s === 'xl' && 'w-16 h-16',
s === 'fill' && 'w-4 h-4'
);
return { container, icon };
diff --git a/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx b/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx
index 39b4b2963e..d28377b7c3 100644
--- a/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx
+++ b/js/app/packages/channel/Channel/ChannelTopBarLiveIndicators.tsx
@@ -35,7 +35,9 @@ export function ChannelTopBarLiveIndicators() {
return (
<SplitHeaderRight>
- <BlockLiveIndicators />
+ <div class="-order-1">
+ <BlockLiveIndicators />
+ </div>
</SplitHeaderRight>
);
}
diff --git a/js/app/packages/channel/Participants/ParticipantsListItem.tsx b/js/app/packages/channel/Participants/ParticipantsListItem.tsx
index dac8b450a4..5ed9a76cbf 100644
--- a/js/app/packages/channel/Participants/ParticipantsListItem.tsx
+++ b/js/app/packages/channel/Participants/ParticipantsListItem.tsx
@@ -31,10 +31,10 @@ export function ParticipantsListItem(props: {
type="button"
class="flex min-w-0 flex-1 items-center gap-2 rounded-xs px-2 py-1 text-left focus:outline-none"
>
- <div class="shrink-0">
+ <div class="shrink-0 flex items-center">
<UserIcon
id={props.participant.user_id}
- size="xs"
+ size="sm"
isDeleted={false}
/>
</div>
diff --git a/js/app/packages/channel/Thread/ThreadCollapsedIndicator.tsx b/js/app/packages/channel/Thread/ThreadCollapsedIndicator.tsx
index fac1e49e7f..e701e20598 100644
--- a/js/app/packages/channel/Thread/ThreadCollapsedIndicator.tsx
+++ b/js/app/packages/channel/Thread/ThreadCollapsedIndicator.tsx
@@ -69,8 +69,6 @@ export function ThreadCollapsedIndicator(props: ThreadCollapsedIndicatorProps) {
size="fill"
suppressClick
showTooltip={false}
- isDeleted={false}
- fetchUrl={false}
/>
</div>
)}
diff --git a/js/app/packages/core/comments/MessageTopRow.tsx b/js/app/packages/core/comments/MessageTopRow.tsx
index 5920c4c337..74d808d7c6 100644
--- a/js/app/packages/core/comments/MessageTopRow.tsx
+++ b/js/app/packages/core/comments/MessageTopRow.tsx
@@ -88,7 +88,7 @@ export function MessageRowUI(
>
<div class="absolute">
<UserIcon
- size="xs"
+ size="sm"
suppressClick={true}
id={props.authorId}
isDeleted={false}
diff --git a/js/app/packages/core/component/DetailsDrawer.tsx b/js/app/packages/core/component/DetailsDrawer.tsx
index b5421451b7..470a7747d1 100644
--- a/js/app/packages/core/component/DetailsDrawer.tsx
+++ b/js/app/packages/core/component/DetailsDrawer.tsx
@@ -173,7 +173,7 @@ function OwnerValue(props: { ownerId: string }) {
const [displayName] = useDisplayName(tryMacroId(props.ownerId));
return (
<>
- <UserIcon id={props.ownerId} size="xs" showTooltip suppressClick />
+ <UserIcon id={props.ownerId} size="sm" showTooltip suppressClick />
<span class="truncate">{displayName()}</span>
</>
);
diff --git a/js/app/packages/core/component/DocumentPreview.tsx b/js/app/packages/core/component/DocumentPreview.tsx
index 861ad029f0..6ca22db53f 100644
--- a/js/app/packages/core/component/DocumentPreview.tsx
+++ b/js/app/packages/core/component/DocumentPreview.tsx
@@ -278,7 +278,7 @@ function UserInfo(props: { userId: string }) {
<div class="justify-left mt-2 w-fit max-w-[66%] text-ink-muted overflow-hidden whitespace-nowrap text-ellipsis flex items-center gap-1.5">
<UserIconComponent
id={props.userId}
- size="xs"
+ size="sm"
suppressClick
showTooltip={false}
/>
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/UserMention.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/UserMention.tsx
index eaed16d9a1..e21be0b212 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/UserMention.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/UserMention.tsx
@@ -1,7 +1,10 @@
import { cn } from '@ui/utils/classname';
import type { UserMentionDecoratorProps } from '@lexical-core';
-import { useContext } from 'solid-js';
+import { createMemo, useContext } from 'solid-js';
import { LexicalWrapperContext } from '../../context/LexicalWrapperContext';
+import { Tooltip } from '@core/component/Tooltip';
+import { UserTooltip } from '@core/component/UserTooltip';
+import { tryMacroId, macroIdToEmail, useDisplayName } from '@core/user';
export function UserMention(props: UserMentionDecoratorProps) {
const lexicalWrapper = useContext(LexicalWrapperContext);
@@ -13,20 +16,49 @@ export function UserMention(props: UserMentionDecoratorProps) {
return sel.type === 'node' && sel.nodeKeys.has(props.key);
};
+ // Convert String wrapper to primitive string
+ const userId = () => String(props.userId);
+ const propEmail = () => String(props.email);
+
+ const macroId = createMemo(() =>
+ props.userId ? tryMacroId(userId()) : undefined
+ );
+
+ const [displayName] = useDisplayName(macroId());
+
+ const email = createMemo(() => {
+ const id = macroId();
+ if (id) return macroIdToEmail(id);
+ return propEmail();
+ });
+
return (
- <span
- class={cn(
- 'relative py-0.5 px-0.5 cursor-default rounded-xs bg-accent/8 hover:bg-accent/20 focus:bg-accent/20 text-accent-ink',
- isSelectedAsNode() && 'bg-active'
+ <Tooltip
+ placement="top"
+ unstyled
+ tooltip={(close) => (
+ <UserTooltip
+ displayName={displayName() || email() || propEmail()}
+ email={email() || propEmail()}
+ id={userId()}
+ onClose={close}
+ />
)}
>
<span
- data-user-id={props.userId}
- data-email={props.email}
- data-user-mention="true"
+ class={cn(
+ 'relative py-0.5 px-0.5 cursor-default rounded-xs bg-accent/8 hover:bg-accent/20 focus:bg-accent/20 text-accent-ink',
+ isSelectedAsNode() && 'bg-active'
+ )}
>
- @{props.email.split('@')[0]}
+ <span
+ data-user-id={props.userId}
+ data-email={props.email}
+ data-user-mention="true"
+ >
+ @{propEmail().split('@')[0]}
+ </span>
</span>
- </span>
+ </Tooltip>
);
}
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
index 4e6e422993..0565cf883d 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
@@ -35,7 +35,7 @@ export function MentionsMenuItem(props: {
const icon = () => {
switch (props.item.kind) {
case 'user':
- return <UserIcon id={props.item.id} size="xs" isDeleted={false} />;
+ return <UserIcon id={props.item.id} size="sm" isDeleted={false} />;
case 'group':
return <UsersIcon class="size-4 text-ink-muted" />;
@@ -82,11 +82,11 @@ export function MentionsMenuItem(props: {
e.stopPropagation();
}}
on:mousemove={() => props.setIndex(props.index)}
- class={cn('group flex items-center p-1.5 mx-1.5 rounded-xs', {
+ class={cn('group flex items-center p-1.5 mx-1.5 rounded-sm', {
'bg-hover': props.selected,
})}
>
- <div class="mr-2">{icon()}</div>
+ <div class="mr-2 flex items-center">{icon()}</div>
<span
class="ph-no-capture text-ink text-xs sm:text-sm font-medium grow overflow-hidden text-nowrap"
style={{ 'text-overflow': 'ellipsis' }}
diff --git a/js/app/packages/core/component/LiveIndicators.tsx b/js/app/packages/core/component/LiveIndicators.tsx
index 699748944f..d18c76c727 100644
--- a/js/app/packages/core/component/LiveIndicators.tsx
+++ b/js/app/packages/core/component/LiveIndicators.tsx
@@ -2,68 +2,47 @@ import { ENABLE_LIVE_INDICATORS } from '@core/constant/featureFlags';
import { useUserId } from '@core/context/user';
import { createMemo, For, Show } from 'solid-js';
import { useUserIndicators } from '../state/liveIndicators';
-import { Tooltip } from './Tooltip';
import { UserIcon } from './UserIcon';
+import { AvatarGroup } from '@ui';
const MAX_USER_INDICATORS = 3;
-export function UserIndicator(props: { userId: string }) {
- return (
- <Tooltip tooltip={props.userId?.split('|').at(1)?.split('@')[0]}>
- <div class="bg-panel size-6 rounded-full p-[2px] -mr-3">
- <UserIcon id={props.userId} isDeleted={false} size="fill" />
- </div>
- </Tooltip>
- );
-}
-
export function LiveIndicators(props: {
userIds: string[];
currentUserId?: string;
}) {
- const userIds = () =>
+ const userIds = createMemo(() =>
props.currentUserId
? props.userIds.filter((id) => id !== props.currentUserId)
- : props.userIds;
+ : props.userIds
+ );
- const remaining = createMemo(() => {
- if (userIds().length < MAX_USER_INDICATORS) return undefined;
- return userIds().length - MAX_USER_INDICATORS;
- });
- const len = createMemo(() => userIds().length);
+ const displayUserIds = () => userIds().slice(0, MAX_USER_INDICATORS);
+ const remaining = createMemo(() =>
+ Math.max(0, userIds().length - MAX_USER_INDICATORS)
+ );
return (
- <div
- class="flex items-center h-full shrink-0 overflow-hidden w-fit isolate"
- classList={{
- 'pl-2 pr-4': len() > 0,
- 'width-0': len() === 0,
- }}
- >
- <For each={userIds().splice(0, 3)}>
- {(userId) => <UserIndicator userId={userId} />}
- </For>
- <Show when={remaining()}>
- <div class="z-placeable">
- <Tooltip
- tooltip={userIds()
- .slice(MAX_USER_INDICATORS)
- .map((user) => user.split('|').at(1)?.split('@')[0])
- .join(', ')}
- >
- <div class="size-6 bg-menu border-2 text-xxs -mr-3 border-panel rounded-full flex flex-col justify-center items-center">
- <span>{`+${remaining()}`}</span>
- </div>
- </Tooltip>
- </div>
- </Show>
- </div>
+ <Show when={userIds().length > 0}>
+ <AvatarGroup size="sm" class="pl-2 pr-1">
+ <For each={displayUserIds()}>
+ {(userId) => (
+ <UserIcon id={userId} size="sm" showTooltip suppressClick />
+ )}
+ </For>
+
+ <Show when={remaining()}>
+ <AvatarGroup.Count size="sm">+{remaining()}</AvatarGroup.Count>
+ </Show>
+ </AvatarGroup>
+ </Show>
);
}
export function BlockLiveIndicators() {
const indicators = useUserIndicators();
const userId = useUserId();
+
return (
<Show when={ENABLE_LIVE_INDICATORS}>
<LiveIndicators userIds={indicators() ?? []} currentUserId={userId()} />
diff --git a/js/app/packages/core/component/ProfilePicture.tsx b/js/app/packages/core/component/ProfilePicture.tsx
deleted file mode 100644
index 1b847a3b94..0000000000
--- a/js/app/packages/core/component/ProfilePicture.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import { cn } from '@ui/utils/classname';
-import { toast } from '@core/component/Toast/Toast';
-import { ENABLE_PROFILE_PICTURES } from '@core/constant/featureFlags';
-import {
- staticFileIdEndpoint,
- staticFileSizedUrl,
-} from '@core/constant/servers';
-import { internalDrag } from '@core/directive/internalDragState';
-false && internalDrag;
-import { useProfilePictureUrl } from '@core/signal/profilePicture';
-import { idToEmail } from '@core/user';
-import { createStaticFile } from '@core/util/create';
-import { authServiceClient } from '@service-auth/client';
-import { createMemo, Show } from 'solid-js';
-import type { SizeClass } from './UserIcon';
-
-type ProfilePictureProps = {
- id?: string;
- sizeClass: SizeClass;
- email?: string;
- // TODO: remove. Not being used.
- imageUrl?: string;
- fetchUrl?: boolean;
-};
-
-// 16 megabytes
-const MAX_FILE_SIZE = 16 * 1000 * 1000;
-
-export async function uploadProfilePicture(
- file: File
-): Promise<{ id: string; url: string } | void> {
- if (file.size > MAX_FILE_SIZE) {
- return toast.failure('Image size too large');
- }
-
- try {
- const id = await createStaticFile(file);
- const url = staticFileIdEndpoint(id);
- await authServiceClient.putProfilePicture({ url });
- return { id, url };
- } catch (_error) {
- return toast.failure('Failed to upload profile picture');
- }
-}
-
-export function ProfilePicture(props: ProfilePictureProps) {
- const email = createMemo(() => {
- const id = props.id;
- if (!id) {
- return props.email || 'User';
- }
-
- return idToEmail(id);
- });
-
- if (!ENABLE_PROFILE_PICTURES) {
- return (
- <div class={cn('shrink-0', props.sizeClass.text)}>
- {email().substring(0, 1).toUpperCase()}
- </div>
- );
- }
-
- const [profilePicUrl] = useProfilePictureUrl(props.id);
- return (
- <Show
- when={profilePicUrl()}
- fallback={
- <div
- class={cn(
- 'shrink-0 flex items-center justify-center',
- props.sizeClass.container
- )}
- style={{
- 'line-height': 0,
- }}
- >
- <span class={props.sizeClass.text}>
- {email().substring(0, 1).toUpperCase()}
- </span>
- </div>
- }
- keyed
- >
- {(url) => {
- const smallUrl = staticFileSizedUrl(url, 'small');
- return (
- <div
- class={cn(
- 'shrink-0 overflow-hidden rounded-full',
- props.sizeClass.container
- )}
- >
- <img
- src={smallUrl}
- class="object-cover rounded-full w-full h-full origin-[50%_20%]"
- use:internalDrag={true}
- onError={(e) => {
- if (e.currentTarget.src !== url) {
- e.currentTarget.src = url;
- }
- }}
- />
- </div>
- );
- }}
- </Show>
- );
-}
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
index af394835e0..5880aaf700 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx
@@ -483,13 +483,13 @@ export function PropertyEntitySelector(props: EntityInputProps) {
}}
>
<div class="flex items-center gap-2 flex-1 min-w-0">
- <div class="size-4 shrink-0">
+ <div class="size-4 shrink-0 flex items-center">
<Show
when={entity.kind === 'entity'}
fallback={
<UserIcon
id={entity.id}
- size="xs"
+ size="sm"
isDeleted={false}
suppressClick={true}
/>
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/UserGroup.tsx b/js/app/packages/core/component/Properties/component/propertyValue/UserGroup.tsx
index c11353c5c5..a8a894b86e 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/UserGroup.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/UserGroup.tsx
@@ -1,46 +1,45 @@
import { createMemo, For, Show } from 'solid-js';
+import { AvatarGroup } from '@ui';
import type { EntityReference } from '../../types';
import { UserIcon } from '@core/component/UserIcon';
-type UserEntityPillProps = {
+type UserEntityGroupProps = {
entities: EntityReference[];
maxUsers?: number;
};
/**
- * Pill for multiselect user entity properties that shows user avatars in LiveIndicators style
+ * Group display for multiselect user entity properties.
+ * Shows user avatars in an overlapping style.
+ *
+ * Uses --avatar-group-separator CSS variable for the separator color,
+ * allowing parent containers to override on hover states.
*/
-export const UserGroup = (props: UserEntityPillProps) => {
+export const UserGroup = (props: UserEntityGroupProps) => {
const max = () => props.maxUsers ?? 3;
- const remaining = createMemo(() => {
- if (props.entities.length <= max()) return undefined;
- return props.entities.length - max();
- });
+
+ const remaining = createMemo(() =>
+ Math.max(0, props.entities.length - max())
+ );
const displayEntities = () => props.entities.slice(0, max());
return (
- <div class="flex items-center shrink-0 w-fit">
+ <AvatarGroup size="sm">
<For each={displayEntities()}>
{(entity) => (
- <div class="bg-panel rounded-full">
- <UserIcon
- id={entity.entity_id}
- isDeleted={false}
- size="xs"
- suppressClick
- showTooltip={false}
- />
- </div>
+ <UserIcon
+ id={entity.entity_id}
+ size="sm"
+ suppressClick
+ showTooltip={false}
+ />
)}
</For>
+
<Show when={remaining()}>
- <div class="z-placeable">
- <div class="size-5 bg-menu border-2 text-[10px] -mr-2 text-ink border-panel rounded-full flex flex-col justify-center items-center">
- <span>+{remaining()}</span>
- </div>
- </div>
+ <AvatarGroup.Count size="sm">+{remaining()}</AvatarGroup.Count>
</Show>
- </div>
+ </AvatarGroup>
);
};
diff --git a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx
index 22d1028c19..c15472cefe 100644
--- a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx
+++ b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx
@@ -113,7 +113,7 @@ export function usePropertyEntityDisplay(
const icon = createMemo(() =>
match(entityType())
- .with('USER', () => <UserIcon id={entityId()} size="xs" />)
+ .with('USER', () => <UserIcon id={entityId()} size="sm" />)
.with('CHANNEL', () => <CoreEntityIcon targetType="channel" size="xs" />)
.with('TASK', () => <CoreEntityIcon targetType="task" size="xs" />)
.with('DOCUMENT', () => {
diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsx
index 2ff07bf803..d5c89de209 100644
--- a/js/app/packages/core/component/RecipientSelector.tsx
+++ b/js/app/packages/core/component/RecipientSelector.tsx
@@ -190,7 +190,7 @@ function RecipientComboboxItem(props: RecipientComboboxItemProps): JSX.Element {
return (
<Combobox.ItemLabel class="flex flex-row w-full items-center gap-1.5 text-ink-muted select-none text-sm">
- <UserIcon id={iconId ?? ''} size="sm" isDeleted={false} />
+ <UserIcon id={iconId ?? ''} size="md" isDeleted={false} />
<p
class={cn(
'ph-no-capture truncate my-auto',
@@ -538,7 +538,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
icon={
<UserIcon
id={opt.id}
- size="xs"
+ size="sm"
isDeleted={false}
showTooltip={false}
/>
@@ -597,7 +597,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
icon={
<UserIcon
id={email}
- size="xs"
+ size="sm"
isDeleted={false}
showTooltip={false}
/>
diff --git a/js/app/packages/core/component/References.tsx b/js/app/packages/core/component/References.tsx
index 05b50762a3..8773335855 100644
--- a/js/app/packages/core/component/References.tsx
+++ b/js/app/packages/core/component/References.tsx
@@ -207,7 +207,7 @@ export function References(props: ReferenceProps) {
</div>
<span class="inline-flex items-center gap-2 pl-4 text-sm">
- <UserIcon id={ref.sender_id} size="xs" isDeleted={false} />
+ <UserIcon id={ref.sender_id} size="sm" isDeleted={false} />
<span class="font-medium text-ink">{userName()}</span>
<span class="text-ink-extra-muted">
{hasMessageContent ? 'referenced in' : 'attached in'}
@@ -248,7 +248,7 @@ export function References(props: ReferenceProps) {
</div>
<span class="inline-flex items-center gap-1 text-sm pl-4">
- <UserIcon id={userId} size="xs" isDeleted={false} />
+ <UserIcon id={userId} size="sm" isDeleted={false} />
<span class="font-medium text-ink">{userName()}</span>
<span class="text-ink-extra-muted">mentioned in</span>
<InlineItemPreview
diff --git a/js/app/packages/core/component/StackedAvatarsRow.tsx b/js/app/packages/core/component/StackedAvatarsRow.tsx
index 4ee47bcb80..07c1e525ff 100644
--- a/js/app/packages/core/component/StackedAvatarsRow.tsx
+++ b/js/app/packages/core/component/StackedAvatarsRow.tsx
@@ -18,12 +18,10 @@ export type StackedAvatarsSize = NonNullable<UserIconProps['size']>;
/** `distribute="fill"`: face + chip footprint in px (matches Tailwind `size-*` at default rem). */
const AVATAR_DIAMETER_PX: Record<StackedAvatarsSize, number> = {
- xs: 16,
- sm: 24,
- md: 32,
+ sm: 16,
+ md: 24,
lg: 40,
- xl: 100,
- fill: 32,
+ fill: 24,
};
/** Horizontal row shell: stacking context (`isolate`). */
@@ -50,7 +48,7 @@ const STACK_STYLE: Record<
defaultEmptyIcon: string;
}
> = {
- xs: {
+ sm: {
overlap: '-mr-1.5',
overflowChip:
'size-4 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
@@ -60,7 +58,7 @@ const STACK_STYLE: Record<
'bg-panel size-4 rounded-full p-[1px] border-2 border-panel box-border',
defaultEmptyIcon: 'w-2 h-2',
},
- sm: {
+ md: {
overlap: '-mr-2',
overflowChip:
'size-6 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
@@ -70,16 +68,6 @@ const STACK_STYLE: Record<
'bg-panel size-6 rounded-full p-[2px] border-2 border-panel box-border',
defaultEmptyIcon: 'w-3 h-3',
},
- md: {
- overlap: '-mr-3',
- overflowChip:
- 'size-8 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
- overflowChipText:
- 'text-xs font-semibold tabular-nums leading-none text-ink',
- inner:
- 'bg-panel size-8 rounded-full p-[2px] border-2 border-panel box-border',
- defaultEmptyIcon: 'w-4 h-4',
- },
lg: {
overlap: '-mr-4',
overflowChip:
@@ -90,42 +78,32 @@ const STACK_STYLE: Record<
'bg-panel size-10 rounded-full p-[2px] border-2 border-panel box-border',
defaultEmptyIcon: 'w-5 h-5',
},
- xl: {
- overlap: '-mr-10',
- overflowChip:
- 'size-25 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
- overflowChipText:
- 'text-lg font-semibold tabular-nums leading-none text-ink',
- inner:
- 'bg-panel size-25 rounded-full p-[2px] border-2 border-panel box-border',
- defaultEmptyIcon: 'w-16 h-16',
- },
fill: {
- overlap: '-mr-3',
+ overlap: '-mr-2',
overflowChip:
- 'size-8 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
+ 'size-6 shrink-0 rounded-full border-2 border-panel bg-menu flex flex-col items-center justify-center',
overflowChipText:
- 'text-xs font-semibold tabular-nums leading-none text-ink',
+ 'text-[10px] font-semibold tabular-nums leading-none text-ink',
inner:
- 'bg-panel size-8 rounded-full p-[2px] border-2 border-panel box-border',
- defaultEmptyIcon: 'w-4 h-4',
+ 'bg-panel size-6 rounded-full p-[2px] border-2 border-panel box-border',
+ defaultEmptyIcon: 'w-3 h-3',
},
};
/** Inner ring around `UserIcon` (no overlap margin — the row applies overlap on a wrapper). */
-export function stackedAvatarInnerClass(size: StackedAvatarsSize = 'md') {
+export function stackedAvatarInnerClass(size: StackedAvatarsSize = 'sm') {
return STACK_STYLE[size].inner;
}
/** Default +N chip shell (no text); pair with {@link stackedAvatarOverflowChipTextClass}. */
export function stackedAvatarOverflowChipClass(
- size: StackedAvatarsSize = 'md'
+ size: StackedAvatarsSize = 'sm'
) {
return STACK_STYLE[size].overflowChip;
}
export function stackedAvatarOverflowChipTextClass(
- size: StackedAvatarsSize = 'md'
+ size: StackedAvatarsSize = 'sm'
) {
return STACK_STYLE[size].overflowChipText;
}
@@ -214,7 +192,7 @@ function defaultOverflowChip(
export function StackedAvatarsRow<T = unknown>(
props: StackedAvatarsRowProps<T>
) {
- const size = () => props.size ?? 'md';
+ const size = () => props.size ?? 'sm';
const distributeFill = () => props.distribute === 'fill';
diff --git a/js/app/packages/core/component/TopBar/ShareButton.tsx b/js/app/packages/core/component/TopBar/ShareButton.tsx
index bc5fc45d70..e92092e6f5 100644
--- a/js/app/packages/core/component/TopBar/ShareButton.tsx
+++ b/js/app/packages/core/component/TopBar/ShareButton.tsx
@@ -201,7 +201,7 @@ function DmRecipientIcon(props: { channelId: string }) {
fallback={<UserCircle class="shrink-0 w-4 h-4" />}
>
{(id) => (
- <UserIcon id={id()} size="xs" isDeleted={false} showTooltip={false} />
+ <UserIcon id={id()} size="sm" isDeleted={false} showTooltip={false} />
)}
</Show>
);
@@ -391,7 +391,7 @@ function MobileShareDrawer(props: MobileShareDrawerProps) {
<Show when={props.owner}>
<div class="flex justify-between">
<div class="flex items-center gap-2 overflow-hidden">
- <UserIcon isDeleted={false} id={props.owner!} size="xs" />
+ <UserIcon isDeleted={false} id={props.owner!} size="sm" />
<div class="font-medium truncate">
{props.formattedOwner}
</div>
@@ -1018,7 +1018,7 @@ export function ShareModal(props: ShareModalProps) {
<UserIcon
isDeleted={false}
id={props.owner!}
- size="xs"
+ size="sm"
/>
<div class="font-medium truncate">
{formattedOwner()}
diff --git a/js/app/packages/core/component/UserGroup.tsx b/js/app/packages/core/component/UserGroup.tsx
index 744acd3a7b..bb79c5883e 100644
--- a/js/app/packages/core/component/UserGroup.tsx
+++ b/js/app/packages/core/component/UserGroup.tsx
@@ -1,98 +1,51 @@
import { createMemo, For, Show } from 'solid-js';
+import { AvatarGroup, type AvatarGroupSize } from '@ui';
import { UserIcon } from './UserIcon';
-import { cn } from '@ui/utils/classname';
-import { match } from 'ts-pattern';
+
+export type UserGroupSize = AvatarGroupSize;
export type UserGroupProps = {
userIds: string[];
maxUsers?: number;
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
+ size?: UserGroupSize;
suppressClick?: boolean;
showTooltip?: boolean;
};
/**
- * Displays a group of user avatars in an overlapping style with an overflow indicator
+ * Displays a group of user avatars in an overlapping style with an overflow indicator.
+ *
+ * Uses --avatar-group-separator CSS variable for ring color (defaults to --color-panel).
+ * Parent containers can override to match hover backgrounds:
+ *
+ * @example
+ * <div class="hover:bg-hover hover:[--avatar-group-separator:var(--color-hover)]">
+ * <UserGroup userIds={ids} />
+ * </div>
*/
export function UserGroup(props: UserGroupProps) {
const max = () => props.maxUsers ?? 3;
- const size = () => props.size ?? 'xs';
-
- const remaining = createMemo(() => {
- if (props.userIds.length <= max()) return undefined;
- return props.userIds.length - max();
- });
+ const size = () => props.size ?? 'sm';
+ const remaining = createMemo(() => Math.max(0, props.userIds.length - max()));
const displayUserIds = () => props.userIds.slice(0, max());
- const sizeClasses = () => {
- return match(size())
- .with('xs', () => ({
- userIcon: 'size-4',
- wrapper: 'p-[2px]',
- overlap: '-mr-3',
- counter: 'size-5 text-[10px] -mr-2 border-2',
- }))
- .with('sm', () => ({
- userIcon: 'size-6',
- wrapper: 'p-[2px]',
- overlap: '-mr-4',
- counter: 'size-6 text-xs -mr-3 border-2',
- }))
- .with('md', () => ({
- userIcon: 'size-8',
- wrapper: 'p-[3px]',
- overlap: '-mr-5',
- counter: 'size-8 text-sm -mr-4 border-2',
- }))
- .with('lg', () => ({
- userIcon: 'size-10',
- wrapper: 'p-[3px]',
- overlap: '-mr-6',
- counter: 'size-10 text-base -mr-5 border-2',
- }))
- .with('xl', () => ({
- userIcon: 'size-25',
- wrapper: 'p-1',
- overlap: '-mr-16',
- counter: 'size-20 text-2xl -mr-12 border-4',
- }))
- .exhaustive();
- };
-
return (
- <div class="flex items-center shrink-0 w-fit pr-3">
+ <AvatarGroup size={size()}>
<For each={displayUserIds()}>
{(userId) => (
- <div
- class={cn(
- 'bg-panel rounded-full',
- sizeClasses().wrapper,
- sizeClasses().overlap
- )}
- >
- <UserIcon
- id={userId}
- isDeleted={false}
- size={size()}
- suppressClick={props.suppressClick}
- showTooltip={props.showTooltip ?? false}
- />
- </div>
+ <UserIcon
+ id={userId}
+ size={size()}
+ suppressClick={props.suppressClick}
+ showTooltip={props.showTooltip ?? false}
+ />
)}
</For>
+
<Show when={remaining()}>
- <div class="z-placeable">
- <div
- class={cn(
- 'bg-menu text-ink border-panel rounded-full flex flex-col justify-center items-center',
- sizeClasses().counter
- )}
- >
- <span>+{remaining()}</span>
- </div>
- </div>
+ <AvatarGroup.Count size={size()}>+{remaining()}</AvatarGroup.Count>
</Show>
- </div>
+ </AvatarGroup>
);
}
diff --git a/js/app/packages/core/component/UserIcon.tsx b/js/app/packages/core/component/UserIcon.tsx
index ed64c703eb..e1a312b775 100644
--- a/js/app/packages/core/component/UserIcon.tsx
+++ b/js/app/packages/core/component/UserIcon.tsx
@@ -1,160 +1,240 @@
-import { macroIdToEmail, tryMacroId, useDisplayName } from '@core/user';
+import {
+ macroIdToEmail,
+ tryMacroId,
+ useDisplayName,
+ useDisplayNameParts,
+} from '@core/user';
import { isOk } from '@core/util/maybeResult';
import Trash from '@phosphor-icons/core/regular/trash.svg?component-solid';
import { commsServiceClient } from '@service-comms/client';
import { createMemo, Match, Show, Switch } from 'solid-js';
import { useSplitLayout } from '../../app/component/split-layout/layout';
-import { ProfilePicture } from './ProfilePicture';
import { Tooltip } from './Tooltip';
import { UserTooltip } from './UserTooltip';
-import { cn } from '@ui/utils/classname';
+import { Avatar, type AvatarSize } from '@ui';
+import { ENABLE_PROFILE_PICTURES } from '@core/constant/featureFlags';
+import { staticFileSizedUrl } from '@core/constant/servers';
+import { internalDrag } from '@core/directive/internalDragState';
+import { useProfilePictureUrl } from '@core/signal/profilePicture';
+
+export type UserIconSize = AvatarSize;
export type UserIconProps = {
isDeleted?: boolean;
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'fill';
+ size?: UserIconSize;
suppressClick?: boolean;
showTooltip?: boolean;
- // TODO: remove imageUrl. not actively used.
- imageURL?: string;
- fetchUrl?: boolean;
class?: string;
} & ({ id: string; email?: never } | { email: string; id?: never });
-export type SizeClass = {
- container: string;
- icon: string;
- text: string;
-};
+function getInitials(
+ firstName: string,
+ lastName: string,
+ email: string
+): string {
+ const first = firstName.trim();
+ const last = lastName.trim();
-export function UserIcon(props: UserIconProps) {
- const displayName = createMemo(() => {
- if (!props.id) return () => props.email;
- const [displayName] = useDisplayName(tryMacroId(props.id));
- return displayName;
- });
+ if (first && last) {
+ return (first[0] + last[0]).toUpperCase();
+ }
+ if (first) {
+ return first[0].toUpperCase();
+ }
+ return email.substring(0, 1).toUpperCase();
+}
+
+/**
+ * Internal render. Image or fallback.
+ */
+function ProfileImage(props: { id?: string; email?: string }) {
+ const macroId = createMemo(() =>
+ props.id ? tryMacroId(props.id) : undefined
+ );
const email = createMemo(() => {
- const macroId = props.id && tryMacroId(props.id);
- if (macroId) {
- return macroIdToEmail(macroId);
+ if (props.id) {
+ const id = tryMacroId(props.id);
+ return id ? macroIdToEmail(id) : props.email || 'User';
}
- if (props.email) return props.email;
+ return props.email || 'User';
});
- const sizeClasses = createMemo(() => {
- switch (props.size || 'md') {
- case 'xs':
- return {
- container: 'size-4',
- icon: 'w-2 h-2',
- text: 'text-[8px] leading-none',
- };
- case 'sm':
- return {
- container: 'size-6',
- icon: 'w-3 h-3',
- text: 'text-xs leading-none',
- };
- case 'md':
- return {
- container: 'size-8',
- icon: 'w-4 h-4',
- text: 'text-lg leading-none',
- };
- case 'lg':
- return {
- container: 'size-10',
- icon: 'w-5 h-5',
- text: 'text-lg leading-none',
- };
- case 'xl':
- return {
- container: 'size-25',
- icon: 'w-16 h-16',
- text: 'text-[48px] leading-none',
- };
- case 'fill':
- return {
- container: 'w-full h-full @container',
- icon: 'w-full h-full',
- text: 'text-[min(calc(50cqw),3rem)] leading-none',
- };
- }
+ const { firstName, lastName } = useDisplayNameParts(macroId());
+
+ const initials = () => getInitials(firstName(), lastName(), email());
+
+ if (!ENABLE_PROFILE_PICTURES) {
+ return (
+ <Avatar.Fallback class="font-semibold">{initials()}</Avatar.Fallback>
+ );
+ }
+
+ const [profilePicUrl] = useProfilePictureUrl(props.id);
+
+ return (
+ <Show
+ when={profilePicUrl()}
+ fallback={
+ <Avatar.Fallback class="font-semibold">{initials()}</Avatar.Fallback>
+ }
+ keyed
+ >
+ {(url) => (
+ <Avatar.Image
+ src={staticFileSizedUrl(url, 'small')}
+ onError={(e) => {
+ if (e.currentTarget.src !== url) {
+ e.currentTarget.src = url;
+ }
+ }}
+ ref={(el) => internalDrag(el)}
+ />
+ )}
+ </Show>
+ );
+}
+
+/**
+ * Avatar content based on user state (deleted, has id, has email, or unknown).
+ */
+function UserIconContent(props: {
+ id?: string;
+ email?: string;
+ isDeleted?: boolean;
+}) {
+ return (
+ <Switch>
+ <Match when={props.isDeleted}>
+ <Trash />
+ </Match>
+ <Match when={props.id} keyed>
+ {(id) => <ProfileImage id={id} />}
+ </Match>
+ <Match when={!props.id && props.email} keyed>
+ {(email) => <ProfileImage email={email} />}
+ </Match>
+ <Match when={!props.id && !props.email}>
+ <Avatar.Fallback class="font-semibold">?</Avatar.Fallback>
+ </Match>
+ </Switch>
+ );
+}
+
+/**
+ * User avatar with profile picture, tooltip, and DM click behavior.
+ * For pure styling without user-specific behavior, use `<Avatar>` from @ui.
+ */
+export function UserIcon(props: UserIconProps) {
+ const size = () => props.size ?? 'md';
+
+ const macroId = createMemo(() =>
+ props.id ? tryMacroId(props.id) : undefined
+ );
+
+ const [displayName] = useDisplayName(macroId());
+
+ const email = createMemo(() => {
+ const id = macroId();
+ if (id) return macroIdToEmail(id);
+ return props.email;
});
const { replaceOrInsertSplit } = useSplitLayout();
const getOrCreateDm = async () => {
- if (props.id) {
- const result = await commsServiceClient.getOrCreateDirectMessage({
- recipient_id: props.id,
- });
- const channelId = isOk(result) && result[1]?.channel_id;
- if (channelId) {
- replaceOrInsertSplit({
- type: 'channel',
- id: channelId,
- });
- }
- }
+ if (!props.id) return;
+
+ const result = await commsServiceClient.getOrCreateDirectMessage({
+ recipient_id: props.id,
+ });
+
+ const channelId = isOk(result) && result[1]?.channel_id;
+ if (!channelId) return;
+
+ replaceOrInsertSplit({ type: 'channel', id: channelId });
};
- const icon = createMemo(() => (
- <div
- onMouseDown={props.suppressClick ? undefined : getOrCreateDm}
- class={cn(
- 'relative shrink-0 overflow-hidden rounded-full bg-ink-extra-muted text-panel',
- sizeClasses().container,
- props.class
- )}
- >
- <div class="absolute inset-0 flex min-h-0 min-w-0 items-center justify-center">
- <Switch>
- <Match when={props.isDeleted}>
- <div class="flex size-full min-h-0 min-w-0 items-center justify-center rounded-full bg-ink-extra-muted/50">
- <Trash class={cn(sizeClasses().icon, 'block shrink-0')} />
- </div>
- </Match>
- <Match when={props.id} keyed>
- {(id) => <ProfilePicture id={id} sizeClass={sizeClasses()} />}
- </Match>
- <Match when={!props.id && props.email} keyed>
- {(email) => (
- <ProfilePicture
- id={undefined}
- email={email}
- sizeClass={sizeClasses()}
- />
- )}
- </Match>
- </Switch>
- </div>
- </div>
- ));
+ const showTooltip = () => props.showTooltip !== false;
+ const hasTooltipContent = () => displayName() || email();
+
+ const triggerClass = () =>
+ size() === 'fill' ? 'size-full' : 'inline-flex shrink-0';
return (
- <Show
- when={
- props.showTooltip !== false && (displayName().length > 0 || email())
- }
- fallback={icon()}
- >
- <Tooltip
- placement="left"
- class={sizeClasses().container}
- unstyled
- tooltip={(close) => (
- <UserTooltip
- displayName={displayName()() || ''}
- email={email()}
+ <Switch>
+ <Match when={!showTooltip() || !hasTooltipContent()}>
+ <Avatar
+ size={size()}
+ class={props.class}
+ onMouseDown={props.suppressClick ? undefined : getOrCreateDm}
+ >
+ <UserIconContent
id={props.id}
+ email={props.email}
isDeleted={props.isDeleted}
- onClose={close}
/>
+ </Avatar>
+ </Match>
+
+ <Match when={macroId()} keyed>
+ {(id) => (
+ <Tooltip
+ placement="left"
+ class={triggerClass()}
+ unstyled
+ tooltip={(close) => (
+ <UserTooltip
+ displayName={displayName() || email() || ''}
+ email={email()}
+ id={id}
+ isDeleted={props.isDeleted}
+ onClose={close}
+ />
+ )}
+ >
+ <Avatar
+ size={size()}
+ class={props.class}
+ onMouseDown={props.suppressClick ? undefined : getOrCreateDm}
+ >
+ <UserIconContent
+ id={id}
+ email={props.email}
+ isDeleted={props.isDeleted}
+ />
+ </Avatar>
+ </Tooltip>
)}
- >
- {icon()}
- </Tooltip>
- </Show>
+ </Match>
+
+ <Match when={email()}>
+ <Tooltip
+ placement="left"
+ class={triggerClass()}
+ unstyled
+ tooltip={(close) => (
+ <UserTooltip
+ displayName={email() || ''}
+ email={email()}
+ isDeleted={props.isDeleted}
+ onClose={close}
+ />
+ )}
+ >
+ <Avatar
+ size={size()}
+ class={props.class}
+ onMouseDown={props.suppressClick ? undefined : getOrCreateDm}
+ >
+ <UserIconContent
+ id={props.id}
+ email={props.email}
+ isDeleted={props.isDeleted}
+ />
+ </Avatar>
+ </Tooltip>
+ </Match>
+ </Switch>
);
}
diff --git a/js/app/packages/core/component/UserTooltip.tsx b/js/app/packages/core/component/UserTooltip.tsx
index ab42f164ab..2aab05f4ef 100644
--- a/js/app/packages/core/component/UserTooltip.tsx
+++ b/js/app/packages/core/component/UserTooltip.tsx
@@ -6,13 +6,12 @@ import IconCheck from '@icon/regular/check.svg';
import WideCopy from '@macro-icons/wide/copy.svg';
import WideChat from '@macro-icons/wide/chat.svg';
import WideTask from '@macro-icons/wide/task.svg';
-import Trash from '@phosphor-icons/core/regular/trash.svg?component-solid';
import { commsServiceClient } from '@service-comms/client';
import { useUserId } from '@core/context/user';
import { Button } from '@ui/components/Button';
-import { createSignal, Match, Show, Switch } from 'solid-js';
+import { createSignal, Show } from 'solid-js';
import { debounce } from '@solid-primitives/scheduled';
-import { ProfilePicture } from './ProfilePicture';
+import { UserIcon } from './UserIcon';
export type UserTooltipProps = {
displayName: string;
@@ -79,40 +78,30 @@ export function UserTooltip(props: UserTooltipProps) {
const buttonStyle =
'px-3 text-xs w-full justify-start hover:bg-hover rounded-xs';
+ // Determine avatar props based on what we have
+ const avatarProps = () => {
+ if (props.id) {
+ return { id: props.id } as const;
+ }
+ if (props.email) {
+ return { email: props.email } as const;
+ }
+ // Fallback - use email even if empty to satisfy the union type
+ return { email: '?' } as const;
+ };
+
return (
<Panel depth={2} active>
<div class="bg-panel text-ink box-border border-accent overflow-hidden max-w-lg">
<div class="flex items-center gap-2 p-2">
- <div class="relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-ink-extra-muted pointer-events-none">
- <Switch>
- <Match when={props.isDeleted}>
- <div class="size-10 shrink-0 rounded-full bg-ink-extra-muted/50 flex items-center justify-center">
- <Trash class="w-4 h-4 shrink-0" />
- </div>
- </Match>
- <Match when={props.id}>
- <ProfilePicture
- id={props.id}
- sizeClass={{
- container: 'size-10',
- icon: 'w-4 h-4',
- text: 'text-lg text-panel leading-none',
- }}
- />
- </Match>
- <Match when={!props.id && props.email}>
- <ProfilePicture
- id={undefined}
- email={props.email}
- sizeClass={{
- container: 'size-10',
- icon: 'w-4 h-4',
- text: 'text-lg text-panel leading-none',
- }}
- />
- </Match>
- </Switch>
- </div>
+ <UserIcon
+ {...avatarProps()}
+ size="lg"
+ isDeleted={props.isDeleted}
+ showTooltip={false}
+ suppressClick
+ class="pointer-events-none"
+ />
<div class="flex-1 min-w-0">
<div class="text-sm font-medium truncate">{props.displayName}</div>
diff --git a/js/app/packages/core/internal/UserIconDemo.tsx b/js/app/packages/core/internal/UserIconDemo.tsx
new file mode 100644
index 0000000000..ed3b342f63
--- /dev/null
+++ b/js/app/packages/core/internal/UserIconDemo.tsx
@@ -0,0 +1,248 @@
+import { For } from 'solid-js';
+import { UserIcon } from '@core/component/UserIcon';
+import { UserGroup } from '@core/component/UserGroup';
+import { seedMockDisplayNames } from '@core/user/displayName';
+import { Avatar } from '@ui';
+import User from '@phosphor-icons/core/regular/user.svg?component-solid';
+
+// Mock macro user IDs (format: macro|[email protected])
+const MOCK_USERS = [
+ { id: 'macro|[email protected]', firstName: 'Seamus', lastName: 'Edson' },
+ { id: 'macro|[email protected]', firstName: 'Teo', lastName: 'Brasoveanu' },
+ { id: 'macro|[email protected]', firstName: 'Russel', lastName: 'Smith' },
+ { id: 'macro|[email protected]', firstName: 'Rahul', lastName: 'Gupta' },
+ { id: 'macro|[email protected]', firstName: 'Gab', lastName: 'Briones' },
+];
+
+const USER_IDS = MOCK_USERS.map((u) => u.id);
+
+const SIZE_LABELS = ['sm', 'md', 'lg'] as const;
+type GroupSize = 'sm' | 'md' | 'lg';
+
+// Seed mock display names so tooltips work
+seedMockDisplayNames(MOCK_USERS);
+
+function Section(props: { title: string; children: any }) {
+ return (
+ <div class="space-y-3">
+ <h2 class="text-sm font-semibold text-ink-muted uppercase tracking-wide">
+ {props.title}
+ </h2>
+ {props.children}
+ </div>
+ );
+}
+
+function SizeLabel(props: { size: string }) {
+ return (
+ <span class="text-xs text-ink-extra-muted font-mono w-8">{props.size}</span>
+ );
+}
+
+export default function UserIconDemo() {
+ return (
+ <div class="p-8 space-y-12 bg-panel min-h-full overflow-auto">
+ <div>
+ <h1 class="text-xl font-bold text-ink mb-2">
+ UserIcon & UserGroup Demo
+ </h1>
+ <p class="text-sm text-ink-muted">
+ Demonstrates the Avatar primitives from @ui and UserIcon built on top.
+ </p>
+ </div>
+
+ {/* Raw Avatar primitives */}
+ <Section title="Avatar Primitives (@ui)">
+ <p class="text-xs text-ink-muted mb-3">
+ Pure UI components with no user/API logic. Use these for custom
+ avatars.
+ </p>
+ <div class="flex items-center gap-4">
+ <Avatar size="sm">
+ <Avatar.Fallback>AB</Avatar.Fallback>
+ </Avatar>
+ <Avatar size="md">
+ <Avatar.Image src="https://i.pravatar.cc/100?img=1" alt="Random" />
+ </Avatar>
+ <Avatar size="lg">
+ <Avatar.Fallback>
+ <User class="size-5" />
+ </Avatar.Fallback>
+ </Avatar>
+ </div>
+ </Section>
+
+ {/* Individual UserIcons at each size */}
+ <Section title="UserIcon - All Sizes">
+ <div class="space-y-4">
+ <For each={SIZE_LABELS}>
+ {(size) => (
+ <div class="flex items-center gap-4">
+ <SizeLabel size={size} />
+ <div class="flex items-center gap-3">
+ <For each={MOCK_USERS}>
+ {(user) => (
+ <UserIcon id={user.id} size={size} suppressClick />
+ )}
+ </For>
+ </div>
+ </div>
+ )}
+ </For>
+
+ {/* Fill size needs a container */}
+ <div class="flex items-center gap-4">
+ <SizeLabel size="fill" />
+ <div class="flex items-center gap-3">
+ <For each={MOCK_USERS}>
+ {(user) => (
+ <div class="size-12">
+ <UserIcon id={user.id} size="fill" suppressClick />
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ </div>
+ </Section>
+
+ {/* UserGroup at each size */}
+ <Section title="UserGroup - All Sizes">
+ <div class="space-y-4">
+ <For each={SIZE_LABELS}>
+ {(size) => (
+ <div class="flex items-center gap-4">
+ <SizeLabel size={size} />
+ <UserGroup
+ userIds={[...USER_IDS]}
+ size={size as GroupSize}
+ suppressClick
+ />
+ </div>
+ )}
+ </For>
+ </div>
+ </Section>
+
+ {/* UserGroup with different maxUsers */}
+ <Section title="UserGroup - Max Users Variants">
+ <div class="space-y-4">
+ <For each={[1, 2, 3, 4, 5]}>
+ {(max) => (
+ <div class="flex items-center gap-4">
+ <span class="text-xs text-ink-extra-muted font-mono w-16">
+ max={max}
+ </span>
+ <UserGroup
+ userIds={[...USER_IDS]}
+ maxUsers={max}
+ size="sm"
+ suppressClick
+ />
+ </div>
+ )}
+ </For>
+ </div>
+ </Section>
+
+ {/* Hover background test - the main bug fix */}
+ <Section title="Hover Background Test">
+ <p class="text-xs text-ink-muted mb-3">
+ The separator should match the hover background. Add{' '}
+ <code class="bg-edge px-1 rounded">
+ hover:[--avatar-group-separator:var(--color-hover)]
+ </code>{' '}
+ to the parent.
+ </p>
+
+ <div class="space-y-2">
+ {/* Without the fix */}
+ <div class="flex items-center gap-4">
+ <span class="text-xs text-ink-extra-muted font-mono w-24">
+ without fix
+ </span>
+ <div class="flex items-center gap-2 px-3 py-2 rounded hover:bg-hover transition-colors border border-edge-muted">
+ <UserGroup
+ userIds={[...USER_IDS]}
+ size="sm"
+ maxUsers={3}
+ suppressClick
+ />
+ <span class="text-sm text-ink">Some content here</span>
+ </div>
+ </div>
+
+ {/* With the fix */}
+ <div class="flex items-center gap-4">
+ <span class="text-xs text-ink-extra-muted font-mono w-24">
+ with fix
+ </span>
+ <div class="flex items-center gap-2 px-3 py-2 rounded hover:bg-hover hover:[--avatar-group-separator:var(--color-hover)] transition-colors border border-edge-muted">
+ <UserGroup
+ userIds={[...USER_IDS]}
+ size="sm"
+ maxUsers={3}
+ suppressClick
+ />
+ <span class="text-sm text-ink">Some content here</span>
+ </div>
+ </div>
+ </div>
+ </Section>
+
+ {/* Active/selected state test */}
+ <Section title="Active State Test">
+ <div class="space-y-2">
+ <div class="flex items-center gap-2 px-3 py-2 rounded bg-active [--avatar-group-separator:var(--color-active)] border border-edge-muted">
+ <UserGroup
+ userIds={[...USER_IDS]}
+ size="sm"
+ maxUsers={3}
+ suppressClick
+ />
+ <span class="text-sm text-ink">
+ Active row with matching separator
+ </span>
+ </div>
+
+ <div class="flex items-center gap-2 px-3 py-2 rounded bg-hover [--avatar-group-separator:var(--color-hover)] border border-edge-muted">
+ <UserGroup
+ userIds={[...USER_IDS]}
+ size="sm"
+ maxUsers={3}
+ suppressClick
+ />
+ <span class="text-sm text-ink">
+ Hover row with matching separator
+ </span>
+ </div>
+ </div>
+ </Section>
+
+ {/* Email-only fallback */}
+ <Section title="Email Fallback (no macro ID)">
+ <div class="flex items-center gap-3">
+ <UserIcon email="[email protected]" size="sm" suppressClick />
+ <UserIcon email="[email protected]" size="md" suppressClick />
+ <UserIcon email="[email protected]" size="lg" suppressClick />
+ </div>
+ </Section>
+
+ {/* Deleted state */}
+ <Section title="Deleted User State">
+ <div class="flex items-center gap-3">
+ <For each={SIZE_LABELS}>
+ {(size) => (
+ <UserIcon
+ id={MOCK_USERS[0].id}
+ size={size}
+ isDeleted
+ suppressClick
+ />
+ )}
+ </For>
+ </div>
+ </Section>
+ </div>
+ );
+}
diff --git a/js/app/packages/entity/src/components/Badges.tsx b/js/app/packages/entity/src/components/Badges.tsx
index 20426a2620..57c6a9fd91 100644
--- a/js/app/packages/entity/src/components/Badges.tsx
+++ b/js/app/packages/entity/src/components/Badges.tsx
@@ -19,7 +19,7 @@ function Badge(props: ParentProps<{ class?: string }>) {
export function SharedBadge(props: { ownerId: string }) {
return (
<Badge class="text-ink-extra-muted border-edge-muted pr-2">
- <UserIcon id={props.ownerId} size="xs" />
+ <UserIcon id={props.ownerId} size="sm" />
shared
</Badge>
);
diff --git a/js/app/packages/entity/src/composed/list-entity/call.tsx b/js/app/packages/entity/src/composed/list-entity/call.tsx
index c5709e363c..056909b56c 100644
--- a/js/app/packages/entity/src/composed/list-entity/call.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/call.tsx
@@ -90,7 +90,7 @@ export function CallNarrowBody(props: {
<Show when={matches(h(), isCallRecordHit)}>
{(callHit) => (
<Show when={callHit().senderId}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
)}
</Show>
@@ -167,7 +167,7 @@ export function CallWideContent(props: {
<Show when={matches(h(), isCallRecordHit)}>
{(callHit) => (
<Show when={callHit().senderId}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
)}
</Show>
diff --git a/js/app/packages/entity/src/composed/list-entity/channel.tsx b/js/app/packages/entity/src/composed/list-entity/channel.tsx
index 8780fc372e..5b6c392b87 100644
--- a/js/app/packages/entity/src/composed/list-entity/channel.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/channel.tsx
@@ -48,7 +48,7 @@ export function ChannelMessageNarrowBody(props: {
<>
<span class="text-ink-muted text-xs flex items-center gap-1">
<Show when={props.entity.senderId}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
<SearchSender hit={h()} />
</span>
@@ -99,7 +99,7 @@ export function ChannelMessageWideContent(props: {
{props.entity.channelName}
</span>
<Show when={props.entity.senderId}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
<Show when={hit()}>
{(h) => (
diff --git a/js/app/packages/entity/src/composed/list-entity/narrow-layout.tsx b/js/app/packages/entity/src/composed/list-entity/narrow-layout.tsx
index ed40efbfd8..e76abc7259 100644
--- a/js/app/packages/entity/src/composed/list-entity/narrow-layout.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/narrow-layout.tsx
@@ -64,7 +64,7 @@ export function NarrowLayout(props: LayoutProps) {
{entity().channelName}
</span>
<Show when={entity().senderId}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
<Show when={hit()}>
{(h) => (
diff --git a/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx b/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx
index 2957639317..26e2cd316f 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx
+++ b/js/app/packages/entity/src/extractors-notification/notification-sender-icon.tsx
@@ -7,7 +7,7 @@ import { UserGroup } from '@core/component/UserGroup';
interface NotificationSenderIconProps {
notification?: Notification;
stack?: NotificationStack;
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
+ size?: 'sm' | 'md' | 'lg';
}
/**
diff --git a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
index 0c9281783b..76246bd4ab 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
+++ b/js/app/packages/entity/src/extractors-notification/notification-stacks.tsx
@@ -141,7 +141,7 @@ export function NotificationStackRow(props: {
<UnreadIndicator active />
</span>
<div class="shrink-0">
- <NotificationSenderIcon stack={props.stack} size="xs" />
+ <NotificationSenderIcon stack={props.stack} size="sm" />
</div>
<span class="ph-no-capture truncate min-w-0">
<NotificationDescription stack={props.stack} />
diff --git a/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx b/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
index e6c91ae6fb..619cd20880 100644
--- a/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
+++ b/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
@@ -38,7 +38,7 @@ export function SearchContentHitRow(props: SearchContentHitRowProps) {
<Show when={hitHasSender(props.hit)}>
<div class="flex items-center gap-1">
<Show when={senderId()}>
- {(id) => <UserIcon id={id()} size="xs" />}
+ {(id) => <UserIcon id={id()} size="sm" />}
</Show>
<span class="text-xs text-ink-muted">
<SearchSender hit={props.hit} />
diff --git a/js/app/packages/ui/components/Avatar.tsx b/js/app/packages/ui/components/Avatar.tsx
new file mode 100644
index 0000000000..cb20183281
--- /dev/null
+++ b/js/app/packages/ui/components/Avatar.tsx
@@ -0,0 +1,214 @@
+import { cn } from '../utils/classname';
+import { type ParentProps, splitProps, type JSX } from 'solid-js';
+
+export type AvatarSize = 'sm' | 'md' | 'lg' | 'fill';
+
+export type AvatarProps = ParentProps<
+ JSX.HTMLAttributes<HTMLDivElement> & {
+ size?: AvatarSize;
+ class?: string;
+ }
+>;
+
+const AVATAR_SIZE_CLASSES = cn(
+ 'size-4',
+ 'data-[size=md]:size-6',
+ 'data-[size=lg]:size-10',
+ 'data-[size=fill]:size-full'
+);
+
+const AVATAR_SVG_CLASSES = cn(
+ '[&>svg]:size-2',
+ 'data-[size=md]:[&>svg]:size-3',
+ 'data-[size=lg]:[&>svg]:size-5',
+ 'data-[size=fill]:[&>svg]:size-1/2'
+);
+
+/**
+ * Avatar root. Provides sizing and styling context for children.
+ * @example
+ * <Avatar size="lg">
+ * <Avatar.Image src={url} alt="User" />
+ * <Avatar.Fallback>JD</Avatar.Fallback>
+ * </Avatar>
+ */
+export function Avatar(props: AvatarProps) {
+ const [local, rest] = splitProps(props, ['size', 'class', 'children']);
+ const size = () => local.size ?? 'sm';
+
+ return (
+ <div
+ data-slot="avatar"
+ data-size={size()}
+ class={cn(
+ 'group/avatar relative flex shrink-0 select-none items-center justify-center overflow-hidden rounded-full bg-ink-extra-muted text-panel',
+ size() === 'fill' && '@container',
+ AVATAR_SIZE_CLASSES,
+ AVATAR_SVG_CLASSES,
+ local.class
+ )}
+ {...rest}
+ >
+ {local.children}
+ </div>
+ );
+}
+
+export type AvatarImageProps = {
+ src: string;
+ alt?: string;
+ class?: string;
+ onError?: JSX.EventHandler<HTMLImageElement, Event>;
+ ref?: (el: HTMLImageElement) => void;
+};
+
+/**
+ * Avatar image. Fills the avatar container.
+ */
+function AvatarImage(props: AvatarImageProps) {
+ return (
+ <img
+ ref={props.ref}
+ src={props.src}
+ alt={props.alt}
+ class={cn('size-full object-cover rounded-full', props.class)}
+ onError={props.onError}
+ />
+ );
+}
+
+export type AvatarFallbackProps = ParentProps<{
+ class?: string;
+}>;
+
+/**
+ * Avatar fallback content (typically initials or an icon).
+ * Automatically sizes text based on parent avatar's data-size.
+ */
+function AvatarFallback(props: AvatarFallbackProps) {
+ return (
+ <span
+ class={cn(
+ 'leading-none select-none flex items-center justify-center',
+ 'text-[8px]',
+ 'group-data-[size=md]/avatar:text-xs',
+ 'group-data-[size=lg]/avatar:text-lg',
+ 'group-data-[size=fill]/avatar:text-[min(50cqw,3rem)]',
+ props.class
+ )}
+ >
+ {props.children}
+ </span>
+ );
+}
+
+// Attach sub-components
+Avatar.Image = AvatarImage;
+Avatar.Fallback = AvatarFallback;
+
+// ---------- AvatarGroup ----------
+
+export type AvatarGroupSize = 'sm' | 'md' | 'lg';
+
+export type AvatarGroupProps = ParentProps<
+ JSX.HTMLAttributes<HTMLDivElement> & {
+ size?: AvatarGroupSize;
+ class?: string;
+ }
+>;
+
+/**
+ * Overlap spacing for avatar groups by size.
+ */
+const GROUP_OVERLAP_CLASSES: Record<AvatarGroupSize, string> = {
+ sm: '-space-x-1.5',
+ md: '-space-x-2',
+ lg: '-space-x-3',
+};
+
+/**
+ * Ring classes applied to child avatars for separation.
+ */
+const GROUP_RING_CLASSES: Record<AvatarGroupSize, string> = {
+ sm: '*:data-[slot=avatar]:ring-1',
+ md: '*:data-[slot=avatar]:ring-2',
+ lg: '*:data-[slot=avatar]:ring-2',
+};
+
+/**
+ * Avatar group container. Displays avatars in an overlapping style.
+ *
+ * Uses --avatar-group-separator CSS variable for ring color (defaults to --color-panel).
+ * Parent containers can override to match hover backgrounds.
+ *
+ * @example
+ * <AvatarGroup size="sm">
+ * <Avatar size="sm"><Avatar.Fallback>AB</Avatar.Fallback></Avatar>
+ * <Avatar size="sm"><Avatar.Fallback>CD</Avatar.Fallback></Avatar>
+ * <AvatarGroup.Count size="sm">+3</AvatarGroup.Count>
+ * </AvatarGroup>
+ *
+ * @example Matching hover background
+ * <div class="hover:bg-hover hover:[--avatar-group-separator:var(--color-hover)]">
+ * <AvatarGroup size="sm">...</AvatarGroup>
+ * </div>
+ */
+export function AvatarGroup(props: AvatarGroupProps) {
+ const [local, others] = splitProps(props, ['size', 'class', 'children']);
+ const size = () => local.size ?? 'sm';
+
+ return (
+ <div
+ data-slot="avatar-group"
+ data-size={size()}
+ class={cn(
+ 'isolate flex w-fit shrink-0 items-center',
+ GROUP_OVERLAP_CLASSES[size()],
+ GROUP_RING_CLASSES[size()],
+ '*:data-[slot=avatar]:ring-(--avatar-group-separator,var(--color-panel))',
+ local.class
+ )}
+ {...others}
+ >
+ {local.children}
+ </div>
+ );
+}
+
+export type AvatarGroupCountProps = ParentProps<{
+ size?: AvatarGroupSize;
+ class?: string;
+}>;
+
+/**
+ * Count sizing classes for overflow indicator.
+ */
+const GROUP_COUNT_CLASSES: Record<AvatarGroupSize, string> = {
+ sm: 'size-4 text-[9px] ring-1',
+ md: 'size-6 text-xs ring-2',
+ lg: 'size-10 text-base ring-2',
+};
+
+/**
+ * Overflow count indicator for avatar groups.
+ */
+function AvatarGroupCount(props: AvatarGroupCountProps) {
+ const size = () => props.size ?? 'sm';
+
+ return (
+ <div
+ data-slot="avatar-group-count"
+ class={cn(
+ 'relative z-10 flex shrink-0 select-none items-center justify-center rounded-full bg-menu text-ink leading-none',
+ 'ring-(--avatar-group-separator,var(--color-panel))',
+ GROUP_COUNT_CLASSES[size()],
+ props.class
+ )}
+ >
+ {props.children}
+ </div>
+ );
+}
+
+// Attach AvatarGroup sub-components
+AvatarGroup.Count = AvatarGroupCount;
diff --git a/js/app/packages/ui/index.ts b/js/app/packages/ui/index.ts
index b4dc926fad..8eeaff31ab 100644
--- a/js/app/packages/ui/index.ts
+++ b/js/app/packages/ui/index.ts
@@ -1,4 +1,12 @@
/* components */
+export {
+ Avatar,
+ AvatarGroup,
+ type AvatarSize,
+ type AvatarProps,
+ type AvatarGroupSize,
+ type AvatarGroupProps,
+} from './components/Avatar';
export { SegmentedControl } from './components/SegmentedControl';
export { TabbedControl } from './components/TabbedControl';
export { Keyboard } from './components/Keyboard';