-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new withFluentProvider decorator for converged Provider (#16869)
* feat: new withFluentProvider decorator for converged Provider * Change files * add missing deps * Update packages/storybook/src/decorators/withFluentProvider.tsx * Update packages/storybook/src/decorators/withFluentProvider.tsx
- Loading branch information
1 parent
b6e11cb
commit e6a1c49
Showing
6 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-theme-c1768520-8e1c-4d97-b64c-b2792d4ed903.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix mergeThemes() to avoid object's mutation", | ||
"packageName": "@fluentui/react-theme", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './withFluentProvider'; | ||
export * from './withKeytipLayer'; | ||
export * from './withStrictMode'; | ||
export * from './withCompatThemeProvider'; |
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,20 @@ | ||
import { makeDecorator } from '@storybook/addons'; | ||
import { FluentProvider } from '@fluentui/react-provider'; | ||
import * as React from 'react'; | ||
|
||
import { useFluentTheme } from '../knobs/useFluentTheme'; | ||
|
||
const ProviderWrapper: React.FunctionComponent = props => { | ||
const { theme } = useFluentTheme(); | ||
|
||
return <FluentProvider theme={theme}>{props.children}</FluentProvider>; | ||
}; | ||
|
||
export const withFluentProvider = makeDecorator({ | ||
name: 'withFluentProvider', | ||
parameterName: 'theme', | ||
skipIfNoParametersOrOptions: false, | ||
wrapper: (storyFn, context) => { | ||
return <ProviderWrapper>{storyFn(context)}</ProviderWrapper>; | ||
}, | ||
}); |
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,26 @@ | ||
import { | ||
webLightTheme, | ||
webDarkTheme, | ||
webHighContrastTheme, | ||
teamsLightTheme, | ||
teamsDarkTheme, | ||
teamsHighContrastTheme, | ||
Theme, | ||
} from '@fluentui/react-theme'; | ||
import { select } from '@storybook/addon-knobs'; | ||
|
||
const themeSelectorLabel = 'Theme'; | ||
|
||
const themeOptions = [ | ||
{ label: 'Web Light', theme: webLightTheme }, | ||
{ label: 'Web Dark', theme: webDarkTheme }, | ||
{ label: 'Web High Contrast', theme: webHighContrastTheme }, | ||
{ label: 'Teams Light', theme: teamsLightTheme }, | ||
{ label: 'Teams Dark', theme: teamsDarkTheme }, | ||
{ label: 'Teams High Contrast', theme: teamsHighContrastTheme }, | ||
]; | ||
|
||
export const useFluentTheme = (): { label: string; theme: Theme } => | ||
// Casting any here due to issue: https://github.com/storybookjs/storybook/issues/9751 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
select(themeSelectorLabel, themeOptions as any, themeOptions[0] as any); |