Error handling modals

This commit is contained in:
space-nuko
2023-05-21 16:55:18 -05:00
parent 02afbae406
commit a3c10d5be9
12 changed files with 241 additions and 61 deletions

View File

@@ -5,16 +5,18 @@ import { v4 as uuidv4 } from "uuid";
export type ModalButton = {
name: string,
variant: "primary" | "secondary",
onClick: () => void
onClick: () => void,
closeOnClick?: boolean
}
export interface ModalData {
id: string,
title: string,
title?: string,
onClose?: () => void,
svelteComponent?: typeof SvelteComponentDev,
svelteProps?: Record<string, any>,
buttons?: ModalButton[],
showCloseButton?: boolean
svelteProps: Record<string, any>,
buttons: ModalButton[],
showCloseButton: boolean,
closeOnClick: boolean
}
export interface ModalState {
activeModals: ModalData[]
@@ -34,7 +36,10 @@ const store: Writable<ModalState> = writable(
function pushModal(data: Partial<ModalData>) {
const modal: ModalData = {
title: "Modal",
showCloseButton: true,
closeOnClick: true,
buttons: [],
svelteProps: {},
...data,
id: uuidv4(),
}