2024-05-26 19:18:43 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import type { Banner } from '$lib/types';
|
|
|
|
import { onMount, createEventDispatcher } from 'svelte';
|
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
export let banner: Banner = {
|
|
|
|
id: '',
|
|
|
|
type: 'info',
|
|
|
|
title: '',
|
|
|
|
content: '',
|
|
|
|
url: '',
|
|
|
|
dismissable: true,
|
|
|
|
timestamp: Math.floor(Date.now() / 1000)
|
|
|
|
};
|
|
|
|
|
|
|
|
export let dismissed = false;
|
|
|
|
|
|
|
|
let mounted = false;
|
|
|
|
|
|
|
|
const classNames: Record<string, string> = {
|
|
|
|
info: 'bg-blue-500/20 text-blue-700 dark:text-blue-200 ',
|
|
|
|
success: 'bg-green-500/20 text-green-700 dark:text-green-200',
|
|
|
|
warning: 'bg-yellow-500/20 text-yellow-700 dark:text-yellow-200',
|
|
|
|
error: 'bg-red-500/20 text-red-700 dark:text-red-200'
|
|
|
|
};
|
|
|
|
|
|
|
|
const dismiss = (id) => {
|
|
|
|
dismissed = true;
|
|
|
|
dispatch('dismiss', id);
|
|
|
|
};
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
mounted = true;
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2024-05-26 19:32:57 +00:00
|
|
|
{#if !dismissed}
|
|
|
|
{#if mounted}
|
2024-05-26 19:18:43 +00:00
|
|
|
<div
|
2024-06-04 07:45:56 +00:00
|
|
|
class=" top-0 left-0 right-0 p-2 mx-4 px-3 flex justify-center items-center relative rounded-xl border border-gray-50 dark:border-gray-850 text-gray-800 dark:text-gary-100 bg-white dark:bg-gray-900 backdrop-blur-xl z-30"
|
2024-05-26 19:32:57 +00:00
|
|
|
transition:fade={{ delay: 100, duration: 300 }}
|
2024-05-26 19:18:43 +00:00
|
|
|
>
|
|
|
|
<div class=" flex flex-col md:flex-row md:items-center flex-1 text-sm w-fit gap-1.5">
|
|
|
|
<div class="flex justify-between self-start">
|
|
|
|
<div
|
2024-07-08 20:35:25 +00:00
|
|
|
class=" text-xs font-bold {classNames[banner.type] ??
|
2024-05-26 19:32:57 +00:00
|
|
|
classNames['info']} w-fit px-2 rounded uppercase line-clamp-1 mr-0.5"
|
2024-05-26 19:18:43 +00:00
|
|
|
>
|
|
|
|
{banner.type}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if banner.url}
|
|
|
|
<div class="flex md:hidden group w-fit md:items-center">
|
|
|
|
<a
|
2024-07-08 20:35:25 +00:00
|
|
|
class="text-gray-700 dark:text-white text-xs font-semibold underline"
|
2024-05-26 19:18:43 +00:00
|
|
|
href="/assets/files/whitepaper.pdf"
|
|
|
|
target="_blank">Learn More</a
|
|
|
|
>
|
|
|
|
|
|
|
|
<div
|
|
|
|
class=" ml-1 text-gray-400 group-hover:text-gray-600 dark:group-hover:text-white"
|
|
|
|
>
|
|
|
|
<!-- -->
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="currentColor"
|
|
|
|
class="w-4 h-4"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fill-rule="evenodd"
|
|
|
|
d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z"
|
|
|
|
clip-rule="evenodd"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex-1 text-xs text-gray-700 dark:text-white">
|
|
|
|
{banner.content}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if banner.url}
|
|
|
|
<div class="hidden md:flex group w-fit md:items-center">
|
|
|
|
<a
|
2024-07-08 20:35:25 +00:00
|
|
|
class="text-gray-700 dark:text-white text-xs font-semibold underline"
|
2024-05-26 19:18:43 +00:00
|
|
|
href="/"
|
|
|
|
target="_blank">Learn More</a
|
|
|
|
>
|
|
|
|
|
|
|
|
<div class=" ml-1 text-gray-400 group-hover:text-gray-600 dark:group-hover:text-white">
|
|
|
|
<!-- -->
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="currentColor"
|
|
|
|
class="size-4"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fill-rule="evenodd"
|
|
|
|
d="M4.22 11.78a.75.75 0 0 1 0-1.06L9.44 5.5H5.75a.75.75 0 0 1 0-1.5h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-1.5 0V6.56l-5.22 5.22a.75.75 0 0 1-1.06 0Z"
|
|
|
|
clip-rule="evenodd"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2024-05-26 19:32:57 +00:00
|
|
|
<div class="flex self-start">
|
2024-05-26 19:18:43 +00:00
|
|
|
{#if banner.dismissible}
|
|
|
|
<button
|
|
|
|
on:click={() => {
|
|
|
|
dismiss(banner.id);
|
|
|
|
}}
|
2024-05-26 19:32:57 +00:00
|
|
|
class=" -mt-[3px] ml-1.5 mr-1 text-gray-400 dark:hover:text-white h-1">×</button
|
2024-05-26 19:18:43 +00:00
|
|
|
>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{/if}
|