mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: implement new alerts
This commit is contained in:
@@ -3,17 +3,54 @@
|
||||
import type { Notification } from '../stores/notifications';
|
||||
|
||||
export let type: Notification['type'] = 'info';
|
||||
export let title: Notification['title'];
|
||||
|
||||
let icon: string;
|
||||
switch (type) {
|
||||
case 'success':
|
||||
icon = 'check-circle';
|
||||
break;
|
||||
case 'warning':
|
||||
icon = 'exclamation';
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
icon = 'exclamation-circle';
|
||||
break;
|
||||
|
||||
case 'info':
|
||||
icon = 'info';
|
||||
break;
|
||||
|
||||
default:
|
||||
icon = '';
|
||||
break;
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
</script>
|
||||
|
||||
<li class="toaster-item">
|
||||
<div class={`toaster-message is-${type}`}>
|
||||
<button class="x-button" on:click={() => dispatch('dismiss')}>
|
||||
<span class="icon-cancel" aria-hidden="true" />
|
||||
</button>
|
||||
<span class="text">
|
||||
<slot />
|
||||
</span>
|
||||
<li class={`alert-sticky is-${type}`}>
|
||||
<button class="x-button" aria-label="close alert" on:click={() => dispatch('dismiss')}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
<div class="alert-sticky-image">
|
||||
<span class={`icon-${icon}`} aria-hidden="true" />
|
||||
</div>
|
||||
<div class="alert-sticky-content">
|
||||
{#if title}
|
||||
<h4 class="alert-sticky-title">{title}</h4>
|
||||
{/if}
|
||||
<p><slot /></p>
|
||||
</div>
|
||||
<!--
|
||||
<div class="buttons u-flex">
|
||||
<button class="button is-text is-small">
|
||||
<span class="text">Action 1</span>
|
||||
</button>
|
||||
<button class="button is-text is-small">
|
||||
<span class="text">Action 2</span>
|
||||
</button>
|
||||
</div>
|
||||
-->
|
||||
</li>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
{#each $notifications as notification (notification.id)}
|
||||
<Notification
|
||||
type={notification.type}
|
||||
title={notification.title}
|
||||
on:dismiss={() => dismissNotification(notification.id)}>
|
||||
{notification.message}
|
||||
</Notification>
|
||||
@@ -20,10 +21,8 @@
|
||||
<style lang="scss">
|
||||
section {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: calc(var(--main-header-height) + 24px);
|
||||
right: 24px;
|
||||
z-index: 1000;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,6 +6,7 @@ export type Notification = {
|
||||
dismissible?: boolean;
|
||||
timeout?: number;
|
||||
message: string;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
let counter = 0;
|
||||
|
||||
Reference in New Issue
Block a user