design: update accounts page and commonlist
This commit is contained in:
5 files changed
+165
-41
No files matched your search
@@ -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}
|
||||||
@@ -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>
|
||||||
@@ -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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -132,12 +132,11 @@
|
|||||||
/>
|
/>
|
||||||
{: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"
|
||||||
@@ -158,9 +157,8 @@
|
|||||||
></div>
|
></div>
|
||||||
<ProfileAvatar
|
<ProfileAvatar
|
||||||
profile={p}
|
profile={p}
|
||||||
{index}
|
|
||||||
selected={profile?.current.id == p.id}
|
selected={profile?.current.id == p.id}
|
||||||
size={32}
|
size={24}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col overflow-hidden">
|
<div class="flex flex-col overflow-hidden">
|
||||||
<span class="break-words font-medium text-base">
|
<span class="break-words font-medium text-base">
|
||||||
@@ -171,7 +169,7 @@
|
|||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
<span class="text-xs text-slate-600 dark:text-zinc-400">
|
||||||
<span class="capitalize">
|
<span class="capitalize">
|
||||||
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
|
{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}
|
||||||
</span>
|
</span>
|
||||||
@@ -236,7 +234,8 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
{/snippet}
|
</li>
|
||||||
|
{/each}
|
||||||
</CommonList>
|
</CommonList>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in new issue
Block a user