design: redesign accounts page

This commit is contained in:
James Xylight committed 2025-07-07 19:49:41 -07:00
1 parent 95f18a0f1b
commit 9d0aa878ca
9 files changed
+189 -194

No files matched your search

+39 -32
View File
@@ -105,41 +105,48 @@ class CurrentProfile {
const index = profileData.profiles.findIndex(i => i.id == value?.id) const index = profileData.profiles.findIndex(i => i.id == value?.id)
profileData.profiles[index] = value profileData.profiles[index] = value
} }
async fetchUserData() {
const startId = this.#data.id
if (this.#data.jwt) {
site.data = undefined
notifications.set({ applications: 0, inbox: 0, reports: 0 })
const res = await userFromJwt(this.#data.jwt, this.#data.instance)
if (!res?.user)
toast({
content:
"Your account's instance did not return your user data. Your login may have expired.",
type: 'error',
})
// TODO update authentication handling to not be this dynamic
if (this.#data.id != startId) {
console.error('profile was switched too fast, ID mismatch')
return
}
site.data = res?.site
this.#data.user = res?.user
if (profile.data.user) {
this.#data.avatar = res?.user?.local_user_view.person.avatar
this.#data.username = res?.user?.local_user_view.person.name
}
} else {
if (browser) {
site.data = undefined
client({ instanceURL: this.#data.instance })
.getSite()
.then(res => (site.data = res))
}
}
return this
}
} }
export const profile = new CurrentProfile() export const profile = new CurrentProfile()
async function fetchUserData(profile: CurrentProfile) {
if (profile.data.jwt) {
site.data = undefined
notifications.set({ applications: 0, inbox: 0, reports: 0 })
const res = await userFromJwt(profile.data.jwt, profile.data.instance)
if (!res?.user)
toast({
content:
"Your account's instance did not return your user data. Your login may have expired.",
type: 'error',
})
site.data = res?.site
profile.data.user = res?.user
if (profile.data.user) {
profile.data.avatar = res?.user?.local_user_view.person.avatar
profile.data.username = res?.user?.local_user_view.person.name
}
} else {
if (browser) {
site.data = undefined
client({ instanceURL: profile.data.instance })
.getSite()
.then(res => (site.data = res))
}
}
return profile
}
export const notifications = writable<Notifications>({ export const notifications = writable<Notifications>({
applications: 0, applications: 0,
inbox: 0, inbox: 0,
@@ -168,7 +175,7 @@ $effect.root(() => {
$effect(() => { $effect(() => {
if (profile.data.id || profileData) if (profile.data.id || profileData)
fetchUserData(profile).then(() => { profile.fetchUserData().then(() => {
checkInbox() checkInbox()
}) })
}) })
+1
View File
@@ -0,0 +1 @@
A lot of the code in here was either inspired or modified from https://github.com/aeharding/threadiverse, which is licensed under the AGPL 3.0.
+5 -1
View File
@@ -30,7 +30,11 @@
url={profile.avatar} url={profile.avatar}
width={size} width={size}
alt="" alt=""
class={['shrink-0 rounded-full', selected && 'scale-75']} class={[
'shrink-0 rounded-full',
selected && 'scale-75',
'transition-transform',
]}
/> />
{:else} {:else}
<Icon <Icon
+1 -1
View File
@@ -111,7 +111,7 @@
<Shell <Shell
dir={$locale == 'he' && settings.useRtl ? 'rtl' : 'ltr'} dir={$locale == 'he' && settings.useRtl ? 'rtl' : 'ltr'}
class="min-h-screen " class="min-h-screen ease-cubic duration-200"
route={page.route} route={page.route}
> >
<Moderation /> <Moderation />
+142 -129
View File
@@ -14,21 +14,17 @@
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte.js' import { LINKED_INSTANCE_URL } from '$lib/instance.svelte.js'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte' import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { settings } from '$lib/settings.svelte.js' import { settings } from '$lib/settings.svelte.js'
import { Button, Menu, MenuButton, Modal } from 'mono-svelte' import { Badge, Button, Material, Menu, MenuButton, Modal } from 'mono-svelte'
import { import {
ArrowLeftOnRectangle, ArrowLeftOnRectangle,
ArrowRightOnRectangle, ArrowRightOnRectangle,
ArrowsRightLeft,
BugAnt, BugAnt,
Check,
ChevronDown, ChevronDown,
ChevronUp, ChevronUp,
EllipsisHorizontal, EllipsisHorizontal,
Icon, Icon,
Plus, Plus,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly } from 'svelte/transition'
let debugging = $state(false) let debugging = $state(false)
let debugProfile: Profile | undefined = $state(undefined) let debugProfile: Profile | undefined = $state(undefined)
@@ -38,7 +34,17 @@
account: undefined as Profile | undefined, account: undefined as Profile | undefined,
}) })
let switching = $state(-2) let switching = $state(-1)
let radioSelected = $state(profile.data.id)
$effect(() => {
switching = radioSelected
setUserID(radioSelected)
})
$effect(() => {
if (profile.data.user) switching = -1
})
</script> </script>
<svelte:head> <svelte:head>
@@ -96,138 +102,145 @@
</Modal> </Modal>
{/if} {/if}
<div class="flex flex-col h-full gap-4"> <Header pageHeader>
<Header pageHeader> {$t('routes.accounts')}
{$t('routes.accounts')} {#snippet extended()}
{#snippet extended()} <div class="flex">
<div class="flex"> <div class="flex gap-2 mr-auto">
<div class="flex gap-2 mr-auto">
<Button
href="/accounts/login"
rounding="pill"
class="px-4"
color="primary"
>
{#snippet prefix()}
<Icon src={ArrowLeftOnRectangle} size="16" mini />
{/snippet}
{$t('account.login')}
</Button>
{#if !LINKED_INSTANCE_URL}
<Button href="/accounts/login/guest" rounding="pill">
{#snippet prefix()}
<Icon src={Plus} size="16" micro />
{/snippet}
{$t('account.addGuest')}
</Button>
{/if}
</div>
</div>
{/snippet}
</Header>
<div>
{#each profileData.profiles as profile, index (profile.id)}
<div
class="flex flex-row gap-2 items-center py-3"
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
>
<Button <Button
title={profile.id == currentProfile?.data.id ? 'Switch' : 'Current'} href="/accounts/login"
onclick={async () => {
if (profile.id != currentProfile?.data.id) {
switching = profile.id
await setUserID(profile.id)
switching = -69
}
}}
size="square-md"
color={profile.id == currentProfile?.data.id ? 'primary' : 'ghost'}
loading={switching == profile.id}
disabled={switching == profile.id}
rounding="pill" rounding="pill"
class="px-4"
color="primary"
> >
{#snippet prefix()} {#snippet prefix()}
{#if profile.id == currentProfile?.data.id} <Icon src={ArrowLeftOnRectangle} size="16" mini />
<Icon src={Check} mini size="16" />
{:else}
<Icon src={ArrowsRightLeft} size="16" mini />
{/if}
{/snippet} {/snippet}
{$t('account.login')}
</Button> </Button>
<div class="flex items-center gap-2"> {#if !LINKED_INSTANCE_URL}
<ProfileAvatar <Button href="/accounts/login/guest" rounding="pill">
{profile} {#snippet prefix()}
{index} <Icon src={Plus} size="16" micro />
selected={currentProfile?.data.id == profile.id} {/snippet}
size={24} {$t('account.addGuest')}
/> </Button>
{/if}
</div>
</div>
{/snippet}
</Header>
<form class="accounts-grid mt-4 sm:mt-6">
{#each profileData.profiles as profile, index (profile.id)}
<label>
<input
type="radio"
id={profile.id.toString()}
name="profile"
value={profile.id}
class="hidden peer"
bind:group={radioSelected}
/>
<Material
rounding="2xl"
color="uniform"
class={[
'flex flex-col gap-2 py-3 transition-all duration-75 cursor-pointer',
'peer-checked:ring-2',
switching == profile.id && 'ring-slate-400 dark:ring-zinc-600',
]}
>
<ProfileAvatar
{profile}
{index}
selected={currentProfile?.data.id == profile.id}
size={40}
/>
<div class="flex flex-row justify-between">
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-medium">{profile.username}</span> <span class="font-medium text-base">
{profile.username}
{#if !profile.jwt}
<Badge class="inline">{$t('account.guest')}</Badge>
{/if}
</span>
<span class="text-sm text-slate-600 dark:text-zinc-400"> <span class="text-sm text-slate-600 dark:text-zinc-400">
{profile.instance} {profile.instance}
</span> </span>
</div> </div>
<Menu placement="bottom-end">
{#snippet target()}
<Button rounding="pill" size="custom" class="self-end h-8 w-8">
{#snippet prefix()}
<Icon src={EllipsisHorizontal} mini size="16" />
{/snippet}
</Button>
{/snippet}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="px-4 py-2 flex items-center gap-2"
onclick={e => e.stopPropagation()}
>
<Button
size="square-md"
color="secondary"
title={$t('account.moveUp')}
onclick={() => moveProfile(profile.id, true)}
>
{#snippet prefix()}
<Icon src={ChevronUp} size="16" mini />
{/snippet}
</Button>
<Button
size="square-md"
color="secondary"
title={$t('account.moveDown')}
onclick={() => moveProfile(profile.id, false)}
>
{#snippet prefix()}
<Icon src={ChevronDown} size="16" mini />
{/snippet}
</Button>
</div>
{#if settings.debugInfo}
<MenuButton
onclick={() => {
debugProfile = profile
debugging = !debugging
}}
>
{#snippet prefix()}
<Icon src={BugAnt} size="16" mini />
{/snippet}
{$t('common.debug')}
</MenuButton>
{/if}
{#if !LINKED_INSTANCE_URL || profile.user}
<MenuButton
onclick={() => {
removing.account = profile
removing.shown = !removing.shown
}}
color="danger-subtle"
>
{#snippet prefix()}
<Icon src={ArrowRightOnRectangle} size="16" mini />
{/snippet}
{$t('account.logout')}
</MenuButton>
{/if}
</Menu>
</div> </div>
<div class="ml-auto"></div> </Material>
<Menu placement="bottom-end"> </label>
{#snippet target()} {/each}
<Button size="square-md"> </form>
{#snippet prefix()}
<Icon src={EllipsisHorizontal} mini size="16" /> <style>
{/snippet} .accounts-grid {
</Button> display: grid;
{/snippet} grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
<div class="px-4 py-2 flex items-center gap-2"> gap: calc(var(--spacing) * 4);
<Button }
size="square-md" </style>
color="secondary"
title={$t('account.moveUp')}
onclick={() => moveProfile(profile.id, true)}
>
{#snippet prefix()}
<Icon src={ChevronUp} size="16" mini />
{/snippet}
</Button>
<Button
size="square-md"
color="secondary"
title={$t('account.moveDown')}
onclick={() => moveProfile(profile.id, false)}
>
{#snippet prefix()}
<Icon src={ChevronDown} size="16" mini />
{/snippet}
</Button>
</div>
{#if settings.debugInfo}
<MenuButton
onclick={() => {
debugProfile = profile
debugging = !debugging
}}
>
{#snippet prefix()}
<Icon src={BugAnt} size="16" mini />
{/snippet}
{$t('common.debug')}
</MenuButton>
{/if}
{#if !LINKED_INSTANCE_URL || profile.user}
<MenuButton
onclick={() => {
removing.account = profile
removing.shown = !removing.shown
}}
color="danger-subtle"
>
{#snippet prefix()}
<Icon src={ArrowRightOnRectangle} size="16" mini />
{/snippet}
{$t('account.logout')}
</MenuButton>
{/if}
</Menu>
</div>
{/each}
</div>
</div>
+1 -31
View File
@@ -14,6 +14,7 @@
--animate-pop-in: pop-in 0.25s ease-out forwards; --animate-pop-in: pop-in 0.25s ease-out forwards;
--ease-cubic: cubic-bezier(0.075, 0.82, 0.165, 1);
--spacing-22: 88px; --spacing-22: 88px;
--color-slate-25: rgb(var(--c-s-25, 252 253 254)); --color-slate-25: rgb(var(--c-s-25, 252 253 254));
@@ -57,19 +58,6 @@
} }
} }
.cc {
inset: -1px;
position: absolute;
border-radius: inherit;
z-index: -1;
background: linear-gradient(
125deg,
color-mix(in oklab, var(--color-zinc-50) 20%, transparent),
color-mix(in oklab, var(--color-zinc-50) 0%, transparent),
color-mix(in oklab, var(--color-zinc-50) 20%, transparent)
);
}
@custom-variant hover (&:hover); @custom-variant hover (&:hover);
@font-face { @font-face {
@@ -78,24 +66,6 @@
font-display: swap; font-display: swap;
} }
@font-face {
font-family: 'Satoshi';
src: url('/font/Satoshi.woff2') format('woff2');
font-display: swap;
}
@font-face {
font-family: 'Nunito';
src: url('/font/Nunito.woff2') format('woff2');
font-display: swap;
}
@font-face {
font-family: 'EBGaramond';
src: url('/font/EBGaramond-Regular.woff2') format('woff2');
font-display: swap;
}
body { body {
@apply bg-slate-50 text-slate-900 dark:bg-zinc-950 dark:text-zinc-100 accent-slate-950 dark:accent-zinc-50; @apply bg-slate-50 text-slate-900 dark:bg-zinc-950 dark:text-zinc-100 accent-slate-950 dark:accent-zinc-50;
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.