From 22fbfda73efcad3b7d4797487c11d267ec48b967 Mon Sep 17 00:00:00 2001 From: eti Date: Tue, 4 Aug 2026 14:13:31 +0200 Subject: [PATCH] web: give Avatar a named size scale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avatar used to take a tailwind class for its size, and a separate `tiny` flag that picked which image size to download. Nothing kept those two in agreement, and they drifted apart: comment avatars draw at 32px but downloaded a 32px image, so they looked blurry on retina screens, while the small 16px avatars in settings downloaded a full-size one. Now there's one prop. Pick mini, small, regular or large — the names the design system already uses — and Avatar works out the image size itself, always asking for twice what it draws so it stays sharp. `full` is for the cases where the surrounding layout sets the size instead; it fills whatever box you put it in and uses the original image. The sizes go through tv() so you can still pass your own size class and have it win. Two size classes in one string is a coin flip otherwise, because tailwind decides by where the rules land in the stylesheet, not the order you wrote them. A few avatars shift slightly to land on the scale: comments 32 to 26, settings lists 16 to 17, access and last commit 20 to 21, repo header and commit rows 24 to 26. Signed-off-by: eti --- web/src/lib/avatar.ts | 4 +- web/src/lib/components/comment/Comment.svelte | 2 +- .../lib/components/comment/CommentBox.svelte | 2 +- .../profile/FollowCardContent.svelte | 2 +- .../lib/components/profile/ProfileCard.svelte | 7 +-- .../lib/components/repo/CommitHeader.svelte | 2 +- .../lib/components/repo/CommitLogView.svelte | 2 +- .../components/repo/LastCommitPanel.svelte | 2 +- web/src/lib/components/repo/RepoHeader.svelte | 2 +- .../settings/tabs/ProfileTab.svelte | 2 +- .../lib/components/ui/Avatar.stories.svelte | 19 +++--- web/src/lib/components/ui/Avatar.svelte | 59 +++++++++++++++++-- web/src/lib/components/ui/User.svelte | 21 ++++--- .../[repo]/settings/access/+page.svelte | 2 +- .../[repo]/settings/hooks/+page.svelte | 2 +- .../[repo]/settings/pipelines/+page.svelte | 2 +- web/src/routes/repo/new/+page.svelte | 2 +- 17 files changed, 93 insertions(+), 41 deletions(-) diff --git a/web/src/lib/avatar.ts b/web/src/lib/avatar.ts index 0350e8e6..8259d7ce 100644 --- a/web/src/lib/avatar.ts +++ b/web/src/lib/avatar.ts @@ -1,4 +1,4 @@ // the service wants signed urls and the secret is server side, so this points // at the route that signs -export const avatarUrl = (did: string, tiny = false): string => - `/avatar/${encodeURIComponent(did)}${tiny ? "?size=tiny" : ""}`; +export const avatarUrl = (did: string, width?: number): string => + `/avatar/${encodeURIComponent(did)}${width ? `?size=${width}` : ""}`; diff --git a/web/src/lib/components/comment/Comment.svelte b/web/src/lib/components/comment/Comment.svelte index 8fd23d87..2550dd39 100644 --- a/web/src/lib/components/comment/Comment.svelte +++ b/web/src/lib/components/comment/Comment.svelte @@ -45,7 +45,7 @@ class={`flex gap-2 ${variant === "top" ? "border-b border-border-default bg-background-default px-6 py-4" : "py-4 pr-4"}`} >
- +
diff --git a/web/src/lib/components/comment/CommentBox.svelte b/web/src/lib/components/comment/CommentBox.svelte index 01e10f42..48a2e62e 100644 --- a/web/src/lib/components/comment/CommentBox.svelte +++ b/web/src/lib/components/comment/CommentBox.svelte @@ -64,7 +64,7 @@
- +
diff --git a/web/src/lib/components/profile/FollowCardContent.svelte b/web/src/lib/components/profile/FollowCardContent.svelte index 2a4959b6..4e39ed3d 100644 --- a/web/src/lib/components/profile/FollowCardContent.svelte +++ b/web/src/lib/components/profile/FollowCardContent.svelte @@ -19,7 +19,7 @@
- +
diff --git a/web/src/lib/components/profile/ProfileCard.svelte b/web/src/lib/components/profile/ProfileCard.svelte index 2ae561f6..ff4cd27a 100644 --- a/web/src/lib/components/profile/ProfileCard.svelte +++ b/web/src/lib/components/profile/ProfileCard.svelte @@ -40,12 +40,7 @@
- +
diff --git a/web/src/lib/components/repo/CommitHeader.svelte b/web/src/lib/components/repo/CommitHeader.svelte index b4d6c391..742ecab3 100644 --- a/web/src/lib/components/repo/CommitHeader.svelte +++ b/web/src/lib/components/repo/CommitHeader.svelte @@ -42,7 +42,7 @@ {label} - + {#if email} {name} {:else} diff --git a/web/src/lib/components/repo/CommitLogView.svelte b/web/src/lib/components/repo/CommitLogView.svelte index d07df54f..a38d1f63 100644 --- a/web/src/lib/components/repo/CommitLogView.svelte +++ b/web/src/lib/components/repo/CommitLogView.svelte @@ -42,7 +42,7 @@ {#snippet authorCell(commit: CommitSummary)} - + {#if commit.authorEmail} {commit.authorName} diff --git a/web/src/lib/components/repo/LastCommitPanel.svelte b/web/src/lib/components/repo/LastCommitPanel.svelte index 7eb6c664..7864729a 100644 --- a/web/src/lib/components/repo/LastCommitPanel.svelte +++ b/web/src/lib/components/repo/LastCommitPanel.svelte @@ -21,7 +21,7 @@
{#if commit.authorName} - + {commit.authorName} {/if} diff --git a/web/src/lib/components/repo/RepoHeader.svelte b/web/src/lib/components/repo/RepoHeader.svelte index 4b56f499..0288d885 100644 --- a/web/src/lib/components/repo/RepoHeader.svelte +++ b/web/src/lib/components/repo/RepoHeader.svelte @@ -74,7 +74,7 @@ href={resolve(`/${repo.ownerHandle}` as "/")} class="flex items-center gap-2 text-foreground-default no-underline hover:underline" > - + {repo.ownerHandle} / diff --git a/web/src/lib/components/settings/tabs/ProfileTab.svelte b/web/src/lib/components/settings/tabs/ProfileTab.svelte index 91c2c50d..eb061d95 100644 --- a/web/src/lib/components/settings/tabs/ProfileTab.svelte +++ b/web/src/lib/components/settings/tabs/ProfileTab.svelte @@ -60,7 +60,7 @@
- +
diff --git a/web/src/lib/components/ui/Avatar.stories.svelte b/web/src/lib/components/ui/Avatar.stories.svelte index ce91be3b..6e91e897 100644 --- a/web/src/lib/components/ui/Avatar.stories.svelte +++ b/web/src/lib/components/ui/Avatar.stories.svelte @@ -1,6 +1,9 @@ +