From 8d02623c8caac27e516f6d6270b4ac404556efd8 Mon Sep 17 00:00:00 2001 From: Alexander Daichendt Date: Wed, 3 Aug 2022 20:23:19 +0200 Subject: [PATCH] feat: initial cat page --- src/lib/components/Image.svelte | 27 ++++++++++ src/lib/components/blurupplaceholder.svelte | 22 ++++++++ src/lib/utils/types.ts | 12 +++++ src/lib/utils/utils.ts | 17 ++++++ src/routes/__layout.svelte | 1 + src/routes/admin/index.svelte | 8 ++- src/routes/cat/index.svelte | 57 ++++++++++++++++++--- 7 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 src/lib/components/Image.svelte create mode 100644 src/lib/components/blurupplaceholder.svelte create mode 100644 src/lib/utils/utils.ts diff --git a/src/lib/components/Image.svelte b/src/lib/components/Image.svelte new file mode 100644 index 0000000..ef093b1 --- /dev/null +++ b/src/lib/components/Image.svelte @@ -0,0 +1,27 @@ + + +{#if !fallback && !metadata} + No metadata supplied +{:else} + A cute kitty +{/if} + + diff --git a/src/lib/components/blurupplaceholder.svelte b/src/lib/components/blurupplaceholder.svelte new file mode 100644 index 0000000..1087581 --- /dev/null +++ b/src/lib/components/blurupplaceholder.svelte @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/src/lib/utils/types.ts b/src/lib/utils/types.ts index bc39e5c..f2ff897 100644 --- a/src/lib/utils/types.ts +++ b/src/lib/utils/types.ts @@ -15,3 +15,15 @@ export interface Skill { years: number; started: number; } + +export interface ImageMetadata { + href: string; + mime: string; + width: number; +} + +export interface Thumbnail { + value: string; + width: number; + height: number; +} diff --git a/src/lib/utils/utils.ts b/src/lib/utils/utils.ts new file mode 100644 index 0000000..8c30169 --- /dev/null +++ b/src/lib/utils/utils.ts @@ -0,0 +1,17 @@ +export const createLoadObserver = (handler: () => void) => { + let waiting = 0; + + const onload = (el) => { + waiting++; + console.log(waiting); + el.addEventListener('load', () => { + waiting--; + console.log('waiting ' + waiting); + if (waiting === 0) { + handler(); + } + }); + }; + + return onload; +}; diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index b0210ff..f497606 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -69,6 +69,7 @@

Copyright {year} Alexander Daichendt