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
+83 -88

No files matched your search

+19 -12
View File
@@ -105,16 +105,14 @@ 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
} }
}
export const profile = new CurrentProfile() async fetchUserData() {
const startId = this.#data.id
async function fetchUserData(profile: CurrentProfile) { if (this.#data.jwt) {
if (profile.data.jwt) {
site.data = undefined site.data = undefined
notifications.set({ applications: 0, inbox: 0, reports: 0 }) notifications.set({ applications: 0, inbox: 0, reports: 0 })
const res = await userFromJwt(profile.data.jwt, profile.data.instance) const res = await userFromJwt(this.#data.jwt, this.#data.instance)
if (!res?.user) if (!res?.user)
toast({ toast({
content: content:
@@ -122,23 +120,32 @@ async function fetchUserData(profile: CurrentProfile) {
type: 'error', 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 site.data = res?.site
profile.data.user = res?.user this.#data.user = res?.user
if (profile.data.user) { if (profile.data.user) {
profile.data.avatar = res?.user?.local_user_view.person.avatar this.#data.avatar = res?.user?.local_user_view.person.avatar
profile.data.username = res?.user?.local_user_view.person.name this.#data.username = res?.user?.local_user_view.person.name
} }
} else { } else {
if (browser) { if (browser) {
site.data = undefined site.data = undefined
client({ instanceURL: profile.data.instance }) client({ instanceURL: this.#data.instance })
.getSite() .getSite()
.then(res => (site.data = res)) .then(res => (site.data = res))
} }
} }
return profile return this
} }
}
export const profile = new CurrentProfile()
export const notifications = writable<Notifications>({ export const notifications = writable<Notifications>({
applications: 0, applications: 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 />
+56 -43
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,7 +102,6 @@
</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()}
@@ -125,59 +130,58 @@
</div> </div>
{/snippet} {/snippet}
</Header> </Header>
<div> <form class="accounts-grid mt-4 sm:mt-6">
{#each profileData.profiles as profile, index (profile.id)} {#each profileData.profiles as profile, index (profile.id)}
<div <label>
class="flex flex-row gap-2 items-center py-3" <input
transition:fly={{ duration: 500, y: -12, easing: expoOut }} 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',
]}
> >
<Button
title={profile.id == currentProfile?.data.id ? 'Switch' : 'Current'}
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"
>
{#snippet prefix()}
{#if profile.id == currentProfile?.data.id}
<Icon src={Check} mini size="16" />
{:else}
<Icon src={ArrowsRightLeft} size="16" mini />
{/if}
{/snippet}
</Button>
<div class="flex items-center gap-2">
<ProfileAvatar <ProfileAvatar
{profile} {profile}
{index} {index}
selected={currentProfile?.data.id == profile.id} selected={currentProfile?.data.id == profile.id}
size={24} 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>
</div>
<div class="ml-auto"></div>
<Menu placement="bottom-end"> <Menu placement="bottom-end">
{#snippet target()} {#snippet target()}
<Button size="square-md"> <Button rounding="pill" size="custom" class="self-end h-8 w-8">
{#snippet prefix()} {#snippet prefix()}
<Icon src={EllipsisHorizontal} mini size="16" /> <Icon src={EllipsisHorizontal} mini size="16" />
{/snippet} {/snippet}
</Button> </Button>
{/snippet} {/snippet}
<div class="px-4 py-2 flex items-center gap-2"> <!-- 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 <Button
size="square-md" size="square-md"
color="secondary" color="secondary"
@@ -228,6 +232,15 @@
{/if} {/if}
</Menu> </Menu>
</div> </div>
</Material>
</label>
{/each} {/each}
</div> </form>
</div>
<style>
.accounts-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: calc(var(--spacing) * 4);
}
</style>
+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.