fix: multiple layout shifts with the spinner
This commit is contained in:
4 files changed
+25
-23
No files matched your search
+15
-14
@@ -27,7 +27,21 @@
|
|||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<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
|
<svg
|
||||||
width="40"
|
width="40"
|
||||||
height="40"
|
height="40"
|
||||||
@@ -73,18 +87,5 @@
|
|||||||
.animate-spin {
|
.animate-spin {
|
||||||
animation: spin 0.9s linear infinite;
|
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>
|
</style>
|
||||||
</html>
|
</html>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { findClosestNumber } from '$lib/util.svelte.js'
|
import { findClosestNumber } from '$lib/util.svelte.js'
|
||||||
import { createAvatar } from '@dicebear/core'
|
import { createAvatar } from '@dicebear/core'
|
||||||
import * as initials from '@dicebear/initials'
|
import * as initials from '@dicebear/initials'
|
||||||
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
|
||||||
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
|
const sizes = [16, 24, 32, 48, 64, 96, 128, 256, 512]
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
width: number
|
width: number
|
||||||
res?: number | undefined
|
res?: number | undefined
|
||||||
style?: string
|
style?: string
|
||||||
class?: string
|
class?: ClassValue
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
{alt}
|
{alt}
|
||||||
{width}
|
{width}
|
||||||
{title}
|
{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}"
|
style="width: {width}px; height: {width}px; {style}"
|
||||||
class:rounded-full={circle}
|
class:rounded-full={circle}
|
||||||
class:rounded-md={!circle}
|
class:rounded-md={!circle}
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
style="width: {width}px; height: {width}px;"
|
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-full={circle}
|
||||||
class:rounded-md={!circle}
|
class:rounded-md={!circle}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Profile } from '$lib/auth.svelte.js'
|
import type { Profile } from '$lib/auth.svelte.js'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { Icon, UserCircle } from 'svelte-hero-icons'
|
import { Icon, UserCircle } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -25,18 +26,17 @@
|
|||||||
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}
|
{#if profile.avatar}
|
||||||
<img
|
<Avatar
|
||||||
src="{profile.avatar}?thumbnail=32&format=webp"
|
url={profile.avatar}
|
||||||
alt={profile.username}
|
|
||||||
width={size}
|
width={size}
|
||||||
height={size}
|
alt=""
|
||||||
class={['flex-shrink-0 rounded-full', selected && 'scale-75']}
|
class={['flex-shrink-0 rounded-full', selected && 'scale-75']}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Icon
|
<Icon
|
||||||
src={UserCircle}
|
src={UserCircle}
|
||||||
mini={selected}
|
mini={selected}
|
||||||
size={`${size}`}
|
size={size?.toString()}
|
||||||
title={profile.username}
|
title={profile.username}
|
||||||
class="text-blue-500 flex-shrink-0"
|
class="text-blue-500 flex-shrink-0"
|
||||||
style={guest
|
style={guest
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
<Navbar class={c} style={s} />
|
<Navbar class={c} style={s} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet suffix({ class: c, style: s })}
|
{#snippet suffix({ class: c, style: s })}
|
||||||
<div class={c} style={s}>
|
<div class=" {c}" style={s}>
|
||||||
{#if page.data.slots?.sidebar?.component}
|
{#if page.data.slots?.sidebar?.component}
|
||||||
{@const SvelteComponent = page.data.slots.sidebar.component}
|
{@const SvelteComponent = page.data.slots.sidebar.component}
|
||||||
<SvelteComponent {...page.data.slots.sidebar.props} />
|
<SvelteComponent {...page.data.slots.sidebar.props} />
|
||||||
|
|||||||
Reference in new issue
Block a user