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

+15 -14
View File
@@ -27,7 +27,21 @@
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div class="loader">
<div
style="
width: 100vw;
height: 100vh;
z-index: -50;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
"
>
<svg
width="40"
height="40"
@@ -73,18 +87,5 @@
.animate-spin {
animation: spin 0.9s linear infinite;
}
.loader {
width: 100vw;
height: 100vh;
z-index: -50;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
}
</style>
</html>
+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
+1 -1
View File
@@ -144,7 +144,7 @@
<Navbar class={c} style={s} />
{/snippet}
{#snippet suffix({ class: c, style: s })}
<div class={c} style={s}>
<div class=" {c}" style={s}>
{#if page.data.slots?.sidebar?.component}
{@const SvelteComponent = page.data.slots.sidebar.component}
<SvelteComponent {...page.data.slots.sidebar.props} />