forked from tsai/budibase
10 changed files with 106 additions and 98 deletions
@ -1,60 +1,59 @@ |
|||||
<script> |
<script> |
||||
import { flip } from 'svelte/animate'; |
import { flip } from "svelte/animate" |
||||
import { fly } from "svelte/transition" |
import { fly } from "svelte/transition" |
||||
import { getContext } from "svelte" |
import { getContext } from "svelte" |
||||
const { notifications } = getContext("sdk") |
const { notifications } = getContext("sdk") |
||||
|
|
||||
export let themes = { |
export let themes = { |
||||
danger: "#E26D69", |
danger: "#E26D69", |
||||
success: "#84C991", |
success: "#84C991", |
||||
warning: "#f0ad4e", |
warning: "#f0ad4e", |
||||
info: "#5bc0de", |
info: "#5bc0de", |
||||
default: "#aaaaaa", |
default: "#aaaaaa", |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<div class="notifications"> |
<div class="notifications"> |
||||
{#each $notifications as notification (notification.id)} |
{#each $notifications as notification (notification.id)} |
||||
<div |
<div |
||||
animate:flip |
animate:flip |
||||
class="toast" |
class="toast" |
||||
style="background: {themes[notification.type]};" |
style="background: {themes[notification.type]};" |
||||
transition:fly={{ y: -30 }}> |
transition:fly={{ y: -30 }}> |
||||
<div class="content">{notification.message}</div> |
<div class="content">{notification.message}</div> |
||||
{#if notification.icon}<i class={notification.icon} />{/if} |
{#if notification.icon}<i class={notification.icon} />{/if} |
||||
</div> |
</div> |
||||
{/each} |
{/each} |
||||
</div> |
</div> |
||||
|
|
||||
<style> |
<style> |
||||
.notifications { |
.notifications { |
||||
position: fixed; |
position: fixed; |
||||
top: 10px; |
top: 10px; |
||||
left: 0; |
left: 0; |
||||
right: 0; |
right: 0; |
||||
margin: 0 auto; |
margin: 0 auto; |
||||
padding: 0; |
padding: 0; |
||||
z-index: 9999; |
z-index: 9999; |
||||
display: flex; |
display: flex; |
||||
flex-direction: column; |
flex-direction: column; |
||||
justify-content: flex-start; |
justify-content: flex-start; |
||||
align-items: center; |
align-items: center; |
||||
pointer-events: none; |
pointer-events: none; |
||||
} |
} |
||||
|
|
||||
.toast { |
.toast { |
||||
flex: 0 0 auto; |
flex: 0 0 auto; |
||||
margin-bottom: 10px; |
margin-bottom: 10px; |
||||
border-radius: var(--border-radius-s); |
border-radius: var(--border-radius-s); |
||||
/* The toasts now support being auto sized, so this static width could be removed */ |
/* The toasts now support being auto sized, so this static width could be removed */ |
||||
width: 40vw; |
width: 40vw; |
||||
} |
} |
||||
|
|
||||
.content { |
.content { |
||||
padding: 10px; |
padding: 10px; |
||||
display: block; |
display: block; |
||||
color: white; |
color: white; |
||||
font-weight: 500; |
font-weight: 500; |
||||
} |
} |
||||
</style> |
</style> |
||||
|
|
||||
|
|||||
Loading…
Reference in new issue