Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate storybook to 6.2.9 #18693

Merged
merged 52 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
df00dc0
fix no static file found error on sb start
TristanWatanabe Jun 17, 2021
704f2e2
clean upgrade to 6.1.21
TristanWatanabe Jun 23, 2021
4e2898c
upgrade to 6.2.9
TristanWatanabe Jun 24, 2021
0501c6f
yarn lock file
TristanWatanabe Jun 24, 2021
8050fae
replace class with className in mdx file
TristanWatanabe Jun 24, 2021
fd72afd
Change files
TristanWatanabe Jun 24, 2021
528e246
Merge branch 'master' into migrate-storybook
TristanWatanabe Jun 24, 2021
0d1b1d9
run npx browserslist@latest --update-db
TristanWatanabe Jun 24, 2021
1990505
configure addon-postcss and add autoprefixer as dev dep
TristanWatanabe Jun 24, 2021
4764ee5
match autoprefixer versions
TristanWatanabe Jun 24, 2021
c550c17
update import paths
TristanWatanabe Jun 24, 2021
076a03b
add moduleNameMapper for storybook file
ecraig12345 Jun 24, 2021
b0d14fa
remove new style class injected in body by SB
TristanWatanabe Jun 25, 2021
060fd1a
remove temporary fix
TristanWatanabe Jun 25, 2021
8a652de
Merge branch 'master' into migrate-storybook
TristanWatanabe Jun 28, 2021
573bdc8
set fixed version of autoprefixer and remove from scripts package
TristanWatanabe Jun 28, 2021
0851937
deduplicate babel scope except for babel/core
TristanWatanabe Jun 30, 2021
0e2da26
run yarn after deduplication
TristanWatanabe Jun 30, 2021
74e02e3
Merge branch 'master' into migrate-storybook
TristanWatanabe Jun 30, 2021
05ad646
fix yarn lock file
TristanWatanabe Jul 1, 2021
b6f4d2e
deduplicate
TristanWatanabe Jul 1, 2021
968ee6d
update yarn lock after deduplication
TristanWatanabe Jul 1, 2021
28da3c1
Merge branch 'migrate-storybook' of https://github.com/TristanWatanab…
TristanWatanabe Jul 1, 2021
387d762
update yarn lock
TristanWatanabe Jul 1, 2021
c466480
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 1, 2021
b5b9a94
fix storybook startup issue for converged pkgs
TristanWatanabe Jul 1, 2021
26e055b
remove sb deps in vr-tests
TristanWatanabe Jul 1, 2021
148907d
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 15, 2021
1d9acb6
update yarn lock
TristanWatanabe Jul 15, 2021
63f3422
remove changes by linter
TristanWatanabe Jul 15, 2021
0e80abb
remove changes caused by linter
TristanWatanabe Jul 15, 2021
83ac9ed
update storybook package deps to 6.2.9
TristanWatanabe Jul 15, 2021
8802131
add webpack5 support, autoprefixer 10, and update overrideDefaultBabe…
TristanWatanabe Jul 15, 2021
7814d32
update webpack config file-loader
TristanWatanabe Jul 15, 2021
b337471
add crypto and stream polyfills to react-examples SB webpack config
TristanWatanabe Jul 15, 2021
bb17948
remove addon-info
TristanWatanabe Jul 15, 2021
677a750
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 15, 2021
4fbc960
add vr polyfill to react-examples SB webpack config
TristanWatanabe Jul 15, 2021
14f7a08
add rule to eslintrc file
TristanWatanabe Jul 15, 2021
5551645
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 16, 2021
a9cf49c
remove open argType from react-popover Default story
TristanWatanabe Jul 16, 2021
50d4cbf
Change files
TristanWatanabe Jul 16, 2021
0a03584
remove sb builder webpack5 from satisfied ignore list
TristanWatanabe Jul 16, 2021
8797c07
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 19, 2021
2ebdab9
remove postcss addon
TristanWatanabe Jul 20, 2021
37bf1be
update vrtests eslintrc
TristanWatanabe Jul 20, 2021
38e74b5
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 20, 2021
43ed940
update yarn lock file
TristanWatanabe Jul 20, 2021
d93c6ea
cleanup
TristanWatanabe Jul 21, 2021
6c7d61c
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 21, 2021
7b9c974
remove changes made by linter
TristanWatanabe Jul 21, 2021
640c4d3
Merge branch 'master' into migrate-storybook
TristanWatanabe Jul 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ module.exports = /** @type {Pick<StorybookConfig,'addons' |'stories' |'webpackFi

return config;
},

core: {
builder: 'webpack5',
},
});

/**
Expand All @@ -65,7 +69,7 @@ function overrideDefaultBabelLoader(rules) {
}

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

const loader = /** @type {LoaderObjectDef}*/ (rule.use[loaderIdx]);
Expand Down
3 changes: 2 additions & 1 deletion apps/vr-tests/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/jsx-no-bind": "off",
"deprecation/deprecation": "off"
"deprecation/deprecation": "off",
"import/no-extraneous-dependencies": ["error", { "packageDir": [".", "../.."] }]
}
}
16 changes: 1 addition & 15 deletions apps/vr-tests/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,7 @@ setAddon({
},
});

/**
* @type {import('@storybook/react').Meta['decorators']}
*/
export const decorators = [removeCanvasInlineStyles];

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

// For static storybook per https://github.com/screener-io/screener-storybook#testing-with-static-storybook-app
if (typeof window === 'object') {
Expand Down
3 changes: 0 additions & 3 deletions apps/vr-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
"@fluentui/react-theme": "^9.0.0-alpha.17",
"@fluentui/scripts": "^1.0.0",
"@fluentui/storybook": "^1.0.0",
"@storybook/addons": "6.0.28",
"@storybook/channels": "6.0.28",
"@storybook/react": "6.0.28",
"@types/react": "16.9.42",
"@types/react-dom": "16.9.10",
"csstype": "^2.6.7",
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests/src/utilities/FabricDecorator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { DecoratorFunction } from '@storybook/addons';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types';

export const FabricDecorator: DecoratorFunction<StoryFnReactReturnType> = story => (
<div style={{ display: 'flex' }}>
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests/src/utilities/FluentProviderDecorator.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FluentProvider } from '@fluentui/react-provider';
import { webLightTheme } from '@fluentui/react-theme';
import { DecoratorFunction } from '@storybook/addons';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types';
import * as React from 'react';

export const FluentProviderDecorator: DecoratorFunction<StoryFnReactReturnType> = story => (
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests/src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface IStoryConfig {
rtl?: boolean;
}

declare module '@storybook/addons/dist/types' {
declare module '@storybook/addons/dist/ts3.9/types' {
Hotell marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-next-line @typescript-eslint/naming-convention
interface StoryApi<StoryFnReturnType = unknown> {
/** adds a story, but via VR Tests' addon which auto adds variants like RTL */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: replace class with className in mdx file",
"packageName": "@fluentui/react-examples",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "react-popver: fix Default story issue caused by storybook migration",
"packageName": "@fluentui/react-popover",
"email": "[email protected]",
"dependentChangeType": "patch"
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"rename-package": "node -r ./scripts/ts-node-register ./scripts/rename-package.ts",
"run:published": "node ./scripts/monorepo/runPublished.js",
"runto:lerna": "node ./scripts/monorepo/runTo.js",
"satisfied": "satisfied --skip-invalid --ignore \"sass|@testing-library|vue\"",
"satisfied": "satisfied --skip-invalid --ignore \"angular|sass|svelte|@testing-library|vue\"",
"scrub": "node ./scripts/scrub.js",
"start": "node scripts/start.js",
"start:legacy": "yarn workspace @fluentui/public-docsite-resources start",
Expand Down Expand Up @@ -84,16 +84,16 @@
"@nrwl/node": "12.1.0",
"@nrwl/tao": "12.1.0",
"@nrwl/workspace": "12.1.0",
"@storybook/addon-a11y": "6.0.28",
"@storybook/addon-actions": "6.0.28",
"@storybook/addon-docs": "6.0.28",
"@storybook/addon-essentials": "6.0.28",
"@storybook/addon-info": "6.0.0-alpha.2",
"@storybook/addon-knobs": "6.0.28",
"@storybook/addons": "6.0.28",
"@storybook/channels": "6.0.28",
"@storybook/core": "6.0.28",
"@storybook/react": "6.0.28",
"@storybook/addon-a11y": "6.2.9",
"@storybook/addon-actions": "6.2.9",
"@storybook/addon-docs": "6.2.9",
"@storybook/addon-essentials": "6.2.9",
"@storybook/addon-knobs": "6.2.9",
"@storybook/addons": "6.2.9",
"@storybook/channels": "6.2.9",
"@storybook/core": "6.2.9",
"@storybook/react": "6.2.9",
"@storybook/builder-webpack5": "6.2.9",
"@testing-library/jest-dom": "5.11.9",
"@testing-library/react": "10.4.9",
"@testing-library/react-hooks": "5.0.3",
Expand Down
17 changes: 16 additions & 1 deletion packages/react-examples/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ export default {
loader: path.resolve(__dirname, 'preview-loader.js'),
});

return customConfig;
return {
...customConfig,
resolve: {
...customConfig.resolve,
// @ts-ignore
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
},
},
};
},

core: {
builder: 'webpack5',
},
};
2 changes: 0 additions & 2 deletions packages/react-examples/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { initializeIcons } from '@fluentui/font-icons-mdl2';
import { configure, addParameters, addDecorator } from '@storybook/react';
import 'cypress-storybook/react';
import { withInfo } from '@storybook/addon-info';
import { withPerformance } from 'storybook-addon-performance';
import { withFluentProvider, withKeytipLayer, withStrictMode } from '@fluentui/storybook';

Expand All @@ -21,7 +20,6 @@ const storyOrder = [
'Migrations/Flex/Overview',
];

addDecorator(withInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withInfo was replaced by some addon ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now, i haven't added anything to replace it yet. Since addon-info is deprecated, it was not playing nice with the new storybook webpack5 builder so Elizabeth and I decided to remove it for now (see here)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, vNext uses storybook Docs anyways with typescript doc generation

Copy link
Contributor

@Hotell Hotell Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with that we can also remove our manual typings (can be done in separate PR)
2021-07-20 at 19 24

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a separate issue for this!

addDecorator(withPerformance);
addCustomDecorators();

Expand Down
4 changes: 4 additions & 0 deletions packages/react-examples/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const config = createConfig({
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))],

snapshotSerializers: [resolveMergeStylesSerializer()],

moduleNameMapper: {
'@storybook/addon-docs/blocks$': '@storybook/addon-docs/dist/cjs/blocks',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: is this a know limitation (to explicitly provide CJS storybooks output) ? I mean we don't run tests on stories do we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the limitation but this is a known issue (see here) that's supposed to have been fixed in 6.3.x. Tests were written for the utils.tsx file in react-examples/react-components/Migrations (see file here) which caused the initial failure.

},
});

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import './intro.css';

<Meta title="Concepts/Introduction" />

<h1 class="fluent">Fluent UI React vNext</h1>
<h1 className="fluent">Fluent UI React vNext</h1>
Hotell marked this conversation as resolved.
Show resolved Hide resolved

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

> **⚠ NOT PRODUCTION READY COMPONENTS - API SURFACES MAY CHANGE WITHOUT NOTICE**

---

<h2 class="fluent">Overview</h2>
<div class="fluent-text">
<h2 className="fluent">Overview</h2>
<div className="fluent-text">

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`.

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

</div>

<h2 class="fluent">Questions?</h2>
<h2 className="fluent">Questions?</h2>

Reach out to the Fluent UI React team on [Github](https://github.com/microsoft/fluentui)
4 changes: 0 additions & 4 deletions packages/react-popover/src/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export const Default = (props: PopoverProps) => (
// @FIXME - remove manually specified argTypes once `react-components` package will use new storybook setup(DX)
// https://github.com/microsoft/fluentui/issues/18514
Default.argTypes = {
open: {
defaultValue: false,
control: 'boolean',
},
openOnContext: {
defaultValue: false,
control: 'boolean',
Expand Down
6 changes: 3 additions & 3 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"@fluentui/react-storybook": "^9.0.0-alpha.0",
"@fluentui/react": "^8.23.7",
"@fluentui/theme": "^2.1.4",
"@storybook/addon-knobs": "6.0.28",
"@storybook/addon-essentials": "6.0.28",
"@storybook/addons": "6.0.28",
"@storybook/addon-knobs": "6.2.9",
"@storybook/addon-essentials": "6.2.9",
"@storybook/addons": "6.2.9",
"@fluentui/azure-themes": "^8.1.41",
"@fluentui/theme-samples": "^8.1.41",
"tslib": "^2.1.0"
Expand Down
10 changes: 8 additions & 2 deletions scripts/storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ module.exports = (/** @type {webpack.Configuration} */ config) => {
},
{
test: /\.(gif|jpg|jpeg|png|svg)$/,
loader: 'file-loader?name=[name].[ext]',
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
{
test: /\.(woff|woff2|ttf)$/,
loader: 'file-loader?name=[name].[ext]',
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
{
test: /\.md$/,
Expand Down
3 changes: 2 additions & 1 deletion scripts/tasks/storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ function getCommonOptions(): StorybookCommonOptions {
console.log(`node heap limit = ${require('v8').getHeapStatistics().heap_size_limit / (1024 * 1024)} MB`);

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

return {
staticDir: [path.join(process.cwd(), 'static')],
staticDir: fs.existsSync(localStaticDir) ? [localStaticDir] : [],
Hotell marked this conversation as resolved.
Show resolved Hide resolved
configDir: fs.existsSync(localConfigDir)
? localConfigDir
: path.join(findGitRoot(), 'packages/react-examples/.storybook'),
Expand Down
Loading