Skip to content

Commit cc7a2be

Browse files
committed
refactor(keymap): rework how space keys and layout indicator are handled
1 parent 64cbbfc commit cc7a2be

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

frontend/src/styles/keymap.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
}
5050
}
5151

52-
&.keySpace {
52+
&.layoutIndicator {
5353
width: 100%;
5454
&:hover {
5555
cursor: pointer;
5656
color: var(--main-color);
5757
}
5858
}
5959

60-
&.keySplitSpace {
60+
&.keySpace.right {
6161
width: 100%;
6262
opacity: 0;
6363
}
@@ -153,7 +153,7 @@
153153
.r5 {
154154
grid-template-columns: 5fr 3fr 1fr 3fr 4.5fr;
155155
}
156-
.keySplitSpace {
156+
.keySpace.right {
157157
opacity: 1;
158158
}
159159
}
@@ -181,7 +181,7 @@
181181
.r5 {
182182
grid-template-columns: 1fr 2fr 3fr 1fr 3fr 2fr 1fr;
183183
}
184-
.keySplitSpace {
184+
.keySpace.right {
185185
opacity: 1;
186186
}
187187
}
@@ -434,7 +434,7 @@
434434
.r5 {
435435
grid-template-columns: 5fr 3fr 1fr 3fr 4.5fr;
436436
}
437-
.keySplitSpace {
437+
.keySpace.right {
438438
opacity: 1;
439439
}
440440

@@ -443,7 +443,7 @@
443443
margin-left: -5%;
444444
margin-top: 21%;
445445
}
446-
div.keySplitSpace {
446+
div.keySpace.right {
447447
transform: rotate(-10deg);
448448
margin-left: -33%;
449449
margin-top: 20%;

frontend/src/ts/elements/keymap.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function highlightKey(currentKey: string): void {
3333
currentKey = Hangul.disassemble(currentKey)[0] ?? currentKey;
3434
}
3535
if (currentKey === " ") {
36-
highlightKey = "#keymap .keySpace, #keymap .keySplitSpace";
36+
highlightKey = "#keymap .keySpace";
3737
} else if (currentKey === '"') {
3838
highlightKey = `#keymap .keymapKey[data-key*='${currentKey}']`;
3939
} else {
@@ -54,7 +54,7 @@ async function flashKey(key: string, correct?: boolean): Promise<void> {
5454
if (key === undefined) return;
5555
//console.log("key", key);
5656
if (key === " ") {
57-
key = "#keymap .keySpace, #keymap .keySplitSpace";
57+
key = "#keymap .keySpace";
5858
} else if (key === '"') {
5959
key = `#keymap .keymapKey[data-key*='${key}']`;
6060
} else {
@@ -209,11 +209,11 @@ export async function refresh(
209209
letterStyle = `style="display: none;"`;
210210
}
211211
rowElement += "<div></div>";
212-
rowElement += `<div class="keymapKey keySpace">
212+
rowElement += `<div class="keymapKey keySpace layoutIndicator left">
213213
<div class="letter" ${letterStyle}>${layoutDisplay}</div>
214214
</div>`;
215215
rowElement += `<div class="keymapSplitSpacer"></div>`;
216-
rowElement += `<div class="keymapKey keySplitSpace">
216+
rowElement += `<div class="keymapKey keySpace right">
217217
<div class="letter"></div>
218218
</div>`;
219219
} else {

frontend/src/ts/event-handlers/keymap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getCommandline } from "../utils/async-modules";
22

3-
$("#keymap").on("click", ".r5 .keySpace", async () => {
3+
$("#keymap").on("click", ".r5 .layoutIndicator", async () => {
44
(await getCommandline()).show({
55
subgroupOverride: "keymapLayouts",
66
});

frontend/src/ts/test/shift-tracker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ async function updateKeymapLegendCasing(): Promise<void> {
4444
const keymapKeys = [...document.getElementsByClassName("keymapKey")].filter(
4545
(el) => {
4646
const isKeymapKey = el.classList.contains("keymapKey");
47-
const isNotSpace =
48-
!el.classList.contains("keySpace") &&
49-
!el.classList.contains("keySplitSpace");
47+
const isNotSpace = !el.classList.contains("keySpace");
5048

5149
return isKeymapKey && isNotSpace;
5250
}

0 commit comments

Comments
 (0)