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 = "withContext",
deps = [
"react",
"@types/react",
],
)

View file

@ -0,0 +1,11 @@
import * as React from 'react';
export type ContextShimProps<T> = {
context: React.Context<T>;
children: (data: T) => any;
};
export function ContextShim<T>(props: ContextShimProps<T>) {
const context = React.useContext(props.context);
return <>{props.children(context)}</>;
}

View file

@ -0,0 +1,3 @@
export * from './withContext';
import * as testHelpers from './contextTestHelpers';
export { testHelpers };

View file

@ -0,0 +1,10 @@
import * as React from 'react';
export const withContext = <T, K extends T>(
Context: React.Context<T>,
Component: React.ComponentType<K>
): React.FunctionComponent<K> => (props) => (
<Context.Consumer>
{(context) => <Component {...props} {...context} />}
</Context.Consumer>
);