aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Skeleton.svelte
blob: 839d7985d4bd3f1ff4ca72911693b837386a3d23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script lang="ts">
	export let count = 3;
	export let width = '100%';
	export let height = '100px';
	export let card = true;
</script>

{#each Array(count) as _, i}
	<div class={card ? 'card card-small' : ''} style={`width: ${width};`}>
		<div class="skeleton-container">
			<div class="skeleton" style={`width: ${width}; height: ${height};`} />
		</div>
	</div>

	{#if i < count - 1}
		<p />
	{/if}
{/each}

<style>
	@keyframes progress {
		0% {
			background-position: -200px 0;
		}
		100% {
			background-position: calc(200px + 100%) 0;
		}
	}

	.skeleton-container {
		animation: progress 1.2s ease-in-out infinite;
		background-color: var(--base001);
		background-image: linear-gradient(90deg, var(--base0011), var(--base01), var(--base0011));
		background-size: 200px 100%;
		background-repeat: no-repeat;
		border-radius: 8px;
	}

	.skeleton {
		border-radius: 4px;
		display: inline-block;
		line-height: 1;
	}
</style>