uniform favicons
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
30
front/src/lib/components/favicon-or-icon.svelte
Normal file
30
front/src/lib/components/favicon-or-icon.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { Database, Key, Mail } from "@lucide/svelte";
|
||||
import { cn } from "../utils";
|
||||
|
||||
let { url, icon="", class: className = "" } = $props();
|
||||
|
||||
let hasError = $state(false);
|
||||
</script>
|
||||
|
||||
<div
|
||||
class={cn(
|
||||
"w-10 h-10 rounded-box bg-neutral text-neutral-content items-center justify-center flex",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{#if url && !hasError}
|
||||
<img
|
||||
src={"https://icons.duckduckgo.com/ip3/" + url + ".ico"}
|
||||
class="rounded-box w-full h-full"
|
||||
alt="Favicon de {url}"
|
||||
onerror={() => { hasError = true }}
|
||||
/>
|
||||
{:else if icon == "password"}
|
||||
<Key />
|
||||
{:else if icon == "email"}
|
||||
<Mail />
|
||||
{:else}
|
||||
<Database />
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user