From eebeaa378d49cc8adb597d00fd05bcc314779888 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 21 Apr 2024 19:51:49 -0700
Subject: refactor(lib): move componenets to modules

---
 src/lib/FallbackImage.svelte | 41 -----------------------------------------
 1 file changed, 41 deletions(-)
 delete mode 100644 src/lib/FallbackImage.svelte

(limited to 'src/lib/FallbackImage.svelte')

diff --git a/src/lib/FallbackImage.svelte b/src/lib/FallbackImage.svelte
deleted file mode 100644
index 3f5e8758..00000000
--- a/src/lib/FallbackImage.svelte
+++ /dev/null
@@ -1,41 +0,0 @@
-<script lang="ts">
-	export let source: string | undefined | null;
-	export let alternative: string | undefined | null;
-	export let fallback: string | undefined | null;
-	export let maxReplaceCount = 1;
-	export let replaceDelay = 1000;
-	export let error = 'https://i2.kym-cdn.com/photos/images/newsfeed/000/290/992/0aa.jpg';
-	export let hideOnError = false;
-	export let style = '';
-
-	let replaceCount = 0;
-
-	const delayedReplace = (event: Event, image: string | undefined | null) => {
-		if (replaceCount >= maxReplaceCount) return;
-
-		setTimeout(() => {
-			(event.target as HTMLImageElement).src = image || '';
-
-			replaceCount += 1;
-		}, replaceDelay);
-	};
-</script>
-
-{#if replaceCount < maxReplaceCount}
-	<img
-		src={source}
-		alt={alternative}
-		loading="lazy"
-		class="badge"
-		on:error={(e) => delayedReplace(e, fallback)}
-		{style}
-	/>
-{:else if !hideOnError}
-	<img src={error} alt="Not found" loading="lazy" class="badge" />
-{/if}
-
-<style>
-	.badge {
-		border-radius: 8px;
-	}
-</style>
-- 
cgit v1.2.3

