mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
Implement notification box for web (#533)
* Added test button * styling notification box * Added auto dismission and animation to each notificaiont list * Remove test button
This commit is contained in:
parent
68b1655e7f
commit
f9b1b12b10
6 changed files with 132 additions and 4 deletions
|
|
@ -0,0 +1,36 @@
|
|||
import { writable } from 'svelte/store';
|
||||
|
||||
export enum NotificationType {
|
||||
Info = 'Info',
|
||||
Error = 'Error'
|
||||
}
|
||||
|
||||
export class ImmichNotification {
|
||||
id = new Date().getTime();
|
||||
type!: NotificationType;
|
||||
message!: string;
|
||||
}
|
||||
|
||||
function createNotificationList() {
|
||||
const { set, update, subscribe } = writable<ImmichNotification[]>([]);
|
||||
|
||||
const show = ({ message = '', type = NotificationType.Info }) => {
|
||||
const notification = new ImmichNotification();
|
||||
notification.message = message;
|
||||
notification.type = type;
|
||||
|
||||
update((currentList) => [...currentList, notification]);
|
||||
};
|
||||
|
||||
const removeNotificationById = (id: number) => {
|
||||
update((currentList) => currentList.filter((n) => n.id != id));
|
||||
};
|
||||
|
||||
return {
|
||||
show,
|
||||
removeNotificationById,
|
||||
subscribe
|
||||
};
|
||||
}
|
||||
|
||||
export const notificationList = createNotificationList();
|
||||
Loading…
Add table
Add a link
Reference in a new issue