feat: add NotificationStack component and notify API for toast notifications
This commit is contained in:
1 parent
d005ee6f51
commit
fc0e376df8
6 files changed
+441
-9
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
import Header from './Header.svelte';
|
||||
import NotificationStack from './NotificationStack.svelte';
|
||||
import PageHeader from './PageHeader.svelte';
|
||||
|
||||
let {
|
||||
@@ -54,6 +55,8 @@
|
||||
</script>
|
||||
|
||||
<div class={`sc-root sc-app-shell ${className}`} data-theme={theme === 'system' ? undefined : theme}>
|
||||
<NotificationStack />
|
||||
|
||||
<Header
|
||||
aboutHref={aboutHref ?? navItems.find((item) => item.label.toLowerCase() === 'about')?.href ?? '/about'}
|
||||
{brand}
|
||||
|
||||
@@ -7,11 +7,14 @@ export { default as Button } from './components/Button.svelte';
|
||||
export { default as Card } from './components/Card.svelte';
|
||||
export { default as Dialog } from './components/Dialog.svelte';
|
||||
export { default as Header } from './components/Header.svelte';
|
||||
export { default as NotificationStack } from './components/NotificationStack.svelte';
|
||||
export { default as PageHeader } from './components/PageHeader.svelte';
|
||||
export { default as ProfileDialog } from './components/ProfileDialog.svelte';
|
||||
export { default as SettingsDialog } from './components/SettingsDialog.svelte';
|
||||
export { default as TotpSettings } from './components/TotpSettings.svelte';
|
||||
export { default as UserManagement } from './components/UserManagement.svelte';
|
||||
export { notifications, notify } from './notifications.svelte';
|
||||
export type { NotificationEntry, NotificationVariant } from './notifications.svelte';
|
||||
export type {
|
||||
AboutLink,
|
||||
AsyncAction,
|
||||
|
||||
@@ -717,6 +717,86 @@
|
||||
color: var(--sc-fg);
|
||||
}
|
||||
|
||||
.sc-notification-stack {
|
||||
position: fixed;
|
||||
z-index: 200;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
display: grid;
|
||||
gap: 0.625rem;
|
||||
width: min(100% - 2rem, 24rem);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sc-notification {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
padding: 0.875rem 1rem;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-raised);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-md);
|
||||
box-shadow: var(--sc-shadow-lg);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.sc-notification-icon {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 0.125rem;
|
||||
color: var(--sc-muted-fg);
|
||||
}
|
||||
|
||||
.sc-notification[data-variant="success"] .sc-notification-icon {
|
||||
color: var(--sc-success);
|
||||
}
|
||||
|
||||
.sc-notification[data-variant="error"] .sc-notification-icon {
|
||||
color: var(--sc-danger);
|
||||
}
|
||||
|
||||
.sc-notification[data-variant="warning"] .sc-notification-icon {
|
||||
color: var(--sc-warning);
|
||||
}
|
||||
|
||||
.sc-notification[data-variant="info"] .sc-notification-icon {
|
||||
color: var(--sc-primary);
|
||||
}
|
||||
|
||||
.sc-notification-message {
|
||||
flex: 1 1 auto;
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.sc-notification-close {
|
||||
display: grid;
|
||||
flex: 0 0 auto;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
place-items: center;
|
||||
color: var(--sc-muted-fg);
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: var(--sc-radius-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sc-notification-close:hover {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
}
|
||||
|
||||
@media (max-width: 30rem) {
|
||||
.sc-notification-stack {
|
||||
top: 0.75rem;
|
||||
right: 0.75rem;
|
||||
left: 0.75rem;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.sc-dialog-backdrop {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
|
||||
Reference in new issue
Block a user