web: dialog system & basic small dialog

This commit is contained in:
wukko
2024-07-13 19:15:43 +06:00
parent c5fbff560b
commit 4232c3437b
7 changed files with 161 additions and 4 deletions

23
web/src/lib/dialogs.ts Normal file
View File

@@ -0,0 +1,23 @@
import { readable, type Updater } from "svelte/store";
import type { DialogInfo } from "$lib/types/dialog";
let update: (_: Updater<DialogInfo[]>) => void;
export default readable<DialogInfo[]>(
[],
(_, _update) => { update = _update }
);
export function createDialog(newData: DialogInfo) {
update((popups) => {
popups.push(newData);
return popups;
});
}
export function killDialog() {
update((popups) => {
popups.pop()
return popups;
});
}

View File

@@ -0,0 +1,14 @@
export type DialogButton = {
text: string,
color: string,
action: () => unknown | Promise<unknown>
}
export type DialogInfo = {
id: string,
type: "small",
title: string,
bodyText: string,
bodySubText: string,
buttons: DialogButton[]
}