Skip to content

Commit ab76553

Browse files
authored
chore: upgrade storybook to v8 (#35279)
1 parent 16a0c91 commit ab76553

File tree

325 files changed

+1804
-2593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+1804
-2593
lines changed

.storybook/docs-root.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
}
3737

3838
#storybook-docs .sbdocs-img.featured-image {
39-
max-width: 100%;
4039
margin: 48px 0;
4140
display: block;
41+
border-radius: 24px;
4242
}
4343

4444
#storybook-docs .sbdocs-img {
45-
border-radius: 24px;
45+
max-width: 100%;
4646
}
4747

4848
#storybook-docs .sbdocs hr:not(.sbdocs-preview hr) {

.storybook/main.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const fs = require('fs');
44
const {
55
loadWorkspaceAddon,
66
registerTsPaths,
7+
registerRules,
8+
rules,
79
processBabelLoaderOptions,
810
getImportMappingsForExportToSandboxAddon,
911
} = require('@fluentui/scripts-storybook');
@@ -15,17 +17,13 @@ const previewHeadTemplate = fs.readFileSync(path.resolve(__dirname, 'preview-hea
1517
module.exports = /** @type {import('./types').StorybookConfig} */ ({
1618
stories: [],
1719
addons: [
18-
// external custom addons
19-
2020
'@storybook/addon-essentials',
2121
'@storybook/addon-a11y',
2222
'@storybook/addon-links',
23-
'storybook-addon-performance',
2423
// https://storybook.js.org/docs/writing-docs/mdx#markdown-tables-arent-rendering-correctly
2524
'@storybook/addon-mdx-gfm',
2625

2726
// internal monorepo custom addons
28-
2927
/** {@link file://./../packages/react-components/react-storybook-addon/package.json} */
3028
loadWorkspaceAddon('@fluentui/react-storybook-addon', { tsConfigPath }),
3129
/** {@link file://./../packages/react-components/react-storybook-addon-export-to-sandbox/package.json} */
@@ -43,6 +41,7 @@ module.exports = /** @type {import('./types').StorybookConfig} */ ({
4341
}),
4442
],
4543
webpackFinal: config => {
44+
registerRules({ config, rules: [rules.swcRule] });
4645
registerTsPaths({ config, configFile: tsConfigPath });
4746

4847
if ((process.env.CI || process.env.TF_BUILD) && config.plugins) {
@@ -60,13 +59,9 @@ module.exports = /** @type {import('./types').StorybookConfig} */ ({
6059
options: {
6160
builder: {
6261
lazyCompilation: true,
63-
useSWC: true,
6462
},
6563
},
6664
},
67-
docs: {
68-
autodocs: true,
69-
},
7065
/**
7166
* Programmatically enhance previewHead as inheriting just static file `preview-head.html` doesn't work in monorepo
7267
* @see https://storybook.js.org/docs/addons/writing-presets#ui-configuration
@@ -76,28 +71,4 @@ module.exports = /** @type {import('./types').StorybookConfig} */ ({
7671
typescript: {
7772
reactDocgen: 'react-docgen-typescript',
7873
},
79-
80-
swc() {
81-
return {
82-
jsc: {
83-
target: 'es2019',
84-
parser: {
85-
syntax: 'typescript',
86-
tsx: true,
87-
decorators: true,
88-
dynamicImport: true,
89-
},
90-
transform: {
91-
decoratorMetadata: true,
92-
legacyDecorator: true,
93-
},
94-
keepClassNames: true,
95-
externalHelpers: true,
96-
loose: true,
97-
minify: {
98-
mangle: false,
99-
},
100-
},
101-
};
102-
},
10374
});

.storybook/types.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import type { StorybookConfig as StorybookBaseConfig } from '@storybook/react-webpack5';
22

3-
export type StorybookConfig = StorybookBaseConfig &
4-
Required<Pick<StorybookBaseConfig, 'stories' | 'addons' | 'webpackFinal'>>;
3+
export type StorybookConfig = Omit<StorybookBaseConfig, 'stories' | 'addons' | 'webpackFinal'> & {
4+
stories: NonNullable<Exclude<StorybookBaseConfig['stories'], Function>>;
5+
addons: NonNullable<Exclude<StorybookBaseConfig['addons'], Function>>;
6+
webpackFinal: NonNullable<StorybookBaseConfig['webpackFinal']>;
7+
};

apps/chart-docsite/.storybook/preview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ const preview: Preview & { parameters: import('@fluentui/react-storybook-addon')
1919
},
2020
};
2121

22+
export const tags = ['autodocs'];
23+
2224
export default preview;

apps/chart-docsite/.storybook/tsconfig.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,5 @@
1010
"../../../node_modules/@nx/react/typings/image.d.ts"
1111
],
1212
"exclude": ["../**/*.spec.ts", "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"],
13-
"include": [
14-
"../stories/**/*.stories.ts",
15-
"../stories/**/*.stories.js",
16-
"../stories/**/*.stories.jsx",
17-
"../stories/**/*.stories.tsx",
18-
"../stories/**/*.stories.mdx",
19-
"*.ts",
20-
"*.js"
21-
]
13+
"include": ["*.tsx", "*.ts", "*.jsx", "*.js"]
2214
}

apps/public-docsite-v9/.storybook/docs-root-v9.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* remove unnecessary padding now that theme switcher is not taking up space */
33
#storybook-docs .sbdocs-wrapper {
44
background: transparent !important;
5-
padding-top: 0;
5+
padding: 0 48px;
66
}
77

88
/* sb-show-main is missing during page transitions causing a page shift */
@@ -18,6 +18,7 @@
1818
.sb-preparing-story,
1919
.sb-preparing-docs,
2020
.sb-nopreview,
21-
.sb-errordisplay {
21+
.sb-errordisplay,
22+
.sidebar-container .search-field + div {
2223
display: none !important;
2324
}

apps/public-docsite-v9/.storybook/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript
99
...rootMain,
1010
stories: [
1111
...rootMain.stories,
12-
'../src/**/*.stories.mdx',
12+
'../src/**/*.mdx',
1313
'../src/**/index.stories.@(ts|tsx)',
1414
...getPackageStoriesGlob({ packageName: '@fluentui/react-components', callerPath: __dirname }),
1515
...getPackageStoriesGlob({
@@ -37,7 +37,7 @@ module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript
3737
previewUrl: process.env.DEPLOY_PATH,
3838
},
3939
webpackFinal: (config, options) => {
40-
const localConfig = /** @type config */ ({ ...rootMain.webpackFinal?.(config, options) });
40+
const localConfig = /** @type config */ ({ ...rootMain.webpackFinal(config, options) });
4141

4242
// add your own webpack tweaks if needed
4343
registerTsPaths({ configFile: tsConfigAllPath, config: localConfig });

apps/public-docsite-v9/.storybook/manager-head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
color: #11100f !important;
139139
}
140140

141+
.sidebar-item a {
142+
align-items: center !important;
143+
}
144+
141145
.sidebar-item[data-selected='true'] {
142146
font-weight: 600 !important;
143147
font-size: 14px !important;

apps/public-docsite-v9/.storybook/preview.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as rootPreview from '../../../.storybook/preview';
22

33
import './docs-root-v9.css';
44

5-
/** @type {NonNullable<import('@storybook/react').Story['decorators']>} */
5+
/** @type {NonNullable<import('@storybook/react').Decorator[]>} */
66
export const decorators = rootPreview.decorators;
77

88
/** @type {import("@fluentui/react-storybook-addon").FluentParameters & typeof rootPreview.parameters} */
@@ -56,3 +56,5 @@ export const parameters = {
5656
docs: true,
5757
},
5858
};
59+
60+
export const tags = ['autodocs'];

apps/public-docsite-v9/src/AccessibilityScenarios/ListOfScenarios.stories.mdx renamed to apps/public-docsite-v9/src/AccessibilityScenarios/ListOfScenarios.mdx

Lines changed: 3 additions & 3 deletions

0 commit comments

Comments
 (0)