format: whole project

This commit is contained in:
James Xylight committed 2025-02-04 16:23:31 -08:00
1 parent b883b5f6e0
commit 80269cf275
79 files changed
+590 -612

No files matched your search

+2 -2
View File
@@ -14,10 +14,10 @@
import { fly } from 'svelte/transition'
interface Props {
toast: Toast;
toast: Toast
}
let { toast }: Props = $props();
let { toast }: Props = $props()
</script>
<div
+45 -43
View File
@@ -3,63 +3,65 @@ import { writable } from 'svelte/store'
type ToastType = keyof typeof toastColors
export const toastColors = {
error: 'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
warning:
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
success: 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg'
error:
'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
warning:
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
success:
'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg',
}
export interface Toast {
id: number
title?: string
content: string
type: ToastType
loading?: boolean
action?: () => any
id: number
title?: string
content: string
type: ToastType
loading?: boolean
action?: () => any
}
export const toasts = writable<Toast[]>([])
export function toast({
title,
content,
type = 'info',
duration = 5000,
loading = false,
action
title,
content,
type = 'info',
duration = 5000,
loading = false,
action,
}: {
title?: string
content: string
type?: ToastType
duration?: number
loading?: boolean
action?: () => any
title?: string
content: string
type?: ToastType
duration?: number
loading?: boolean
action?: () => any
}) {
let id = 0
let id = 0
toasts.update((toasts) => {
id = Math.floor(Math.random() * 10000)
toasts.update((toasts) => {
id = Math.floor(Math.random() * 10000)
return [
...toasts,
{
id: id,
content: content,
title: title,
type: type,
loading: loading,
action: action
}
]
})
return [
...toasts,
{
id: id,
content: content,
title: title,
type: type,
loading: loading,
action: action,
},
]
})
setTimeout(() => {
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
}, duration)
setTimeout(() => {
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
}, duration)
return id
return id
}
export const removeToast = (id: number) =>
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))