-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
andrew-cat
committed
Sep 19, 2024
1 parent
0b72912
commit 6e5f73e
Showing
13 changed files
with
2,394 additions
and
2,275 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { MultipleConfigCatConfigs } from './MultipleConfigCatConfigs'; | ||
|
||
export default { | ||
title: 'Showcase', | ||
component: MultipleConfigCatConfigs, | ||
parameters: { | ||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout | ||
layout: 'padded', | ||
}, | ||
} as ComponentMeta<typeof MultipleConfigCatConfigs>; | ||
|
||
const Template: ComponentStory<typeof MultipleConfigCatConfigs> = (args) => <MultipleConfigCatConfigs />; | ||
|
||
export const MultipleConfigcatConfigs = Template.bind({}); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { ConfigCatProvider, User, useFeatureFlagByConfigId, withConfigCatClient } from 'configcat-react'; | ||
import { HocComponent} from './Hoc'; | ||
|
||
|
||
const CC_CONFIGID = { BACKEND: "BACKEND", SHARED: "SHARED"}; | ||
|
||
const CC_SDK = { | ||
BACKEND: "TODO - INSERT BACKEND SDK KEY", | ||
SHARED:"TODO - INSERT SHARED SDK KEY"} | ||
|
||
const userObject = new User('microFrontendUser1'); | ||
|
||
export const C1 = (args: { featureFlagKey: string, configId: string }) => { | ||
|
||
const { value: isFeatureEnabled, loading } = useFeatureFlagByConfigId(args.configId, args.featureFlagKey, false, userObject); | ||
|
||
return ( | ||
<div> | ||
{loading ? | ||
(<div>Loading...</div>) : | ||
(<div> | ||
{args.featureFlagKey} evaluated to {isFeatureEnabled ? 'True' : 'False'} | ||
</div>)} | ||
</div> | ||
); | ||
}; | ||
|
||
const ConfigCatHocComponent = withConfigCatClient(HocComponent, CC_CONFIGID.BACKEND) | ||
|
||
export const MultipleConfigCatConfigs = () => { | ||
|
||
return ( | ||
<article> | ||
<h1>Embeded provider test</h1> | ||
|
||
<div> | ||
<ConfigCatProvider sdkKey={CC_SDK.SHARED} options={{pollIntervalSeconds:10}} configId={CC_CONFIGID.SHARED}> | ||
|
||
<C1 featureFlagKey={"sharedfeature1"} configId={CC_CONFIGID.SHARED}></C1> | ||
|
||
<ConfigCatProvider sdkKey={CC_SDK.BACKEND} options={{pollIntervalSeconds:10}} configId={CC_CONFIGID.BACKEND}> | ||
<C1 featureFlagKey={"isDebugModeOn"} configId={CC_CONFIGID.BACKEND}></C1> | ||
<C1 featureFlagKey={"sharedfeature1"} configId={CC_CONFIGID.SHARED}></C1> | ||
|
||
|
||
{/* Higher-Order Components sample */} | ||
<ConfigCatHocComponent featureFlagKey={"isDebugModeOn"} user={userObject}/> | ||
</ConfigCatProvider> | ||
|
||
</ConfigCatProvider> | ||
</div> | ||
|
||
</article> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.