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">
import { type ProfileInfo } from '$lib/app/auth.svelte.js'
import Avatar from '$lib/ui/generic/Avatar.svelte'
import { Icon, UserCircle } from 'svelte-hero-icons/dist'
interface Props {
profile?: ProfileInfo | undefined
selected?: boolean
index?: number
size?: number
guest?: boolean
}
let {
profile = undefined,
selected = false,
index = 0,
size = 22,
guest = false,
}: Props = $props()
let { profile = undefined, selected = false, size = 22 }: Props = $props()
</script>
{#if profile}
@@ -25,30 +16,15 @@
style="width: {size}px; height: {size}px;"
class={[profile.avatar && 'bg-slate-200 rounded-full dark:bg-zinc-700']}
>
{#if profile.avatar}
<Avatar
url={profile.avatar}
width={size}
alt=""
class={[
'shrink-0 rounded-full',
selected && 'scale-75',
'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}
<Avatar
url={profile.avatar}
alt={profile.username}
width={size}
class={[
'shrink-0 rounded-full',
selected && 'scale-75',
'transition-transform',
]}
/>
</div>
{/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()
</script>
<ul class="space-y-1">
<ul class="space-y-0.5">
{#if items}
{#each items as item, index (item)}
<li
@@ -87,7 +87,7 @@
padding-block: calc(var(--spacing) * 1);
}
ul > :global(li).selected {
ul > :global(li.selected) {
background-color: color-mix(
in oklab,
var(--color-white),
@@ -95,10 +95,10 @@
);
}
:global(.dark) ul > :global(li).selected {
:global(.dark) ul > :global(li.selected) {
background-color: color-mix(
in oklab,
var(--color-zinc-925),
var(--color-zinc-900) 90%,
var(--color-zinc-800)
);
}
@@ -116,7 +116,11 @@
}
&: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-right: 1px solid var(--color-slate-200);
padding-bottom: calc(var(--spacing) * 22);
z-index: 0;
@variant dark {
background-color: var(--color-zinc-925);
+100 -101
View File
@@ -132,111 +132,110 @@
/>
{:else}
<form class="accounts-grid gap-4">
<CommonList
selected={(p) => p.id == profile.meta.profile}
items={profile.meta.profiles}
animate={false}
>
{#snippet item(p, index)}
<label class="relative block">
<input
type="radio"
id={p.id.toString()}
name="profile"
value={p.id}
class="hidden peer"
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}
<CommonList animate={false}>
{#each profile.meta.profiles as p}
<li
class={['xs px-4 py-1', p.id == profile.meta.profile && 'selected']}
>
<label class="relative block">
<input
type="radio"
id={p.id.toString()}
name="profile"
value={p.id}
class="hidden peer"
bind:group={radioSelected}
/>
<div class="flex flex-col overflow-hidden">
<span class="break-words font-medium text-base">
{p.username}
{#if !p.jwt}
<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
class={[
'flex flex-row items-center gap-2 transition-all duration-75',
'cursor-pointer relative ring-transparent',
]}
>
<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={() => profile.move(p.id, true)}
icon={ChevronUp}
></Button>
<Button
size="square-md"
color="secondary"
title={$t('account.moveDown')}
onclick={() => profile.move(p.id, false)}
icon={ChevronDown}
></Button>
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}
selected={profile?.current.id == p.id}
size={24}
/>
<div class="flex flex-col overflow-hidden">
<span class="break-words font-medium text-base">
{p.username}
{#if !p.jwt}
<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-xs text-slate-600 dark:text-zinc-400">
<span class="capitalize">
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
</span>
• {p.instance}
</span>
</div>
{#if settings.debugInfo}
<MenuButton
onclick={() => {
debugProfile = p
debugging = !debugging
}}
icon={BugAnt}
<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
class="px-4 py-2 flex items-center gap-2"
onclick={(e) => e.stopPropagation()}
>
{$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>
{/snippet}
<Button
size="square-md"
color="secondary"
title={$t('account.moveUp')}
onclick={() => profile.move(p.id, true)}
icon={ChevronUp}
></Button>
<Button
size="square-md"
color="secondary"
title={$t('account.moveDown')}
onclick={() => profile.move(p.id, false)}
icon={ChevronDown}
></Button>
</div>
{#if settings.debugInfo}
<MenuButton
onclick={() => {
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>
</form>
{/if}