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
+41
View File
@@ -0,0 +1,41 @@
import type {Component} from "svelte"
import {writable} from "svelte/store"
import {randomId} from "@welshman/lib"
import {copyToClipboard} from "@lib/html"
export type ToastParams = {
message?: string
timeout?: number
theme?: "error"
children?: {
component: Component<any>
props: Record<string, any>
}
action?: {
message: string
onclick: () => void
}
}
export type Toast = ToastParams & {
id: string
}
export const toast = writable<Toast | null>(null)
export const pushToast = (params: ToastParams) => {
const id = randomId()
toast.set({id, ...params})
setTimeout(() => popToast(id), params.timeout || 5000)
return id
}
export const popToast = (id: string) => toast.update($t => ($t?.id === id ? null : $t))
export const clip = (value: string) => {
copyToClipboard(value)
pushToast({message: "Copied to clipboard!"})
}