mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 18:09:09 +00:00
chore: move src/common/utils to @roleypoly/misc-utils
This commit is contained in:
parent
a374030438
commit
65a8760e86
36 changed files with 38 additions and 465 deletions
19
packages/misc-utils/featureFlags/react/FeatureFlags.tsx
Normal file
19
packages/misc-utils/featureFlags/react/FeatureFlags.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as React from 'react';
|
||||
|
||||
export enum FeatureFlag {
|
||||
AllowListsBlockLists = 'AllowListsBlockLists',
|
||||
}
|
||||
|
||||
export class FeatureFlagProvider {
|
||||
activeFlags: FeatureFlag[] = [];
|
||||
|
||||
constructor(flags: FeatureFlag[] = []) {
|
||||
this.activeFlags = flags;
|
||||
}
|
||||
|
||||
has(flag: FeatureFlag) {
|
||||
return this.activeFlags.includes(flag);
|
||||
}
|
||||
}
|
||||
|
||||
export const FeatureFlagsContext = React.createContext(new FeatureFlagProvider());
|
1
packages/misc-utils/featureFlags/react/index.ts
Normal file
1
packages/misc-utils/featureFlags/react/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './FeatureFlags';
|
12
packages/misc-utils/featureFlags/react/storyDecorator.tsx
Normal file
12
packages/misc-utils/featureFlags/react/storyDecorator.tsx
Normal file
|
@ -0,0 +1,12 @@
|
|||
import * as React from 'react';
|
||||
import { FeatureFlag, FeatureFlagProvider, FeatureFlagsContext } from './FeatureFlags';
|
||||
|
||||
export const FeatureFlagDecorator = (flags: FeatureFlag[]) => (
|
||||
storyFn: () => React.ReactNode
|
||||
) => {
|
||||
return (
|
||||
<FeatureFlagsContext.Provider value={new FeatureFlagProvider(flags)}>
|
||||
{storyFn()}
|
||||
</FeatureFlagsContext.Provider>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue