mirror of https://github.com/Budibase/budibase.git
47 changed files with 197 additions and 203 deletions
@ -0,0 +1,44 @@ |
|||
<script> |
|||
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' |
|||
</script> |
|||
|
|||
<Portal target=".modal-container"> |
|||
<div class="notifications"> |
|||
{#each $notifications as {type, icon, message, id} (id)} |
|||
<div animate:flip transition:fly={{ y: -30 }} class="spectrum-Toast spectrum-Toast--{type} notification-offset"> |
|||
{#if icon} |
|||
<svg class="spectrum-Icon spectrum-Icon--sizeM spectrum-Toast-typeIcon" focusable="false" aria-hidden="true"> |
|||
<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> |
|||
</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> |
|||
|
|||
@ -1,70 +0,0 @@ |
|||
<script> |
|||
import { notificationStore } from "builderStore/store/notifications" |
|||
import { flip } from "svelte/animate" |
|||
import { fly } from "svelte/transition" |
|||
|
|||
export let themes = { |
|||
danger: "#E26D69", |
|||
success: "#84C991", |
|||
warning: "#f0ad4e", |
|||
info: "#5bc0de", |
|||
default: "#aaaaaa", |
|||
} |
|||
|
|||
export let timeout = 3000 |
|||
|
|||
$: if ($notificationStore.notifications.length) { |
|||
setTimeout(() => { |
|||
notificationStore.update(state => { |
|||
state.notifications.shift() |
|||
state.notifications = state.notifications |
|||
return state |
|||
}) |
|||
}, timeout) |
|||
} |
|||
</script> |
|||
|
|||
<div class="notifications"> |
|||
{#each $notificationStore.notifications as notification (notification.id)} |
|||
<div |
|||
animate:flip |
|||
class="toast" |
|||
style="background: {themes[notification.type]};" |
|||
transition:fly={{ y: -30 }}> |
|||
<div class="content">{notification.message}</div> |
|||
{#if notification.icon}<i class={notification.icon} />{/if} |
|||
</div> |
|||
{/each} |
|||
</div> |
|||
|
|||
<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; |
|||
} |
|||
|
|||
.toast { |
|||
flex: 0 0 auto; |
|||
margin-bottom: 10px; |
|||
border-radius: var(--border-radius-s); |
|||
/* The toasts now support being auto sized, so this static width could be removed */ |
|||
width: 40vw; |
|||
} |
|||
|
|||
.content { |
|||
padding: 10px; |
|||
display: block; |
|||
color: white; |
|||
font-weight: 500; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue