stuff
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { DeviceEditOp } from "$lib/models/device";
|
||||
import type Device from "$lib/models/device";
|
||||
import type Script from "$lib/models/script";
|
||||
import type { ScriptLine } from "$lib/models/script";
|
||||
import { getContext, setContext } from "svelte";
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
const ctxKey = {ctx: "ModalContext"};
|
||||
|
||||
export type ModalSelection =
|
||||
| { kind: "closed" }
|
||||
| { kind: "device.edit", images: Device[], op: DeviceEditOp }
|
||||
| { kind: "script.edit", id: string | null, lines: ScriptLine[] }
|
||||
| { kind: "script.execute", script: Script }
|
||||
|
||||
export interface ModalContextState {
|
||||
modal: Writable<ModalSelection>
|
||||
}
|
||||
|
||||
export function getModalContext(): ModalContextState {
|
||||
return getContext(ctxKey)
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
setContext<ModalContextState>(ctxKey, {
|
||||
modal: writable({kind: "closed"}),
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot></slot>
|
||||
Reference in New Issue
Block a user