Skip to content

Commit

Permalink
feat: show the modifier key that is the opposite of the main key
Browse files Browse the repository at this point in the history
  • Loading branch information
aradzie committed Mar 28, 2024
1 parent 8c8f298 commit 8e9fdb4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/keybr-keyboard-ui/lib/PointersLayer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.serial("with modifiers", async (t) => {
await TestRenderer.act(() => {});
await fake.timers.run();

t.is(renderer.root.findAllByType("circle").length, 3);
t.is(renderer.root.findAllByType("circle").length, 2);

t.snapshot(renderer.toJSON());
});
35 changes: 0 additions & 35 deletions packages/keybr-keyboard-ui/lib/PointersLayer.test.tsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,6 @@ Generated by [AVA](https://avajs.dev).
{
children: [
{
children: [
{
children: null,
props: {
attributeName: 'opacity',
dur: '0.5s',
from: 0,
repeatCount: '1',
restart: 'always',
to: 1,
},
type: 'animate',
},
{
children: null,
props: {
attributeName: 'r',
dur: '0.5s',
from: 0,
repeatCount: '1',
restart: 'always',
to: 30,
},
type: 'animate',
},
],
props: {
className: 'modifierPointer',
cx: 45,
cy: 140,
r: 30,
},
type: 'circle',
},
{
children: [
{
Expand Down
Binary file modified packages/keybr-keyboard-ui/lib/PointersLayer.test.tsx.snap
Binary file not shown.
36 changes: 28 additions & 8 deletions packages/keybr-keyboard-ui/lib/PointersLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,38 @@ function pointers(keyboard: Keyboard, combo: KeyCombo | null): ReactNode[] {
if (combo.modifier.shift) {
const l = keyboard.getShape("ShiftLeft");
const r = keyboard.getShape("ShiftRight");
children.unshift(
pointer(l, styles.modifierPointer),
pointer(r, styles.modifierPointer),
);
switch (shape.hand) {
case "left":
children.unshift(pointer(r, styles.modifierPointer));
break;
case "right":
children.unshift(pointer(l, styles.modifierPointer));
break;
default:
children.unshift(
pointer(l, styles.modifierPointer),
pointer(r, styles.modifierPointer),
);
break;
}
}
if (combo.modifier.alt) {
const l = keyboard.getShape("AltLeft");
const r = keyboard.getShape("AltRight");
children.unshift(
pointer(l, styles.modifierPointer),
pointer(r, styles.modifierPointer),
);
switch (shape.hand) {
case "left":
children.unshift(pointer(r, styles.modifierPointer));
break;
case "right":
children.unshift(pointer(l, styles.modifierPointer));
break;
default:
children.unshift(
pointer(l, styles.modifierPointer),
pointer(r, styles.modifierPointer),
);
break;
}
}
}
combo = combo.prefix;
Expand Down

0 comments on commit 8e9fdb4

Please sign in to comment.