From e41e0391ba843b85a5b2890db95121fa39426a05 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 30 Aug 2023 19:07:05 +0200 Subject: feat(frontend): window pane switcher --- subprojects/frontend/src/theme/ThemeStore.ts | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'subprojects/frontend/src/theme/ThemeStore.ts') diff --git a/subprojects/frontend/src/theme/ThemeStore.ts b/subprojects/frontend/src/theme/ThemeStore.ts index 7c657449..fa47d873 100644 --- a/subprojects/frontend/src/theme/ThemeStore.ts +++ b/subprojects/frontend/src/theme/ThemeStore.ts @@ -12,11 +12,19 @@ export enum ThemePreference { PreferDark, } +export type SelectedPane = 'code' | 'graph' | 'table'; + export default class ThemeStore { preference = ThemePreference.System; systemDarkMode: boolean; + showCode = true; + + showGraph = true; + + showTable = false; + constructor() { const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); this.systemDarkMode = mediaQuery.matches; @@ -48,4 +56,44 @@ export default class ThemeStore { : ThemePreference.PreferDark; } } + + toggleCode(): void { + if (!this.showGraph && !this.showTable) { + return; + } + this.showCode = !this.showCode; + } + + toggleGraph(): void { + if (!this.showCode && !this.showTable) { + return; + } + this.showGraph = !this.showGraph; + } + + toggleTable(): void { + if (!this.showCode && !this.showGraph) { + return; + } + this.showTable = !this.showTable; + } + + get selectedPane(): SelectedPane { + if (this.showCode) { + return 'code'; + } + if (this.showGraph) { + return 'graph'; + } + if (this.showTable) { + return 'table'; + } + return 'code'; + } + + setSelectedPane(pane: SelectedPane): void { + this.showCode = pane === 'code'; + this.showGraph = pane === 'graph'; + this.showTable = pane === 'table'; + } } -- cgit v1.2.3-54-g00ecf