Skip to content

Commit 4984e4e

Browse files
TristanWatanabePeterDraex
authored andcommitted
Migrate storybook to 6.2.9 (microsoft#18693)
#### Pull request checklist - [x] Addresses an existing issue: Fixes microsoft#18142 - [x] Include a change request file using `$ yarn change` #### Description of changes
1 parent b909ae9 commit 4984e4e

19 files changed

+2327
-1261
lines changed

.storybook/main.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ module.exports = /** @type {Pick<StorybookConfig,'addons' |'stories' |'webpackFi
4343

4444
return config;
4545
},
46+
47+
core: {
48+
builder: 'webpack5',
49+
},
4650
});
4751

4852
/**
@@ -65,7 +69,7 @@ function overrideDefaultBabelLoader(rules) {
6569
}
6670

6771
const loaderIdx = rule.use.findIndex(loaderConfig => {
68-
return /** @type {LoaderObjectDef} */ (loaderConfig).loader === 'babel-loader';
72+
return /** @type {LoaderObjectDef} */ (loaderConfig).loader.includes('babel-loader');
6973
});
7074

7175
const loader = /** @type {LoaderObjectDef}*/ (rule.use[loaderIdx]);

apps/vr-tests/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"rules": {
55
"@typescript-eslint/no-explicit-any": "off",
66
"@typescript-eslint/jsx-no-bind": "off",
7-
"deprecation/deprecation": "off"
7+
"deprecation/deprecation": "off",
8+
"import/no-extraneous-dependencies": ["error", { "packageDir": [".", "../.."] }]
89
}
910
}

apps/vr-tests/.storybook/preview.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,7 @@ setAddon({
4343
},
4444
});
4545

46-
/**
47-
* @type {import('@storybook/react').Meta['decorators']}
48-
*/
49-
export const decorators = [removeCanvasInlineStyles];
50-
51-
/**
52-
* Temporary solution to remove inline styles injected by new default SB layout (https://storybook.js.org/docs/react/configure/story-layout)
53-
* TODO - remove this once we migrate to SB 6.1
54-
* @see https://github.com/storybookjs/storybook/issues/12041#issuecomment-717177177
55-
* @param {Parameters<import('@storybook/react').Meta['decorators'][number]>[0]} Story
56-
*/
57-
function removeCanvasInlineStyles(Story) {
58-
document.body.removeAttribute('style');
59-
return createElement(Story);
60-
}
46+
export const parameters = { layout: 'none' };
6147

6248
// For static storybook per https://github.com/screener-io/screener-storybook#testing-with-static-storybook-app
6349
if (typeof window === 'object') {

apps/vr-tests/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
"@fluentui/react-theme": "^9.0.0-alpha.17",
3737
"@fluentui/scripts": "^1.0.0",
3838
"@fluentui/storybook": "^1.0.0",
39-
"@storybook/addons": "6.0.28",
40-
"@storybook/channels": "6.0.28",
41-
"@storybook/react": "6.0.28",
4239
"@types/react": "16.9.42",
4340
"@types/react-dom": "16.9.10",
4441
"csstype": "^2.6.7",

apps/vr-tests/src/utilities/FabricDecorator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { DecoratorFunction } from '@storybook/addons';
3-
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
3+
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types';
44

55
export const FabricDecorator: DecoratorFunction<StoryFnReactReturnType> = story => (
66
<div style={{ display: 'flex' }}>

apps/vr-tests/src/utilities/FluentProviderDecorator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FluentProvider } from '@fluentui/react-provider';
22
import { webLightTheme } from '@fluentui/react-theme';
33
import { DecoratorFunction } from '@storybook/addons';
4-
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
4+
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types';
55
import * as React from 'react';
66

77
export const FluentProviderDecorator: DecoratorFunction<StoryFnReactReturnType> = story => (

apps/vr-tests/src/utilities/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface IStoryConfig {
88
rtl?: boolean;
99
}
1010

11-
declare module '@storybook/addons/dist/types' {
11+
declare module '@storybook/addons/dist/ts3.9/types' {
1212
// eslint-disable-next-line @typescript-eslint/naming-convention
1313
interface StoryApi<StoryFnReturnType = unknown> {
1414
/** adds a story, but via VR Tests' addon which auto adds variants like RTL */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: replace class with className in mdx file",
4+
"packageName": "@fluentui/react-examples",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "react-popver: fix Default story issue caused by storybook migration",
4+
"packageName": "@fluentui/react-popover",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"rename-package": "node -r ./scripts/ts-node-register ./scripts/rename-package.ts",
5353
"run:published": "node ./scripts/monorepo/runPublished.js",
5454
"runto:lerna": "node ./scripts/monorepo/runTo.js",
55-
"satisfied": "satisfied --skip-invalid --ignore \"sass|@testing-library|vue\"",
55+
"satisfied": "satisfied --skip-invalid --ignore \"angular|sass|svelte|@testing-library|vue\"",
5656
"scrub": "node ./scripts/scrub.js",
5757
"start": "node scripts/start.js",
5858
"start:legacy": "yarn workspace @fluentui/public-docsite-resources start",
@@ -84,16 +84,16 @@
8484
"@nrwl/node": "12.1.0",
8585
"@nrwl/tao": "12.1.0",
8686
"@nrwl/workspace": "12.1.0",
87-
"@storybook/addon-a11y": "6.0.28",
88-
"@storybook/addon-actions": "6.0.28",
89-
"@storybook/addon-docs": "6.0.28",
90-
"@storybook/addon-essentials": "6.0.28",
91-
"@storybook/addon-info": "6.0.0-alpha.2",
92-
"@storybook/addon-knobs": "6.0.28",
93-
"@storybook/addons": "6.0.28",
94-
"@storybook/channels": "6.0.28",
95-
"@storybook/core": "6.0.28",
96-
"@storybook/react": "6.0.28",
87+
"@storybook/addon-a11y": "6.2.9",
88+
"@storybook/addon-actions": "6.2.9",
89+
"@storybook/addon-docs": "6.2.9",
90+
"@storybook/addon-essentials": "6.2.9",
91+
"@storybook/addon-knobs": "6.2.9",
92+
"@storybook/addons": "6.2.9",
93+
"@storybook/channels": "6.2.9",
94+
"@storybook/core": "6.2.9",
95+
"@storybook/react": "6.2.9",
96+
"@storybook/builder-webpack5": "6.2.9",
9797
"@testing-library/jest-dom": "5.11.9",
9898
"@testing-library/react": "10.4.9",
9999
"@testing-library/react-hooks": "5.0.3",

packages/react-examples/.storybook/main.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ export default {
2525
loader: path.resolve(__dirname, 'preview-loader.js'),
2626
});
2727

28-
return customConfig;
28+
return {
29+
...customConfig,
30+
resolve: {
31+
...customConfig.resolve,
32+
// @ts-ignore
33+
fallback: {
34+
crypto: require.resolve('crypto-browserify'),
35+
stream: require.resolve('stream-browserify'),
36+
vm: require.resolve('vm-browserify'),
37+
},
38+
},
39+
};
40+
},
41+
42+
core: {
43+
builder: 'webpack5',
2944
},
3045
};

packages/react-examples/.storybook/preview.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react';
22
import { initializeIcons } from '@fluentui/font-icons-mdl2';
33
import { configure, addParameters, addDecorator } from '@storybook/react';
44
import 'cypress-storybook/react';
5-
import { withInfo } from '@storybook/addon-info';
65
import { withPerformance } from 'storybook-addon-performance';
76
import { withFluentProvider, withKeytipLayer, withStrictMode } from '@fluentui/storybook';
87

@@ -21,7 +20,6 @@ const storyOrder = [
2120
'Migrations/Flex/Overview',
2221
];
2322

24-
addDecorator(withInfo);
2523
addDecorator(withPerformance);
2624
addCustomDecorators();
2725

packages/react-examples/jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const config = createConfig({
55
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))],
66

77
snapshotSerializers: [resolveMergeStylesSerializer()],
8+
9+
moduleNameMapper: {
10+
'@storybook/addon-docs/blocks$': '@storybook/addon-docs/dist/cjs/blocks',
11+
},
812
});
913

1014
module.exports = config;

packages/react-examples/src/react-components/FluentUIComponents/Introduction.stories.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import './intro.css';
44

55
<Meta title="Concepts/Introduction" />
66

7-
<h1 class="fluent">Fluent UI React vNext</h1>
7+
<h1 className="fluent">Fluent UI React vNext</h1>
88

99
<img src="./fluentui-banner2.jpg" alt="Hello3" />
1010

1111
> **⚠ NOT PRODUCTION READY COMPONENTS - API SURFACES MAY CHANGE WITHOUT NOTICE**
1212
1313
---
1414

15-
<h2 class="fluent">Overview</h2>
16-
<div class="fluent-text">
15+
<h2 className="fluent">Overview</h2>
16+
<div className="fluent-text">
1717

1818
Fluent UI vNext is a set of UI components and utilities resulting from an effort to converge the set of React based component libraries in production today: `@fluentui/react` and `@fluentui/react-northstar`.
1919

@@ -27,6 +27,6 @@ Each component is designed adhere to following attributes:
2727

2828
</div>
2929

30-
<h2 class="fluent">Questions?</h2>
30+
<h2 className="fluent">Questions?</h2>
3131

3232
Reach out to the Fluent UI React team on [Github](https://github.com/microsoft/fluentui)

packages/react-popover/src/Popover.stories.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ export const Default = (props: PopoverProps) => (
3131
// @FIXME - remove manually specified argTypes once `react-components` package will use new storybook setup(DX)
3232
// https://github.com/microsoft/fluentui/issues/18514
3333
Default.argTypes = {
34-
open: {
35-
defaultValue: false,
36-
control: 'boolean',
37-
},
3834
openOnContext: {
3935
defaultValue: false,
4036
control: 'boolean',

packages/storybook/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"@fluentui/react-storybook": "^9.0.0-alpha.0",
2828
"@fluentui/react": "^8.23.7",
2929
"@fluentui/theme": "^2.1.4",
30-
"@storybook/addon-knobs": "6.0.28",
31-
"@storybook/addon-essentials": "6.0.28",
32-
"@storybook/addons": "6.0.28",
30+
"@storybook/addon-knobs": "6.2.9",
31+
"@storybook/addon-essentials": "6.2.9",
32+
"@storybook/addons": "6.2.9",
3333
"@fluentui/azure-themes": "^8.1.41",
3434
"@fluentui/theme-samples": "^8.1.41",
3535
"tslib": "^2.1.0"

scripts/storybook/webpack.config.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ module.exports = (/** @type {webpack.Configuration} */ config) => {
5959
},
6060
{
6161
test: /\.(gif|jpg|jpeg|png|svg)$/,
62-
loader: 'file-loader?name=[name].[ext]',
62+
loader: 'file-loader',
63+
options: {
64+
name: '[name].[ext]',
65+
},
6366
},
6467
{
6568
test: /\.(woff|woff2|ttf)$/,
66-
loader: 'file-loader?name=[name].[ext]',
69+
loader: 'file-loader',
70+
options: {
71+
name: '[name].[ext]',
72+
},
6773
},
6874
{
6975
test: /\.md$/,

scripts/tasks/storybook.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ function getCommonOptions(): StorybookCommonOptions {
4949
console.log(`node heap limit = ${require('v8').getHeapStatistics().heap_size_limit / (1024 * 1024)} MB`);
5050

5151
const localConfigDir = path.join(process.cwd(), '.storybook');
52+
const localStaticDir = path.join(process.cwd(), 'static');
5253

5354
return {
54-
staticDir: [path.join(process.cwd(), 'static')],
55+
staticDir: fs.existsSync(localStaticDir) ? [localStaticDir] : [],
5556
configDir: fs.existsSync(localConfigDir)
5657
? localConfigDir
5758
: path.join(findGitRoot(), 'packages/react-examples/.storybook'),

0 commit comments

Comments
 (0)