feat: Add login stuff
This commit is contained in:
1 parent
f71ad4be8e
commit
f0523b0c3f
18 files changed
+288
-56
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
export enum ToastType {
|
||||
'error' = 'from-red-400 to-red-400 text-red-400',
|
||||
'warning' = 'from-yellow-300 to-yellow-300 text-yellow-300',
|
||||
'success' = 'from-green-400 to-green-400 text-green-400',
|
||||
'info' = '',
|
||||
}
|
||||
|
||||
export interface Toast {
|
||||
id: number
|
||||
title: string
|
||||
content: string
|
||||
type: ToastType
|
||||
}
|
||||
|
||||
export const toasts = writable<Toast[]>([])
|
||||
|
||||
export function addToast(title: string, content: string, type: ToastType) {
|
||||
let id = 0
|
||||
|
||||
toasts.update((toasts) => {
|
||||
id = Math.floor(Math.random() * 10000)
|
||||
|
||||
return [
|
||||
{
|
||||
id: id,
|
||||
content: content,
|
||||
title: title,
|
||||
type: type,
|
||||
},
|
||||
...toasts,
|
||||
]
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
}, 5000)
|
||||
}
|
||||
Reference in new issue
Block a user