feat: new blocking progress bar, fixes #18

feat: change cloud icon to history, fixes #15
fix: action search items overlap, fixes #16
feat: show tooltips immediately
This commit is contained in:
2023-11-14 20:19:01 +01:00
parent e19a57efac
commit ebf7d73d20
27 changed files with 790 additions and 268 deletions

39
src/lib/os-layout.ts Normal file
View File

@@ -0,0 +1,39 @@
import {persistentWritable} from "$lib/storage"
import {get} from "svelte/store"
export const osLayout = persistentWritable<Record<string, string>>("os-layout", {})
const keysCurrentlyDown = new Set<string>()
function keydown({code, key}: KeyboardEvent) {
const keys = [...keysCurrentlyDown]
keysCurrentlyDown.add(code)
const keyString = JSON.stringify([...keys.sort(), code])
if (keyString in get(osLayout) || get(osLayout)[JSON.stringify([code])] === key) return
osLayout.update(layout => {
layout[keyString] = key
return layout
})
}
function keyup({code}: KeyboardEvent) {
keysCurrentlyDown.delete(code)
}
export function runLayoutDetection() {
if ("keyboard" in navigator) {
;(navigator.keyboard as any).getLayoutMap().then((layout: Map<string, string>) => {
osLayout.update(osLayout => {
Object.assign(
osLayout,
Object.fromEntries([...layout.entries()].map(([key, value]) => [JSON.stringify([key]), value])),
)
return osLayout
})
})
}
window.addEventListener("keydown", keydown)
window.addEventListener("keyup", keyup)
}