open-webui/src/lib/components/NotificationToast.svelte

40 lines
1 KiB
Svelte
Raw Normal View History

2024-12-19 23:14:09 +00:00
<script lang="ts">
import DOMPurify from 'dompurify';
import { marked } from 'marked';
2024-12-25 01:33:49 +00:00
import { createEventDispatcher, onMount } from 'svelte';
2024-12-19 23:14:09 +00:00
const dispatch = createEventDispatcher();
export let onClick: Function = () => {};
export let title: string = 'HI';
export let content: string;
2024-12-25 01:33:49 +00:00
onMount(() => {
const audio = new Audio(`/audio/notification.mp3`);
audio.play();
});
2024-12-19 23:14:09 +00:00
</script>
<button
2024-12-20 04:11:13 +00:00
class="flex gap-2.5 text-left min-w-[var(--width)] w-full dark:bg-gray-850 dark:text-white bg-white text-black border border-gray-50 dark:border-gray-800 rounded-xl px-3.5 py-3.5"
2024-12-19 23:14:09 +00:00
on:click={() => {
onClick();
dispatch('closeToast');
}}
>
2024-12-19 23:16:51 +00:00
<div class="flex-shrink-0 self-top -translate-y-0.5">
<img src={'/static/favicon.png'} alt="favicon" class="size-7 rounded-full" />
2024-12-19 23:14:09 +00:00
</div>
<div>
{#if title}
2024-12-25 01:25:59 +00:00
<div class=" text-[13px] font-medium mb-0.5 line-clamp-1 capitalize">{title}</div>
2024-12-19 23:14:09 +00:00
{/if}
<div class=" line-clamp-2 text-xs self-center dark:text-gray-300 font-normal">
{@html DOMPurify.sanitize(marked(content))}
</div>
</div>
</button>