Skip to content

Commit

Permalink
revert(react-storybook-addon): Remove addon and reintroduce `withFlue…
Browse files Browse the repository at this point in the history
…ntProvider` (microsoft#20475)

* revert(react-storybook-addon): Remove addon and reintroduce
`withFluentProvider`

no build DX for storybook microsoft#18357. This PR reverts the register of that
addon and only applying this addon to react-components breaks theming
for all other packages

* Change files

* update md
  • Loading branch information
ling1726 authored and Marion Le Pontois committed Jan 17, 2022
1 parent 27f9b97 commit a38395f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { withStrictMode } from '@fluentui/react-storybook';
import { withFluentProvider, withStrictMode } from '@fluentui/react-storybook';
import 'cypress-storybook/react';
import * as dedent from 'dedent';

/** @type {NonNullable<import('@storybook/react').Story['decorators']>} */
export const decorators = [withStrictMode];
export const decorators = [withFluentProvider, withStrictMode];

/** @type {import('@storybook/react').Parameters} */
export const parameters = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "revert(react-storybook-addon): Remove addon and reintroduce `withFluentProvider`",
"packageName": "@fluentui/react-components",
"email": "[email protected]",
"dependentChangeType": "none"
}
2 changes: 1 addition & 1 deletion packages/react-components/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = /** @type {Pick<import('../../../.storybook/main').StorybookCon
'../src/**/*.stories.@(ts|tsx)',
...utils.getVnextStories(),
],
addons: [...rootMain.addons, '@fluentui/react-storybook-addon'],
addons: [...rootMain.addons],
webpackFinal: (config, options) => {
const localConfig = { ...rootMain.webpackFinal(config, options) };

Expand Down
1 change: 0 additions & 1 deletion packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/react-storybook-addon": "9.0.0-beta.0",
"@fluentui/scripts": "^1.0.0",
"@types/react": "16.9.42",
"@types/react-dom": "16.9.10",
Expand Down
3 changes: 3 additions & 0 deletions packages/react-storybook/etc/react-storybook.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import * as React_2 from 'react';

// @public (undocumented)
export const withFluentProvider: (...args: any) => any;

// @public (undocumented)
export const withStrictMode: (storyFn: () => React_2.ReactNode) => JSX.Element;

Expand Down
1 change: 1 addition & 0 deletions packages/react-storybook/src/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './withFluentProvider';
export * from './withStrictMode';
20 changes: 20 additions & 0 deletions packages/react-storybook/src/decorators/withFluentProvider.tsx
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>;
},
});
4 changes: 2 additions & 2 deletions packages/react-storybook/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { withStrictMode } from './index';
import { withFluentProvider, withStrictMode } from './index';

describe(`public api`, () => {
describe(`decorators`, () => {
it(`should work`, () => {
const decorators = [withStrictMode];
const decorators = [withFluentProvider, withStrictMode];

// @TODO - added proper tests
expect(decorators).toBeDefined();
Expand Down

0 comments on commit a38395f

Please sign in to comment.