mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +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/common/utils/withContext/BUILD.bazel
Normal file
11
src/common/utils/withContext/BUILD.bazel
Normal file
|
@ -0,0 +1,11 @@
|
|||
load("//:hack/react.bzl", "react_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
react_library(
|
||||
name = "withContext",
|
||||
deps = [
|
||||
"react",
|
||||
"@types/react",
|
||||
],
|
||||
)
|
11
src/common/utils/withContext/contextTestHelpers.tsx
Normal file
11
src/common/utils/withContext/contextTestHelpers.tsx
Normal 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)}</>;
|
||||
}
|
3
src/common/utils/withContext/index.ts
Normal file
3
src/common/utils/withContext/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export * from './withContext';
|
||||
import * as testHelpers from './contextTestHelpers';
|
||||
export { testHelpers };
|
10
src/common/utils/withContext/withContext.tsx
Normal file
10
src/common/utils/withContext/withContext.tsx
Normal 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>
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue