design: update accounts page and commonlist

This commit is contained in:
Xylight committed 2025-10-14 17:20:26 -07:00
1 parent a61f5d226f
commit 0bb99ddb86
5 files changed
+266 -142

No files matched your search

+11 -35
View File
@@ -1,23 +1,14 @@
<script lang="ts"> <script lang="ts">
import { type ProfileInfo } from '$lib/app/auth.svelte.js' import { type ProfileInfo } from '$lib/app/auth.svelte.js'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
import { Icon, UserCircle } from 'svelte-hero-icons/dist'
interface Props { interface Props {
profile?: ProfileInfo | undefined profile?: ProfileInfo | undefined
selected?: boolean selected?: boolean
index?: number
size?: number size?: number
guest?: boolean
} }
let { let { profile = undefined, selected = false, size = 22 }: Props = $props()
profile = undefined,
selected = false,
index = 0,
size = 22,
guest = false,
}: Props = $props()
</script> </script>
{#if profile} {#if profile}
@@ -25,30 +16,15 @@
style="width: {size}px; height: {size}px;" style="width: {size}px; height: {size}px;"
class={[profile.avatar && 'bg-slate-200 rounded-full dark:bg-zinc-700']} class={[profile.avatar && 'bg-slate-200 rounded-full dark:bg-zinc-700']}
> >
{#if profile.avatar} <Avatar
<Avatar url={profile.avatar}
url={profile.avatar} alt={profile.username}
width={size} width={size}
alt="" class={[
class={[ 'shrink-0 rounded-full',
'shrink-0 rounded-full', selected && 'scale-75',
selected && 'scale-75', 'transition-transform',
'transition-transform', ]}
]} />
/>
{:else}
<Icon
src={UserCircle}
mini={selected}
size={size?.toString()}
title={profile.username}
class="text-blue-500 shrink-0"
style={guest
? `color: gray`
: profile.color
? `color: ${profile.color}`
: `filter: hue-rotate(${index * 50}deg)`}
/>
{/if}
</div> </div>
{/if} {/if}
+146
View File
@@ -0,0 +1,146 @@
<script lang="ts">
interface Props {
seed: string
}
let { seed }: Props = $props()
function randomoklch(seed: string, count: number) {
function hashString(str: string) {
let hash = 0
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash
}
return Math.abs(hash)
}
function seededRandom(seedStr: string, index: number) {
const combined = hashString(seedStr + '|' + index.toString())
let x = Math.sin(combined) * 10000
return x - Math.floor(x)
}
const colors = []
const baseHue = (hashString(seed) % 12) * 60
for (let i = 0; i < count; i++) {
const r1 = seededRandom(seed, i * 3)
const r2 = seededRandom(seed, i * 3 + 1)
const r3 = seededRandom(seed, i * 3 + 2)
const lightness = 0.45 + r1 * 0.4
const chroma = 0.08 + r2 * 0.12
const hueVariation = (r3 - 0.5) * 80
const hue = (baseHue + hueVariation + 360) % 360
const oklchColor = `oklch(${lightness.toFixed(3)} ${chroma.toFixed(3)} ${hue.toFixed(1)})`
colors.push({ str: oklchColor, pos: r1 * 1000 })
}
return colors
}
let colors = $derived(randomoklch(seed, 12))
const uniqueId = $derived(seed.replace(/[^a-zA-Z0-9]/g, '_'))
</script>
<svg width="120%" height="120%" viewBox="0 -100 1171 241" fill="none">
<defs>
<filter
id="noiseFilter_{uniqueId}"
x="0%"
y="0%"
width="100%"
height="100%"
>
<feTurbulence
baseFrequency="0.9"
numOctaves="3"
seed="5"
stitchTiles="stitch"
/>
</filter>
<filter
id="mainBlur_{uniqueId}"
x="-20%"
y="-50%"
width="140%"
height="200%"
>
<feGaussianBlur stdDeviation="45" result="blur" />
<feBlend mode="normal" in="blur" in2="BackgroundImageFix" />
</filter>
<radialGradient id="grad1_{uniqueId}" cx="50%" cy="30%" r="60%">
<stop offset="0%" stop-color={colors[0].str} />
<stop offset="40%" stop-color={colors[1].str} />
<stop offset="100%" stop-color={colors[2].str} />
</radialGradient>
<radialGradient id="grad2_{uniqueId}" cx="30%" cy="70%" r="70%">
<stop offset="0%" stop-color={colors[3].str} />
<stop offset="30%" stop-color={colors[4].str} />
<stop offset="100%" stop-color={colors[5].str} />
</radialGradient>
<linearGradient id="grad3_{uniqueId}" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color={colors[6].str} />
<stop offset="50%" stop-color={colors[7].str} />
<stop offset="100%" stop-color={colors[8].str} />
</linearGradient>
</defs>
<g filter="url(#mainBlur_{uniqueId})">
<ellipse
cx={colors[5].pos}
cy="-30"
rx="300"
ry="120"
fill="url(#grad1_{uniqueId})"
opacity="0.8"
/>
<circle
cx={colors[6].pos}
cy="-20"
r="180"
fill="url(#grad2_{uniqueId})"
opacity="0.7"
/>
<ellipse
cx={colors[7].pos}
cy="10"
rx="250"
ry="100"
fill="url(#grad3_{uniqueId})"
opacity="0.6"
/>
<circle
cx={colors[8].pos}
cy="30"
r="120"
fill={colors[9].str}
opacity="0.5"
/>
<ellipse
cx={colors[9].pos}
cy="20"
rx="150"
ry="80"
fill={colors[10].str}
opacity="0.4"
/>
</g>
<rect
width="100%"
height="100%"
fill="white"
opacity="0.03"
filter="url(#noiseFilter_{uniqueId})"
/>
</svg>
+9 -5
View File
@@ -29,7 +29,7 @@
}: Props = $props() }: Props = $props()
</script> </script>
<ul class="space-y-1"> <ul class="space-y-0.5">
{#if items} {#if items}
{#each items as item, index (item)} {#each items as item, index (item)}
<li <li
@@ -87,7 +87,7 @@
padding-block: calc(var(--spacing) * 1); padding-block: calc(var(--spacing) * 1);
} }
ul > :global(li).selected { ul > :global(li.selected) {
background-color: color-mix( background-color: color-mix(
in oklab, in oklab,
var(--color-white), var(--color-white),
@@ -95,10 +95,10 @@
); );
} }
:global(.dark) ul > :global(li).selected { :global(.dark) ul > :global(li.selected) {
background-color: color-mix( background-color: color-mix(
in oklab, in oklab,
var(--color-zinc-925), var(--color-zinc-900) 90%,
var(--color-zinc-800) var(--color-zinc-800)
); );
} }
@@ -116,7 +116,11 @@
} }
&:active { &:active {
background-color: var(--color-zinc-950); background-color: color-mix(
in oklab,
var(--color-zinc-900) 80%,
var(--color-zinc-925)
);
} }
} }
-1
View File
@@ -154,7 +154,6 @@
border-left: 1px solid var(--color-slate-200); border-left: 1px solid var(--color-slate-200);
border-right: 1px solid var(--color-slate-200); border-right: 1px solid var(--color-slate-200);
padding-bottom: calc(var(--spacing) * 22); padding-bottom: calc(var(--spacing) * 22);
z-index: 0;
@variant dark { @variant dark {
background-color: var(--color-zinc-925); background-color: var(--color-zinc-925);
+100 -101
View File
@@ -132,111 +132,110 @@
/> />
{:else} {:else}
<form class="accounts-grid gap-4"> <form class="accounts-grid gap-4">
<CommonList <CommonList animate={false}>
selected={(p) => p.id == profile.meta.profile} {#each profile.meta.profiles as p}
items={profile.meta.profiles} <li
animate={false} class={['xs px-4 py-1', p.id == profile.meta.profile && 'selected']}
> >
{#snippet item(p, index)} <label class="relative block">
<label class="relative block"> <input
<input type="radio"
type="radio" id={p.id.toString()}
id={p.id.toString()} name="profile"
name="profile" value={p.id}
value={p.id} class="hidden peer"
class="hidden peer" bind:group={radioSelected}
bind:group={radioSelected}
/>
<div
class={[
'flex flex-row items-center gap-2 transition-all duration-75',
'cursor-pointer relative ring-transparent',
]}
>
<div
class="absolute -inset-2 -inset-x-3 sm:-inset-y-3 sm:-inset-x-4 group-first/li:rounded-t-2xl group-last/li:rounded-b-2xl rounded-md ring-2 ring-inherit"
></div>
<ProfileAvatar
profile={p}
{index}
selected={profile?.current.id == p.id}
size={32}
/> />
<div class="flex flex-col overflow-hidden"> <div
<span class="break-words font-medium text-base"> class={[
{p.username} 'flex flex-row items-center gap-2 transition-all duration-75',
{#if !p.jwt} 'cursor-pointer relative ring-transparent',
<Badge class="inline-grid w-6 h-6 p-0! place-items-center"> ]}
<Icon src={QuestionMarkCircle} size="16" micro /> >
</Badge>
{/if}
</span>
<span class="text-sm text-slate-600 dark:text-zinc-400">
<span class="capitalize">
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
</span>
• {p.instance}
</span>
</div>
<Menu placement="bottom-end">
{#snippet target(attachment)}
<Button
{@attach attachment}
size="square-md"
color="tertiary"
class="justify-self-end ml-auto z-50"
aria-label={$t('post.actions.more.label')}
icon={EllipsisHorizontal}
></Button>
{/snippet}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div <div
class="px-4 py-2 flex items-center gap-2" class="absolute -inset-2 -inset-x-3 sm:-inset-y-3 sm:-inset-x-4 group-first/li:rounded-t-2xl group-last/li:rounded-b-2xl rounded-md ring-2 ring-inherit"
onclick={(e) => e.stopPropagation()} ></div>
> <ProfileAvatar
<Button profile={p}
size="square-md" selected={profile?.current.id == p.id}
color="secondary" size={24}
title={$t('account.moveUp')} />
onclick={() => profile.move(p.id, true)} <div class="flex flex-col overflow-hidden">
icon={ChevronUp} <span class="break-words font-medium text-base">
></Button> {p.username}
<Button {#if !p.jwt}
size="square-md" <Badge class="inline-grid w-6 h-6 p-0! place-items-center">
color="secondary" <Icon src={QuestionMarkCircle} size="16" micro />
title={$t('account.moveDown')} </Badge>
onclick={() => profile.move(p.id, false)} {/if}
icon={ChevronDown} </span>
></Button> <span class="text-xs text-slate-600 dark:text-zinc-400">
<span class="capitalize">
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
</span>
• {p.instance}
</span>
</div> </div>
{#if settings.debugInfo} <Menu placement="bottom-end">
<MenuButton {#snippet target(attachment)}
onclick={() => { <Button
debugProfile = p {@attach attachment}
debugging = !debugging size="square-md"
}} color="tertiary"
icon={BugAnt} class="justify-self-end ml-auto z-50"
aria-label={$t('post.actions.more.label')}
icon={EllipsisHorizontal}
></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()}
> >
{$t('common.debug')} <Button
</MenuButton> size="square-md"
{/if} color="secondary"
{#if !LINKED_INSTANCE_URL || p.user} title={$t('account.moveUp')}
<MenuButton onclick={() => profile.move(p.id, true)}
onclick={() => { icon={ChevronUp}
removing.account = p ></Button>
removing.shown = !removing.shown <Button
}} size="square-md"
color="danger-subtle" color="secondary"
icon={ArrowRightOnRectangle} title={$t('account.moveDown')}
> onclick={() => profile.move(p.id, false)}
{$t('account.logout')} icon={ChevronDown}
</MenuButton> ></Button>
{/if} </div>
</Menu> {#if settings.debugInfo}
</div> <MenuButton
</label> onclick={() => {
{/snippet} debugProfile = p
debugging = !debugging
}}
icon={BugAnt}
>
{$t('common.debug')}
</MenuButton>
{/if}
{#if !LINKED_INSTANCE_URL || p.user}
<MenuButton
onclick={() => {
removing.account = p
removing.shown = !removing.shown
}}
color="danger-subtle"
icon={ArrowRightOnRectangle}
>
{$t('account.logout')}
</MenuButton>
{/if}
</Menu>
</div>
</label>
</li>
{/each}
</CommonList> </CommonList>
</form> </form>
{/if} {/if}