feat: initial commit, draft frontend
This commit is contained in:
21
src/lib/Image.svelte
Normal file
21
src/lib/Image.svelte
Normal file
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
type ImageStatus = 'loading' | 'loaded' | 'error';
|
||||
import type { HTMLImgAttributes } from 'svelte/elements';
|
||||
|
||||
let { src, ...props }: HTMLImgAttributes = $props();
|
||||
let status: ImageStatus = $state('loading');
|
||||
</script>
|
||||
|
||||
{#if status === 'loading'}
|
||||
<div class="h-full w-full animate-pulse bg-gray-800"></div>
|
||||
{/if}
|
||||
|
||||
<img
|
||||
{src}
|
||||
hidden={status === 'loading'}
|
||||
onload={() => {
|
||||
status = 'loaded';
|
||||
}}
|
||||
onerror={() => (status = 'error')}
|
||||
{...props}
|
||||
/>
|
||||
Reference in New Issue
Block a user