diff --git a/index.html b/index.html index c5de112..fa28f09 100644 --- a/index.html +++ b/index.html @@ -10,76 +10,95 @@ class="h-screen flex flex-col justify-center items-center" x-data="keyboard" > - - Layout - + + Layout: - + + + Ortholinear + - - + - - - - + + + + + Staggered - - + + - - + + - + diff --git a/src/lib/colemak.ts b/src/lib/colemak.ts new file mode 100644 index 0000000..ceeb2e5 --- /dev/null +++ b/src/lib/colemak.ts @@ -0,0 +1,85 @@ +export const colemak = [ + [ + { value: "`", staggered: "1em", linear: "1em" }, + { value: "1", staggered: "1em", linear: "1em" }, + { value: "2", staggered: "1em", linear: "1em" }, + { value: "3", staggered: "1em", linear: "1em" }, + { value: "4", staggered: "1em", linear: "1em" }, + { value: "5", staggered: "1em", linear: "1em" }, + { value: "6", staggered: "1em", linear: "1em" }, + { value: "7", staggered: "1em", linear: "1em" }, + { value: "8", staggered: "1em", linear: "1em" }, + { value: "9", staggered: "1em", linear: "1em" }, + { value: "0", staggered: "1em", linear: "1em" }, + { value: "-", staggered: "1em", linear: "1em" }, + { value: "=", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Backspace", staggered: "2em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Tab", staggered: "1.5em", linear: "1em" }, + { value: "Q", staggered: "1em", linear: "1em" }, + { value: "W", staggered: "1em", linear: "1em" }, + { value: "F", staggered: "1em", linear: "1em" }, + { value: "P", staggered: "1em", linear: "1em" }, + { value: "G", staggered: "1em", linear: "1em" }, + { value: "J", staggered: "1em", linear: "1em" }, + { value: "L", staggered: "1em", linear: "1em" }, + { value: "U", staggered: "1em", linear: "1em" }, + { value: "Y", staggered: "1em", linear: "1em" }, + { value: ";", staggered: "1em", linear: "1em" }, + { value: "[", staggered: "1em", linear: "1em" }, + { value: "]", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "\\", staggered: "1.5em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Caps", staggered: "1.75em", linear: "1em" }, + { value: "A", staggered: "1em", linear: "1em" }, + { value: "R", staggered: "1em", linear: "1em" }, + { value: "S", staggered: "1em", linear: "1em" }, + { value: "T", staggered: "1em", linear: "1em" }, + { value: "D", staggered: "1em", linear: "1em" }, + { value: "H", staggered: "1em", linear: "1em" }, + { value: "N", staggered: "1em", linear: "1em" }, + { value: "E", staggered: "1em", linear: "1em" }, + { value: "I", staggered: "1em", linear: "1em" }, + { value: "O", staggered: "1em", linear: "1em" }, + { value: "'", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Enter", staggered: "2.25em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Shift", staggered: "2.25em", linear: "1em" }, + { value: "Z", staggered: "1em", linear: "1em" }, + { value: "X", staggered: "1em", linear: "1em" }, + { value: "C", staggered: "1em", linear: "1em" }, + { value: "V", staggered: "1em", linear: "1em" }, + { value: "B", staggered: "1em", linear: "1em" }, + { value: "K", staggered: "1em", linear: "1em" }, + { value: "M", staggered: "1em", linear: "1em" }, + { value: ",", staggered: "1em", linear: "1em" }, + { value: ".", staggered: "1em", linear: "1em" }, + { value: "/", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Shift", staggered: "2.75em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Ctrl", staggered: "1.25em", linear: "1em" }, + { value: "Win", staggered: "1.25em", linear: "1em" }, + { value: "Alt", staggered: "1.25em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Space", staggered: "5em", flexGrow: true, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Alt", staggered: "1.25em", linear: "1em" }, + { value: "Win", staggered: "1em", linear: "1em" }, + { value: "Fn", staggered: "1em", linear: "1em" }, + { value: "Ctrl", staggered: "1.25em", linear: "1em" }, + ], +]; diff --git a/src/lib/qwerty.ts b/src/lib/qwerty.ts new file mode 100644 index 0000000..65ac420 --- /dev/null +++ b/src/lib/qwerty.ts @@ -0,0 +1,85 @@ +export const qwerty = [ + [ + { value: "`", staggered: "1em", linear: "1em" }, + { value: "1", staggered: "1em", linear: "1em" }, + { value: "2", staggered: "1em", linear: "1em" }, + { value: "3", staggered: "1em", linear: "1em" }, + { value: "4", staggered: "1em", linear: "1em" }, + { value: "5", staggered: "1em", linear: "1em" }, + { value: "6", staggered: "1em", linear: "1em" }, + { value: "7", staggered: "1em", linear: "1em" }, + { value: "8", staggered: "1em", linear: "1em" }, + { value: "9", staggered: "1em", linear: "1em" }, + { value: "0", staggered: "1em", linear: "1em" }, + { value: "-", staggered: "1em", linear: "1em" }, + { value: "=", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Backspace", staggered: "2em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Tab", staggered: "1.5em", linear: "1em" }, + { value: "Q", staggered: "1em", linear: "1em" }, + { value: "W", staggered: "1em", linear: "1em" }, + { value: "E", staggered: "1em", linear: "1em" }, + { value: "R", staggered: "1em", linear: "1em" }, + { value: "T", staggered: "1em", linear: "1em" }, + { value: "Y", staggered: "1em", linear: "1em" }, + { value: "U", staggered: "1em", linear: "1em" }, + { value: "I", staggered: "1em", linear: "1em" }, + { value: "O", staggered: "1em", linear: "1em" }, + { value: "P", staggered: "1em", linear: "1em" }, + { value: "[", staggered: "1em", linear: "1em" }, + { value: "]", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "\\", staggered: "1.5em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Caps", staggered: "1.75em", linear: "1em" }, + { value: "A", staggered: "1em", linear: "1em" }, + { value: "S", staggered: "1em", linear: "1em" }, + { value: "D", staggered: "1em", linear: "1em" }, + { value: "F", staggered: "1em", linear: "1em" }, + { value: "G", staggered: "1em", linear: "1em" }, + { value: "H", staggered: "1em", linear: "1em" }, + { value: "J", staggered: "1em", linear: "1em" }, + { value: "K", staggered: "1em", linear: "1em" }, + { value: "L", staggered: "1em", linear: "1em" }, + { value: ";", staggered: "1em", linear: "1em" }, + { value: "'", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Enter", staggered: "2.25em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Shift", staggered: "2.25em", linear: "1em" }, + { value: "Z", staggered: "1em", linear: "1em" }, + { value: "X", staggered: "1em", linear: "1em" }, + { value: "C", staggered: "1em", linear: "1em" }, + { value: "V", staggered: "1em", linear: "1em" }, + { value: "B", staggered: "1em", linear: "1em" }, + { value: "N", staggered: "1em", linear: "1em" }, + { value: "M", staggered: "1em", linear: "1em" }, + { value: ",", staggered: "1em", linear: "1em" }, + { value: ".", staggered: "1em", linear: "1em" }, + { value: "/", staggered: "1em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Shift", staggered: "2.75em", linear: "1em", flexGrow: true }, + ], + [ + { value: "Ctrl", staggered: "1.25em", linear: "1em" }, + { value: "Win", staggered: "1.25em", linear: "1em" }, + { value: "Alt", staggered: "1.25em", linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Space", staggered: "5em", flexGrow: true, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: " ", staggered: null, linear: "1em" }, + { value: "Alt", staggered: "1.25em", linear: "1em" }, + { value: "Win", staggered: "1em", linear: "1em" }, + { value: "Fn", staggered: "1em", linear: "1em" }, + { value: "Ctrl", staggered: "1.25em", linear: "1em" }, + ], +]; diff --git a/src/main.ts b/src/main.ts index b01950b..075865d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,6 @@ import { Heatmap, defaultHeatmap } from "./defaulHeatmap"; +import { colemak } from "./lib/colemak"; +import { qwerty } from "./lib/qwerty"; import "./style.css"; import Alpine from "alpinejs"; @@ -15,15 +17,14 @@ function readTextFile(file: string): Promise { } Alpine.data("keyboard", () => ({ - layout: "", - sample: "", + layout: "qwerty", + sample: "qwerty", heatmap: defaultHeatmap, samples: {} as Record, - layouts: {} as Record, + layouts: { qwerty, colemak }, + staggered: false, init() { - this.getLayout("neo-german"); - this.$watch("sample", (input) => { this.heatmap = input .replace(/\s/gm, "") @@ -59,14 +60,7 @@ Alpine.data("keyboard", () => ({ }, getLayout(layout: string) { - if (this.layouts.hasOwnProperty(layout)) { - this.layout = this.layouts[layout]; - } else { - readTextFile(`${layout}.txt`).then((text) => { - this.layouts[layout] = text; - this.layout = text; - }); - } + this.layout = layout; }, getColor(value: number) { @@ -75,6 +69,10 @@ Alpine.data("keyboard", () => ({ const l = -(value * 70) + 100; return `hsl(${h}, ${s}%, ${l}%)`; }, + + toggleStaggered() { + this.staggered = !this.staggered; + }, })); Alpine.start();