Skip to content

Commit c7b8b7f

Browse files
committed
update to storybook 6 (beta)
1 parent 888d069 commit c7b8b7f

File tree

4 files changed

+1338
-1294
lines changed

4 files changed

+1338
-1294
lines changed

.storybook/main.js

Lines changed: 6 additions & 33 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
});
@@ -15,40 +13,17 @@ const DEPENDENCY_REGEX = BUILD_FOR_IE11
1513

1614
module.exports = {
1715
stories: ['../docs/**/*.stories.mdx', '../packages/**/*.stories.mdx', '../packages/**/*.stories.[tj]sx'],
18-
addons: ['@storybook/addon-knobs', '@storybook/addon-docs', '@storybook/addon-actions'],
16+
addons: ['@storybook/addon-toolbars', '@storybook/addon-knobs', '@storybook/addon-docs', '@storybook/addon-actions'],
1917
webpack: async (config, { configType }) => {
2018
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
2119
// You can change the configuration based on that.
2220
// 'PRODUCTION' is used when building the static version of storybook.
2321

24-
const tsLoader = {
25-
test: /\.tsx?$/,
26-
include: PATHS.packages,
27-
use: [
28-
{
29-
loader: require.resolve('babel-loader'),
30-
options: {
31-
envName: 'esm',
32-
configFile: path.resolve(PATHS.root, 'babel.config.js')
33-
}
34-
}
35-
]
36-
};
37-
38-
if (IS_RELEASE_BUILD) {
39-
highlightLog('Warning: Prop Types Table Generation is active');
40-
tsLoader.use.push(require.resolve('react-docgen-typescript-loader'));
41-
} else {
42-
highlightLog('Info: Prop Types Table Generation is disabled');
43-
console.log(dedent`
44-
The Prop Table Generation is very expensive during build-time and therefore disabled by default.
45-
If you need Prop-Tables, you can activate it by adding a '.env' file to the root of the project with the following content:
46-
47-
UI5_WEBCOMPONENTS_FOR_REACT_RELEASE_BUILD=true\n\n
48-
`);
49-
}
50-
51-
config.module.rules.push(tsLoader);
22+
config.module.rules.push({
23+
test: /assets\/.*\.json$/,
24+
use: 'file-loader',
25+
type: 'javascript/auto'
26+
});
5227

5328
if ((IS_RELEASE_BUILD && configType === 'PRODUCTION') || BUILD_FOR_IE11) {
5429
config.module.rules.push({
@@ -96,8 +71,6 @@ module.exports = {
9671
}
9772
});
9873
}
99-
100-
config.resolve.extensions.push('.ts', '.tsx');
10174
config.resolve.alias = {
10275
...config.resolve.alias,
10376
'@shared': path.join(PATHS.root, 'shared'),

.storybook/preview.js

Lines changed: 75 additions & 7 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';
@@ -26,8 +25,6 @@ addParameters({
2625
}
2726
});
2827

29-
addDecorator(withKnobs);
30-
3128
const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
3229
useEffect(() => {
3330
if (contentDensity === ContentDensity.Compact) {
@@ -38,7 +35,7 @@ const ThemeContainer = ({ theme, contentDensity, children, direction }) => {
3835
}, [contentDensity]);
3936

4037
useEffect(() => {
41-
document.querySelector('html').setAttribute('dir', direction.toLowerCase());
38+
document.querySelector('html').setAttribute('dir', direction);
4239
}, [direction]);
4340

4441
useEffect(() => {
@@ -54,9 +51,9 @@ const withQuery = makeDecorator({
5451
wrapper: (getStory, context) => {
5552
return (
5653
<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')}
54+
theme={context.globalArgs.theme || Themes.sap_fiori_3}
55+
contentDensity={context.globalArgs.contentDensity}
56+
direction={context.globalArgs.direction}
6057
>
6158
{getStory(context)}
6259
</ThemeContainer>
@@ -65,3 +62,74 @@ const withQuery = makeDecorator({
6562
});
6663

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

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@
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-beta.12",
24+
"@storybook/addon-docs": "6.0.0-beta.12",
25+
"@storybook/addon-knobs": "6.0.0-beta.12",
26+
"@storybook/addon-toolbars": "6.0.0-beta.12",
27+
"@storybook/addons": "6.0.0-beta.12",
28+
"@storybook/cli": "6.0.0-beta.12",
29+
"@storybook/react": "6.0.0-beta.12",
30+
"@storybook/theming": "6.0.0-beta.12",
3131
"@ui5/webcomponents": "1.0.0-rc.7",
3232
"@ui5/webcomponents-fiori": "1.0.0-rc.7",
33-
"@ui5/webcomponents-icons": "1.0.0-rc.7",
34-
"react-docgen-typescript-loader": "3.7.2"
33+
"@ui5/webcomponents-icons": "1.0.0-rc.7"
3534
},
3635
"devDependencies": {
3736
"@babel/core": "^7.9.6",

0 commit comments

Comments
 (0)