mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-07-05 01:46:59 +00:00
feat(design-system): port most of ui atoms to bazel monorepo and new storybook
This commit is contained in:
parent
a5e2fdc7a7
commit
72ea639c5d
108 changed files with 13650 additions and 53 deletions
11
src/design-system/atoms/key-events/BUILD.bazel
Normal file
11
src/design-system/atoms/key-events/BUILD.bazel
Normal file
|
@ -0,0 +1,11 @@
|
|||
load("//:hack/react.bzl", "react_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
react_library(
|
||||
name = "key-events",
|
||||
deps = [
|
||||
"react",
|
||||
"@types/react",
|
||||
],
|
||||
)
|
19
src/design-system/atoms/key-events/KeyEvents.ts
Normal file
19
src/design-system/atoms/key-events/KeyEvents.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
export const globalOnKeyUp = (
|
||||
key: string[],
|
||||
action: () => any,
|
||||
isActive: boolean = true
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const onKeyUp = (event: KeyboardEvent) => {
|
||||
if (isActive && key.includes(event.key)) {
|
||||
action();
|
||||
}
|
||||
};
|
||||
|
||||
document.body.addEventListener('keyup', onKeyUp);
|
||||
|
||||
return () => document.body.removeEventListener('keyup', onKeyUp);
|
||||
}, [key, action, isActive]);
|
||||
};
|
1
src/design-system/atoms/key-events/index.ts
Normal file
1
src/design-system/atoms/key-events/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './KeyEvents';
|
Loading…
Add table
Add a link
Reference in a new issue