Add contributing file, rename some files

This commit is contained in:
Jon Staab
2025-08-21 15:01:31 -07:00
parent d4943daa82
commit ba80ebac63
155 changed files with 438 additions and 349 deletions
+48
View File
@@ -0,0 +1,48 @@
import type {Component} from "svelte"
import {writable} from "svelte/store"
import {randomId, always, assoc, Emitter} from "@welshman/lib"
import {goto} from "$app/navigation"
export type ModalOptions = {
drawer?: boolean
fullscreen?: boolean
replaceState?: boolean
path?: string
}
export type Modal = {
id: string
component: Component
props: Record<string, any>
options: ModalOptions
}
export const emitter = new Emitter()
export const modals = writable<Record<string, Modal>>({})
export const pushModal = (
component: Component<any>,
props: Record<string, any> = {},
options: ModalOptions = {},
) => {
const id = randomId()
const path = options.path || ""
modals.update(assoc(id, {id, component, props, options}))
goto(path + "#" + id, {replaceState: options.replaceState})
return id
}
export const pushDrawer = (
component: Component<any>,
props: Record<string, any> = {},
options: ModalOptions = {},
) => pushModal(component, props, {...options, drawer: true})
export const clearModals = () => {
modals.update(always({}))
emitter.emit("close")
}