-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.pointer { | ||
fill: transparent; | ||
stroke: var(--KeyboardKey-pointer__color); | ||
stroke-opacity: 0.5; | ||
stroke-width: 5px; | ||
} | ||
|
||
.modifierPointer { | ||
fill: transparent; | ||
stroke: var(--KeyboardKey-pointer__color); | ||
stroke-opacity: 0.5; | ||
stroke-width: 3px; | ||
stroke-dasharray: 3px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const pointer: string; | ||
export const modifierPointer: string; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { KeyboardContext, Layout, loadKeyboard } from "@keybr/keyboard"; | ||
import { fake } from "@keybr/test-env-time"; | ||
import test from "ava"; | ||
import TestRenderer from "react-test-renderer"; | ||
import { PointersLayer } from "./PointersLayer.tsx"; | ||
|
||
test.beforeEach(() => { | ||
fake.timers.set(); | ||
}); | ||
|
||
test.afterEach(() => { | ||
fake.timers.reset(); | ||
}); | ||
|
||
test.serial("empty", async (t) => { | ||
const keyboard = loadKeyboard(Layout.EN_US); | ||
|
||
const renderer = TestRenderer.create( | ||
<KeyboardContext.Provider value={keyboard}> | ||
<PointersLayer suffix={[]} /> | ||
</KeyboardContext.Provider>, | ||
); | ||
|
||
await TestRenderer.act(() => {}); | ||
await fake.timers.run(); | ||
|
||
t.is(renderer.root.findAllByType("circle").length, 0); | ||
|
||
t.snapshot(renderer.toJSON()); | ||
}); | ||
|
||
test.serial("unknown", async (t) => { | ||
const keyboard = loadKeyboard(Layout.EN_US); | ||
|
||
const renderer = TestRenderer.create( | ||
<KeyboardContext.Provider value={keyboard}> | ||
<PointersLayer suffix={[0x0000]} /> | ||
</KeyboardContext.Provider>, | ||
); | ||
|
||
await TestRenderer.act(() => {}); | ||
await fake.timers.run(); | ||
|
||
t.is(renderer.root.findAllByType("circle").length, 0); | ||
|
||
t.snapshot(renderer.toJSON()); | ||
}); | ||
|
||
test.serial("without modifiers", async (t) => { | ||
const keyboard = loadKeyboard(Layout.EN_US); | ||
|
||
const renderer = TestRenderer.create( | ||
<KeyboardContext.Provider value={keyboard}> | ||
<PointersLayer suffix={[/* "a" */ 0x0061]} /> | ||
</KeyboardContext.Provider>, | ||
); | ||
|
||
await TestRenderer.act(() => {}); | ||
await fake.timers.run(); | ||
|
||
t.is(renderer.root.findAllByType("circle").length, 1); | ||
|
||
t.snapshot(renderer.toJSON()); | ||
}); | ||
|
||
test.serial("with modifiers", async (t) => { | ||
const keyboard = loadKeyboard(Layout.EN_US); | ||
|
||
const renderer = TestRenderer.create( | ||
<KeyboardContext.Provider value={keyboard}> | ||
<PointersLayer suffix={[/* "A" */ 0x0041]} /> | ||
</KeyboardContext.Provider>, | ||
); | ||
|
||
await TestRenderer.act(() => {}); | ||
await fake.timers.run(); | ||
|
||
t.is(renderer.root.findAllByType("circle").length, 3); | ||
|
||
t.snapshot(renderer.toJSON()); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
# Snapshot report for `lib/PointersLayer.test.tsx` | ||
|
||
The actual snapshot is saved in `PointersLayer.test.tsx.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## empty | ||
|
||
> Snapshot 1 | ||
{ | ||
children: null, | ||
props: { | ||
x: 15, | ||
y: 15, | ||
}, | ||
type: 'svg', | ||
} | ||
|
||
## unknown | ||
|
||
> Snapshot 1 | ||
{ | ||
children: null, | ||
props: { | ||
x: 15, | ||
y: 15, | ||
}, | ||
type: 'svg', | ||
} | ||
|
||
## without modifiers | ||
|
||
> Snapshot 1 | ||
{ | ||
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: 'pointer', | ||
cx: 90, | ||
cy: 100, | ||
r: 30, | ||
}, | ||
type: 'circle', | ||
}, | ||
], | ||
props: { | ||
x: 15, | ||
y: 15, | ||
}, | ||
type: 'svg', | ||
} | ||
|
||
## with modifiers | ||
|
||
> Snapshot 1 | ||
{ | ||
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: 'pointer', | ||
cx: 90, | ||
cy: 100, | ||
r: 30, | ||
}, | ||
type: 'circle', | ||
}, | ||
{ | ||
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: [ | ||
{ | ||
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: 545, | ||
cy: 140, | ||
r: 30, | ||
}, | ||
type: 'circle', | ||
}, | ||
], | ||
props: { | ||
x: 15, | ||
y: 15, | ||
}, | ||
type: 'svg', | ||
} |