Skip to content

Commit 63f641a

Browse files
chore: update to storybook 6 (#535)
1 parent 690b9e9 commit 63f641a

File tree

112 files changed

+4023
-3681
lines changed

Some content is hidden

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

112 files changed

+4023
-3681
lines changed

.storybook/main.js

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
const { highlightLog } = require('../scripts/utils');
21
const path = require('path');
32
const PATHS = require('../config/paths');
4-
const dedent = require('dedent');
53
require('dotenv').config({
64
path: path.join(PATHS.root, '.env')
75
});
@@ -14,8 +12,13 @@ const DEPENDENCY_REGEX = BUILD_FOR_IE11
1412
: /node_modules\/(@ui5\/webcomponents(-(base|core|fiori|icons|theme-base))?|lit-html)\//;
1513

1614
module.exports = {
17-
stories: ['../docs/**/*.stories.mdx', '../packages/**/*.stories.mdx', '../packages/**/*.stories.[tj]sx'],
18-
addons: ['@storybook/addon-knobs', '@storybook/addon-docs', '@storybook/addon-actions'],
15+
stories: ['../docs/**/*.stories.mdx', '../packages/**/*.stories.mdx', '../packages/**/*.stories.@(tsx|jsx)'],
16+
addons: [
17+
'@storybook/addon-toolbars',
18+
'@storybook/addon-docs',
19+
'@storybook/addon-controls',
20+
'@storybook/addon-actions'
21+
],
1922
webpack: async (config, { configType }) => {
2023
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
2124
// You can change the configuration based on that.
@@ -27,35 +30,6 @@ module.exports = {
2730
type: 'javascript/auto'
2831
});
2932

30-
const tsLoader = {
31-
test: /\.tsx?$/,
32-
include: PATHS.packages,
33-
use: [
34-
{
35-
loader: require.resolve('babel-loader'),
36-
options: {
37-
envName: 'esm',
38-
configFile: path.resolve(PATHS.root, 'babel.config.js')
39-
}
40-
}
41-
]
42-
};
43-
44-
if (IS_RELEASE_BUILD) {
45-
highlightLog('Warning: Prop Types Table Generation is active');
46-
tsLoader.use.push(require.resolve('react-docgen-typescript-loader'));
47-
} else {
48-
highlightLog('Info: Prop Types Table Generation is disabled');
49-
console.log(dedent`
50-
The Prop Table Generation is very expensive during build-time and therefore disabled by default.
51-
If you need Prop-Tables, you can activate it by adding a '.env' file to the root of the project with the following content:
52-
53-
UI5_WEBCOMPONENTS_FOR_REACT_RELEASE_BUILD=true\n\n
54-
`);
55-
}
56-
57-
config.module.rules.push(tsLoader);
58-
5933
if ((IS_RELEASE_BUILD && configType === 'PRODUCTION') || BUILD_FOR_IE11) {
6034
config.module.rules.push({
6135
test: /\.(js|mjs)$/,
@@ -102,8 +76,6 @@ module.exports = {
10276
}
10377
});
10478
}
105-
106-
config.resolve.extensions.push('.ts', '.tsx');
10779
config.resolve.alias = {
10880
...config.resolve.alias,
10981
'@shared': path.join(PATHS.root, 'shared'),

.storybook/manager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ addons.setConfig({
3838
* enable/disable shortcuts
3939
* @type {Boolean}
4040
*/
41-
enableShortcuts: false
41+
enableShortcuts: false,
42+
43+
showRoots: true
4244
});

.storybook/preview.js

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { select, withKnobs } from '@storybook/addon-knobs';
21
import { makeDecorator } from '@storybook/addons';
32
import { addDecorator, addParameters } from '@storybook/react';
43
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
@@ -21,13 +20,14 @@ addParameters({
2120
return a[1].kind === b[1].kind
2221
? 0
2322
: a[1].id.localeCompare(b[1].id, undefined, { numeric: true, caseFirst: 'upper' });
24-
},
25-
showRoots: true
26-
}
23+
}
24+
},
25+
passArgsFirst: true,
26+
viewMode: 'docs',
27+
docs: { forceExtractedArgTypes: true },
28+
actions: { argTypesRegex: '^on.*' }
2729
});
2830

29-
addDecorator(withKnobs);
30-
3131
const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
3232
useEffect(() => {
3333
if (contentDensity === ContentDensity.Compact) {
@@ -38,7 +38,7 @@ const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
3838
}, [contentDensity]);
3939

4040
// useEffect(() => {
41-
// document.querySelector('html').setAttribute('dir', direction.toLowerCase());
41+
// document.querySelector('html').setAttribute('dir', direction);
4242
// }, [direction]);
4343

4444
useEffect(() => {
@@ -54,9 +54,9 @@ const withQuery = makeDecorator({
5454
wrapper: (getStory, context) => {
5555
return (
5656
<ThemeContainer
57-
theme={select('Theme', Themes, Themes.sap_fiori_3)}
58-
contentDensity={select('ContentDensity', ContentDensity, ContentDensity.Cozy)}
59-
direction={select('Text Direction', ['LTR', 'RTL'], 'LTR')}
57+
theme={context.globals.theme || Themes.sap_fiori_3}
58+
contentDensity={context.globals.contentDensity}
59+
direction={context.globals.direction}
6060
>
6161
{getStory(context)}
6262
</ThemeContainer>
@@ -65,3 +65,74 @@ const withQuery = makeDecorator({
6565
});
6666

6767
addDecorator(withQuery);
68+
69+
export const globalArgTypes = {
70+
theme: {
71+
name: 'Theme',
72+
description: 'Fiori Theme',
73+
defaultValue: Themes.sap_fiori_3,
74+
toolbar: {
75+
icon: 'paintbrush',
76+
items: [
77+
{
78+
value: Themes.sap_fiori_3,
79+
title: Themes.sap_fiori_3
80+
},
81+
{
82+
value: Themes.sap_fiori_3_dark,
83+
title: Themes.sap_fiori_3_dark
84+
},
85+
{
86+
value: Themes.sap_belize,
87+
title: Themes.sap_belize
88+
},
89+
{
90+
value: Themes.sap_belize_hcb,
91+
title: Themes.sap_belize_hcb
92+
},
93+
{
94+
value: Themes.sap_belize_hcw,
95+
title: Themes.sap_belize_hcw
96+
}
97+
]
98+
}
99+
},
100+
contentDensity: {
101+
name: 'Content Density',
102+
description: 'Content Density',
103+
defaultValue: ContentDensity.Cozy,
104+
toolbar: {
105+
icon: 'component',
106+
items: [
107+
{
108+
value: ContentDensity.Cozy,
109+
title: ContentDensity.Cozy
110+
},
111+
{
112+
value: ContentDensity.Compact,
113+
title: ContentDensity.Compact
114+
}
115+
]
116+
}
117+
},
118+
direction: {
119+
name: 'Direction',
120+
description: 'Text Direction',
121+
defaultValue: 'ltr',
122+
toolbar: {
123+
icon: 'transfer',
124+
items: [
125+
{
126+
value: 'ltr',
127+
title: 'LTR',
128+
icon: 'arrowrightalt'
129+
},
130+
{
131+
value: 'rtl',
132+
title: 'RTL',
133+
icon: 'arrowleftalt'
134+
}
135+
]
136+
}
137+
}
138+
};

docs/welcome/Welcome.stories.mdx renamed to docs/1-Welcome.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
33
import { Button } from '@ui5/webcomponents-react/lib/Button';
44

5-
<Meta title="1 Welcome / Getting Started" />
5+
<Meta title="Getting Started" />
66

77
# UI5 Web Components for React
88
[![](https://github.com/SAP/ui5-webcomponents-react/workflows/build/badge.svg)](https://github.com/SAP/ui5-webcomponents-react/actions?query=workflow:%22build%22)

docs/MigrationGuide.stories.mdx renamed to docs/2-MigrationGuide.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
22

3-
<Meta title="1 Welcome / Migration Guide" />
3+
<Meta title="Migration Guide" />
44

55
# Migration Guide
66
<br />

docs/welcome/Styling.stories.mdx renamed to docs/3-Styling.stories.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
3-
import { MyCustomElement } from '../styling/MyCustomElement';
3+
import { MyCustomElement } from './styling/MyCustomElement';
44
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider';
55

6-
<Meta title="1 Welcome / Style Web Components" />
6+
<Meta title="Style Web Components" />
77

88
# How can I style my Web Components?
99
[Open Github Project](https://github.com/SAP/ui5-webcomponents-react)

docs/welcome/TestSetup.stories.mdx renamed to docs/4-TestSetup.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
33

4-
<Meta title="1 Welcome / Test Setup" />
4+
<Meta title="Test Setup" />
55

66
# Test Setup for UI5 Web Components for React
77

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
"lerna:version-dryrun": "lerna version --conventional-graduate --no-git-tag-version --no-push"
2121
},
2222
"dependencies": {
23-
"@storybook/addon-actions": "5.3.18",
24-
"@storybook/addon-docs": "5.3.18",
25-
"@storybook/addon-info": "5.3.18",
26-
"@storybook/addon-knobs": "5.3.18",
27-
"@storybook/addons": "5.3.18",
28-
"@storybook/cli": "5.3.18",
29-
"@storybook/react": "5.3.18",
30-
"@storybook/theming": "5.3.18",
23+
"@storybook/addon-actions": "6.0.0-rc.0",
24+
"@storybook/addon-controls": "6.0.0-rc.0",
25+
"@storybook/addon-docs": "6.0.0-rc.0",
26+
"@storybook/addon-knobs": "6.0.0-rc.0",
27+
"@storybook/addon-toolbars": "6.0.0-rc.0",
28+
"@storybook/addons": "6.0.0-rc.0",
29+
"@storybook/cli": "6.0.0-rc.0",
30+
"@storybook/react": "6.0.0-rc.0",
31+
"@storybook/theming": "6.0.0-rc.0",
3132
"@ui5/webcomponents": "1.0.0-rc.7",
3233
"@ui5/webcomponents-fiori": "1.0.0-rc.7",
3334
"@ui5/webcomponents-icons": "1.0.0-rc.7",
3435
"react": "16.8.0",
35-
"react-docgen-typescript-loader": "3.7.2",
3636
"react-dom": "16.8.0"
3737
},
3838
"devDependencies": {

0 commit comments

Comments
 (0)