2021-04-09 12:02:53 +02:00
|
|
|
<script>
|
2021-05-04 12:04:42 +02:00
|
|
|
import "@spectrum-css/toast/dist/index-vars.css"
|
|
|
|
import Portal from "svelte-portal"
|
|
|
|
import { flip } from "svelte/animate"
|
|
|
|
import { fly } from "svelte/transition"
|
|
|
|
import { notifications } from "../Stores/notifications"
|
2021-04-09 12:02:53 +02:00
|
|
|
</script>
|
2021-05-04 12:04:42 +02:00
|
|
|
|
|
|
|
<Portal target=".modal-container">
|
2021-04-09 12:02:53 +02:00
|
|
|
<div class="notifications">
|
2021-05-04 12:04:42 +02:00
|
|
|
{#each $notifications as { type, icon, message, id } (id)}
|
|
|
|
<div
|
|
|
|
animate:flip
|
|
|
|
transition:fly={{ y: -30 }}
|
|
|
|
class="spectrum-Toast spectrum-Toast--{type} notification-offset"
|
|
|
|
>
|
2021-04-09 12:02:53 +02:00
|
|
|
{#if icon}
|
2021-05-04 12:04:42 +02:00
|
|
|
<svg
|
|
|
|
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Toast-typeIcon"
|
|
|
|
focusable="false"
|
|
|
|
aria-hidden="true"
|
|
|
|
>
|
2021-04-09 12:02:53 +02:00
|
|
|
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
|
|
</svg>
|
|
|
|
{/if}
|
|
|
|
<div class="spectrum-Toast-body">
|
|
|
|
<div class="spectrum-Toast-content">{message}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</div>
|
2021-05-04 12:04:42 +02:00
|
|
|
</Portal>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.notifications {
|
|
|
|
position: fixed;
|
|
|
|
top: 10px;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 0;
|
|
|
|
z-index: 9999;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
.notification-offset {
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
</style>
|