aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/ui/src/stores/ui.svelte.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/ui/src/stores/ui.svelte.ts')
-rw-r--r--packages/ui/src/stores/ui.svelte.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/ui/src/stores/ui.svelte.ts b/packages/ui/src/stores/ui.svelte.ts
new file mode 100644
index 0000000..e88f6b4
--- /dev/null
+++ b/packages/ui/src/stores/ui.svelte.ts
@@ -0,0 +1,32 @@
+import { type ViewType } from "../types";
+
+export class UIState {
+ currentView: ViewType = $state("home");
+ status = $state("Ready");
+ showConsole = $state(false);
+ appVersion = $state("...");
+
+ private statusTimeout: ReturnType<typeof setTimeout> | null = null;
+
+ setStatus(msg: string) {
+ if (this.statusTimeout) clearTimeout(this.statusTimeout);
+
+ this.status = msg;
+
+ if (msg !== "Ready") {
+ this.statusTimeout = setTimeout(() => {
+ this.status = "Ready";
+ }, 5000);
+ }
+ }
+
+ toggleConsole() {
+ this.showConsole = !this.showConsole;
+ }
+
+ setView(view: ViewType) {
+ this.currentView = view;
+ }
+}
+
+export const uiState = new UIState();