fix: multiple layout shifts with the spinner

This commit is contained in:
James Xylight committed 2025-02-17 11:30:54 -08:00
1 parent d9b45e179b
commit ba8dc7ff22
4 files changed
+25 -23

No files matched your search

+4 -3
View File
@@ -2,6 +2,7 @@
import { findClosestNumber } from '$lib/util.svelte.js'
import { createAvatar } from '@dicebear/core'
import * as initials from '@dicebear/initials'
import type { ClassValue } from 'svelte/elements'
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
@@ -35,7 +36,7 @@
width: number
res?: number | undefined
style?: string
class?: string
class?: ClassValue
[key: string]: any
}
@@ -65,7 +66,7 @@
{alt}
{width}
{title}
class="aspect-square object-cover overflow-hidden {clazz} flex-shrink-0"
class={['aspect-square object-cover overflow-hidden flex-shrink-0', clazz]}
style="width: {width}px; height: {width}px; {style}"
class:rounded-full={circle}
class:rounded-md={!circle}
@@ -73,7 +74,7 @@
{:else}
<div
style="width: {width}px; height: {width}px;"
class="aspect-square object-cover overflow-hidden {clazz} flex-shrink-0"
class={['aspect-square object-cover overflow-hidden flex-shrink-0', clazz]}
class:rounded-full={circle}
class:rounded-md={!circle}
>
+5 -5
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import type { Profile } from '$lib/auth.svelte.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { Icon, UserCircle } from 'svelte-hero-icons'
interface Props {
@@ -25,18 +26,17 @@
class={[profile.avatar && 'bg-slate-200 rounded-full dark:bg-zinc-700']}
>
{#if profile.avatar}
<img
src="{profile.avatar}?thumbnail=32&format=webp"
alt={profile.username}
<Avatar
url={profile.avatar}
width={size}
height={size}
alt=""
class={['flex-shrink-0 rounded-full', selected && 'scale-75']}
/>
{:else}
<Icon
src={UserCircle}
mini={selected}
size={`${size}`}
size={size?.toString()}
title={profile.username}
class="text-blue-500 flex-shrink-0"
style={guest