Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(keyboard-key): add documentation #4164

Merged
merged 83 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
6c1c489
feat(keyboard-key): component init
krisantrobus Oct 30, 2024
e8304e6
chore(tools): plopfile syntax fix
krisantrobus Oct 30, 2024
461015e
chore(tools): plopfile syntax fix
krisantrobus Oct 30, 2024
8edd0b4
chore(tools): plopfile syntax fix
krisantrobus Oct 30, 2024
693ea4a
feat(keyboard-key): styled w/ hook unit tests
krisantrobus Oct 30, 2024
ca523ac
feat(keyboard-key): added variants and styles
krisantrobus Nov 1, 2024
325c87d
chore(plop): update tsx dependency
krisantrobus Nov 1, 2024
18d09d2
chore(keyboard-key): internal exports in core
krisantrobus Nov 1, 2024
3394496
chore(keyboard-key): typedocs & build
krisantrobus Nov 1, 2024
4af2bb6
chore(docs): use KeyboardKey in nav
krisantrobus Nov 1, 2024
5351c0b
docs(keyboard-key): init content
krisantrobus Nov 1, 2024
c7617df
feat(keyboard-key): change to infline-flex style
krisantrobus Nov 1, 2024
ec4c6b9
Merge branch 'create-keyboard-key' of github.com:twilio-labs/paste in…
krisantrobus Nov 1, 2024
d90ada2
docs(keybaord-key): added examples
krisantrobus Nov 1, 2024
b13cde4
chore(keyboard-key): added stroy
krisantrobus Nov 1, 2024
87ab0ff
chore(keyboard-key): linting
krisantrobus Nov 1, 2024
c29afac
fix(keyboard-key): command logic
krisantrobus Nov 4, 2024
d910c26
feat(design-tokens): added new box shadows to support keyboard-keys
krisantrobus Nov 4, 2024
4504056
chore(ci-cd): added chagesets
krisantrobus Nov 4, 2024
6775b36
fix(keyboard-key): boxShadow stylings
krisantrobus Nov 4, 2024
3cc0dff
fix(keyboard-key): remove null component wrapper
krisantrobus Nov 4, 2024
a9b5931
fix(keyboard-key): aria-hidden
krisantrobus Nov 4, 2024
bff42f7
chore(keyboard-key): refactor
krisantrobus Nov 4, 2024
2994e0f
chore(keyboard-key): code cleanup
krisantrobus Nov 4, 2024
720407e
Merge branch 'main' of github.com:twilio-labs/paste into create-keybo…
krisantrobus Nov 4, 2024
a9032d3
chore(keyboard-key): code cleanup
krisantrobus Nov 4, 2024
f0cb7ec
chore(keyboard-key): typedocs
krisantrobus Nov 4, 2024
5c3a833
chore(keyboard-key): fix tests
krisantrobus Nov 4, 2024
196a028
fix(keyboard-key): aria and diableBrowserShortcuts
krisantrobus Nov 5, 2024
1ff559c
fix(keyboard-key): props fix
krisantrobus Nov 5, 2024
59b0d43
chore(keyboard-key): playgorund storybook
krisantrobus Nov 5, 2024
a835ef0
chore(keyboard-key): formatting fix
krisantrobus Nov 5, 2024
528b13b
chore(keyboard-key): stories update
krisantrobus Nov 5, 2024
4fbce7b
chore(keyboard-key): formatting fix
krisantrobus Nov 5, 2024
c1714fb
chore(keyboard-key): typo
krisantrobus Nov 5, 2024
acdf2d0
Update .changeset/sweet-mugs-admire.md
krisantrobus Nov 6, 2024
e3d5827
Update .changeset/shaggy-sheep-confess.md
krisantrobus Nov 6, 2024
781d0b0
chore(keyboard-key): address PR comments
krisantrobus Nov 6, 2024
8ec377e
Merge branch 'create-keyboard-key' of github.com:twilio-labs/paste in…
krisantrobus Nov 6, 2024
5ade11a
feat(keyboard-tooltip): wip
krisantrobus Nov 6, 2024
774095c
chore(tooltip): update types
krisantrobus Nov 8, 2024
be97d29
chore(tooltip): update types
krisantrobus Nov 8, 2024
77b102e
Merge branch 'main' of github.com:twilio-labs/paste into add-keyboard…
krisantrobus Nov 14, 2024
4f693d2
chore(tooltip): better var naming
krisantrobus Nov 14, 2024
c5c4d62
chore(tooltip): fail safe check
krisantrobus Nov 14, 2024
c6fdc17
chore(tooltip): linting
krisantrobus Nov 14, 2024
7c9e275
chore(tooltip): linting
krisantrobus Nov 14, 2024
c5cab1e
chore(tooltip): yarn lock
krisantrobus Nov 14, 2024
4691ce4
chore(tooltip): changeset
krisantrobus Nov 14, 2024
f1bee12
chore(tooltip): fix spelling
krisantrobus Nov 14, 2024
278e997
chore(tooltip): uppdate type name
krisantrobus Nov 14, 2024
13afb9a
Merge branch 'add-keyboard-keys-to-tooltip' of github.com:twilio-labs…
krisantrobus Nov 15, 2024
031ba23
docs(keyboard-key): wip
krisantrobus Nov 15, 2024
345af0f
feat(tooltip): add anonymous keybaord action to tooltip
krisantrobus Nov 15, 2024
fe5d6b0
Merge branch 'add-keyboard-keys-to-tooltip' of github.com:twilio-labs…
krisantrobus Nov 15, 2024
b3bdaf0
fix(keyboard-key): ignore case sensitivty to overcome shift combo bug
krisantrobus Nov 15, 2024
57716c9
fix(keyboard-key): ignore case sensitivty to overcome shift combo bug
krisantrobus Nov 15, 2024
529aa0d
Update packages/paste-core/components/tooltip/src/Tooltip.tsx
krisantrobus Nov 18, 2024
30e7f4e
fix(tooltip): update keyboardkey styles
krisantrobus Nov 18, 2024
ec8bbd6
chore(tooltip): formatting
krisantrobus Nov 18, 2024
bd3f102
Merge branch 'add-keyboard-keys-to-tooltip' of github.com:twilio-labs…
krisantrobus Nov 18, 2024
58de99d
docs(keyboard-key): hook examples
krisantrobus Nov 18, 2024
3ab86ec
docs(keyboard-key): fix composition notes
krisantrobus Nov 18, 2024
6375ae7
docs(keyboard-key): fix docs search
krisantrobus Nov 18, 2024
11bc4b6
docs(keyboard-key): change example trigger
krisantrobus Nov 18, 2024
dd14333
docs(keyboard-key): fix build issue
krisantrobus Nov 18, 2024
086e623
docs(keyboard-key): yanlock
krisantrobus Nov 18, 2024
0d296ae
docs(keyboard-key): import fix
krisantrobus Nov 18, 2024
c9a5070
docs(keyboard-key): lint and format
krisantrobus Nov 18, 2024
c1fd89b
Merge branch 'main' of github.com:twilio-labs/paste into docs/keyboar…
krisantrobus Nov 19, 2024
1588670
docs(keyboard-key): changeset
krisantrobus Nov 19, 2024
dfceb27
Apply suggestions from code review
krisantrobus Nov 20, 2024
8d6b437
docs(keyboard-key): address PR comments
krisantrobus Nov 20, 2024
4e785bc
Merge branch 'docs/keyboard-key-init' of github.com:twilio-labs/paste…
krisantrobus Nov 20, 2024
546b70a
Apply suggestions from code review
krisantrobus Nov 20, 2024
e184f97
Merge branch 'docs/keyboard-key-init' of github.com:twilio-labs/paste…
krisantrobus Nov 20, 2024
63ce93d
docs(keyboard-key): address PR comments
krisantrobus Nov 20, 2024
69ff58a
docs(keyboard-key): remopve unused import
krisantrobus Nov 20, 2024
6bb47b8
docs(keyboard-key): address PR comments
krisantrobus Nov 20, 2024
4ef1aba
docs(keyboard-key): address PR comments
krisantrobus Nov 25, 2024
86e4fd0
docs(keyboard-key): address PR comments
krisantrobus Nov 26, 2024
4bed0a9
docs(keyboard-key): pressed stlying example
krisantrobus Nov 26, 2024
6030035
Merge branch 'main' into docs/keyboard-key-init
kodiakhq[bot] Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/slow-jokes-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/keyboard-key": patch
"@twilio-paste/core": patch
---

[KeyboardKey] fixed issue with shift key being captured as capitals on subsequesnt key presses
3 changes: 3 additions & 0 deletions cypress/integration/sitemap-vrt/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export const SITEMAP = [
"/components/input/",
"/components/input/api",
"/components/input/changelog",
"components/keyboard-key",
"components/keyboard-key/api",
"components/keyboard-key/changelog",
"/components/label/",
"/components/label/api",
"/components/label/changelog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
Expand All @@ -49,11 +49,11 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control", "d", "v"]);
expect(result.current?.activeKeys).toEqual(["control", "d", "v"]);
});

await act(async () => {
fireEvent.keyUp(window, { key: "Control" });
fireEvent.keyUp(window, { key: "control" });
fireEvent.keyUp(window, { key: "d" });
});

Expand All @@ -73,15 +73,15 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
fireEvent.keyDown(window, { key: "b" });
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b"]));
expect(onCombinationPress).toHaveBeenCalled();
});
});
Expand All @@ -97,15 +97,15 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
fireEvent.keyDown(window, { key: "d" });
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control", "d"]);
expect(result.current?.activeKeys).toEqual(["control", "d"]);
expect(onCombinationPress).not.toHaveBeenCalled();
});
});
Expand All @@ -121,7 +121,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
Expand All @@ -130,7 +130,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "v", "b"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "v", "b"]));
expect(onCombinationPress).not.toHaveBeenCalled();
});
});
Expand All @@ -148,15 +148,15 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
fireEvent.keyDown(window, { key: "b" });
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b"]));
expect(onCombinationPress).not.toHaveBeenCalled();
});
});
Expand All @@ -180,7 +180,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
Expand All @@ -189,7 +189,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control", "d", "v"]);
expect(result.current?.activeKeys).toEqual(["control", "d", "v"]);
});

await act(async () => {
Expand Down Expand Up @@ -222,15 +222,15 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
fireEvent.keyDown(window, { key: "b" });
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b"]));
expect(onCombinationPress1).toHaveBeenCalled();
expect(onCombinationPress2).not.toHaveBeenCalled();
});
Expand All @@ -241,7 +241,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b", "c"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b", "c"]));
expect(onCombinationPress1).not.toHaveBeenCalled();
expect(onCombinationPress2).not.toHaveBeenCalled();
});
Expand All @@ -251,7 +251,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "c"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "c"]));
expect(onCombinationPress1).not.toHaveBeenCalled();
expect(onCombinationPress2).toHaveBeenCalled();
});
Expand All @@ -277,15 +277,15 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(["Control"]);
expect(result.current?.activeKeys).toEqual(["control"]);
});

await act(async () => {
fireEvent.keyDown(window, { key: "b" });
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b"]));
expect(onCombinationPress1).toHaveBeenCalled();
expect(onCombinationPress2).not.toHaveBeenCalled();
});
Expand All @@ -296,7 +296,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "b", "c"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "b", "c"]));
expect(onCombinationPress1).not.toHaveBeenCalled();
expect(onCombinationPress2).not.toHaveBeenCalled();
});
Expand All @@ -306,7 +306,7 @@ describe("Hooks", () => {
});

await waitFor(() => {
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["Control", "c"]));
expect(result.current?.activeKeys).toEqual(expect.arrayContaining(["control", "c"]));
expect(onCombinationPress1).not.toHaveBeenCalled();
expect(onCombinationPress2).not.toHaveBeenCalled();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/components/keyboard-key/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"category": "typography",
"status": "production",
"description": "A keyboard key distinguishes a keyboard command or shortcut from other text.",
"description": "A Keyboard Key distinguishes a keyboard command or shortcut from other text.",
"author": "Twilio Inc.",
"license": "MIT",
"main:dev": "src/index.tsx",
Expand Down
7 changes: 4 additions & 3 deletions packages/paste-core/components/keyboard-key/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useKeyEvents = (): { activeKeys: string[] } => {
const handleKeyDown = (e: KeyboardEvent): void => {
if (!e.repeat) {
setActiveKeys((prev) => {
return Array.from(new Set([...prev, e.key]));
return Array.from(new Set([...prev, e.key.toLowerCase()]));
});
}
};
Expand All @@ -41,7 +41,7 @@ const useKeyEvents = (): { activeKeys: string[] } => {
if (e.key === "Meta") {
setActiveKeys([]);
} else {
setActiveKeys((prev) => [...prev].filter((k) => k !== e.key));
setActiveKeys((prev) => [...prev].filter((k) => k.toLowerCase() !== e.key.toLowerCase()));
}
};

Expand All @@ -59,7 +59,8 @@ const useKeyEvents = (): { activeKeys: string[] } => {
};

const stringArrayMatches = (arr1: string[], arr2: string[]): boolean =>
JSON.stringify(arr1.sort((a, b) => a.localeCompare(b))) === JSON.stringify(arr2.sort((a, b) => a.localeCompare(b)));
JSON.stringify(arr1.sort((a, b) => a.localeCompare(b)).map((s) => s.toLowerCase())) ===
JSON.stringify(arr2.sort((a, b) => a.localeCompare(b)));

export const useKeyCombination = ({
keys,
Expand Down
1 change: 1 addition & 0 deletions packages/paste-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@twilio-paste/inline-control-group": "^13.0.2",
"@twilio-paste/input": "^9.1.3",
"@twilio-paste/input-box": "^10.1.1",
"@twilio-paste/keyboard-key": "^0.0.0",
"@twilio-paste/label": "^13.1.1",
"@twilio-paste/lexical-library": "^4.2.0",
"@twilio-paste/list": "^8.2.1",
Expand Down
Loading
Loading