Skip to content

Commit 9a2fc3d

Browse files
committed
Show GitHub profile picture instead of generic person when logged in
1 parent 1bf2f59 commit 9a2fc3d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

web/src/lib/github.svelte.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export function getGithubUsername(): string | null {
3232
return githubUsername.value;
3333
}
3434

35+
export function getGithubAvatarUrl(username: string, size: number = 32): string | null {
36+
return `https://avatars.githubusercontent.com/${username}?s=${size}`;
37+
}
38+
3539
export function getGithubToken(): string | null {
3640
const expiresAt = localStorage.getItem(GITHUB_TOKEN_EXPIRES_KEY);
3741
if (expiresAt !== null) {

web/src/routes/OpenDiffDialog.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { getGithubUsername, installGithubApp, loginWithGithub, logoutGithub } from "$lib/github.svelte";
2+
import { getGithubUsername, getGithubAvatarUrl, installGithubApp, loginWithGithub, logoutGithub } from "$lib/github.svelte";
33
import { Button, Dialog, Separator, Popover } from "bits-ui";
44
import InfoPopup from "$lib/components/InfoPopup.svelte";
55
import { page } from "$app/state";
@@ -118,8 +118,9 @@
118118

119119
<div class="mb-2 flex flex-row gap-1">
120120
{#if getGithubUsername()}
121+
{@const username = getGithubUsername()!}
121122
<div class="flex w-fit flex-row items-center justify-between gap-2 px-2 py-1">
122-
<span class="iconify shrink-0 octicon--person-16"></span>
123+
<img src={getGithubAvatarUrl(username)} alt="GitHub Profile Picture of {username}" class="size-6 shrink-0 rounded-full border shadow-xs" />
123124
{getGithubUsername()}
124125
</div>
125126
<Button.Root class="flex items-center gap-2 rounded-md btn-ghost-danger px-2 py-1" onclick={logoutGithub}>

0 commit comments

Comments
 (0)