hantera global state för meny öppen/stängd

F5 för det är protype
This commit is contained in:
botvid johansson 2025-02-10 16:00:46 +01:00
parent 736018b839
commit dc83521730
2 changed files with 15 additions and 2 deletions

View File

@ -35,13 +35,17 @@ let selectedColor = 0;
export const shortforms = $state({ standardList: "", subjectLists: [], cache: new Map() }) export const shortforms = $state({ standardList: "", subjectLists: [], cache: new Map() })
export const importState = $state({ data: "", errors: [] }) export const importState = $state({ data: "", errors: [] })
export const textSettings = $state({ font: "Arial", size: 30, colors: colorSetting, padding: 0, lineheight: 1 }) export const textSettings = $state({ font: "Arial", size: 30, colors: colorSetting, padding: 0, lineheight: 1 })
export const appState = $state({ text: "" }) export const appState = $state({ text: "", menuOpen: false })
export const selectNextColor = () => { export const selectNextColor = () => {
selectedColor += 1 selectedColor += 1
textSettings.colors = colorThemes[(selectedColor % 6)] textSettings.colors = colorThemes[(selectedColor % 6)]
} }
export const toggleMenuOpen = () => {
appState.menuOpen = !appState.menuOpen
}
export const incTextSize = () => { export const incTextSize = () => {
console.log(textSettings.size) console.log(textSettings.size)
if (textSettings.size < 200) { if (textSettings.size < 200) {

View File

@ -1,7 +1,7 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import type { ExpanderType } from "./index.d.ts"; import type { ExpanderType } from "./index.d.ts";
import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWindow } from "@tauri-apps/api/window";
import { incTextSize, decTextSize, selectNextColor, appState } from "$lib/stores.svelte" import { incTextSize, decTextSize, selectNextColor, toggleMenuOpen, appState } from "$lib/stores.svelte"
let fullscreen = true; let fullscreen = true;
export const defaultExpanders: Map<string, ExpanderType> = new Map(); export const defaultExpanders: Map<string, ExpanderType> = new Map();
@ -93,6 +93,15 @@ hotkeys.set("F4", {
appState.text = "" appState.text = ""
} }
}) })
hotkeys.set("F5", {
action: (e) => {
e.preventDefault()
toggleMenuOpen()
console.log("Menu open", appState.menuOpen)
}
})
hotkeys.set("F6", { hotkeys.set("F6", {
action: (e) => { action: (e) => {
e.preventDefault() e.preventDefault()