feat(design-system): port most of ui atoms to bazel monorepo and new storybook

This commit is contained in:
41666 2020-10-09 15:17:23 -04:00
parent a5e2fdc7a7
commit 72ea639c5d
108 changed files with 13650 additions and 53 deletions

View 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",
],
)

View 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]);
};

View file

@ -0,0 +1 @@
export * from './KeyEvents';