chore: restructure project into yarn workspaces, remove next

This commit is contained in:
41666 2021-03-09 23:25:16 -05:00
parent 49e308507e
commit 8d06327c03
266 changed files with 16466 additions and 3350 deletions

View file

@ -0,0 +1,16 @@
import * as React from 'react';
import { FeatureFlagDecorator } from '../../../../src/common/utils/featureFlags/react/storyDecorator';
import { FeatureGate } from './FeatureGate';
export default {
title: 'Atoms/Feature Gate',
decorators: [FeatureFlagDecorator(['AllowListBlockList'])],
};
export const ActiveGate = () => (
<FeatureGate featureFlag="AllowListBlockList">{() => <div>hello!</div>}</FeatureGate>
);
export const InactiveGate = () => (
<FeatureGate featureFlag="aaa">{() => <div>hello!</div>}</FeatureGate>
);

View file

@ -0,0 +1,20 @@
import * as React from 'react';
import {
FeatureFlag,
FeatureFlagsContext,
} from '../../../../src/common/utils/featureFlags/react';
export type FeatureGateProps = {
featureFlag: FeatureFlag;
children: () => React.ReactNode;
};
export const FeatureGate = (props: FeatureGateProps) => {
const featureContext = React.useContext(FeatureFlagsContext);
if (featureContext.has(props.featureFlag)) {
return props.children();
} else {
return <></>;
}
};

View file

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