Skip to content

Commit 73e866b

Browse files
committed
Upgrade storybook
1 parent 71e4b30 commit 73e866b

File tree

7 files changed

+827
-90
lines changed

7 files changed

+827
-90
lines changed

Diff for: .storybook/main.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
module.exports = {
2+
stories: ['../src/__stories__/*.stories.js'],
23
core: {
3-
builder: 'webpack5',
4+
disableTelemetry: true, // Disables telemetry
5+
},
6+
framework: {
7+
name: '@storybook/react-webpack5',
8+
options: {},
9+
},
10+
docs: {
11+
autodocs: false,
412
},
5-
stories: ['../src/__stories__/index.js'],
613
};

Diff for: .storybook/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22

3-
module.exports = async ({config, mode}) => {
3+
module.exports = async ({config}) => {
44
config.module.rules.push({
55
test: /\.scss$/,
66
use: ['style-loader', 'css-loader', 'sass-loader'],

Diff for: dev/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import dataSources from './dataSources';
1111
// https://github.com/plotly/react-chart-editor#mapbox-access-tokens
1212
import ACCESS_TOKENS from '../accessTokens';
1313

14-
// import {customConfigTest} from '../src/__stories__';
14+
// import {customConfigTest} from './customConfigTest';
1515

1616
const dataSourceOptions = Object.keys(dataSources).map((name) => ({
1717
value: name,
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
import {TestEditor, setupGraphDiv, fixtures} from 'lib/test-utils';
2-
import plotly from 'plotly.js/dist/plotly';
3-
4-
import {PanelMenuWrapper} from '../components';
5-
6-
import * as mocks from '../../dev/percy';
7-
import * as panels from '../default_panels/';
8-
9-
import '../../dev/styles.css';
10-
import '../styles/main.scss';
11-
import './stories.css';
12-
13-
import React from 'react';
14-
import {storiesOf} from '@storybook/react';
151
export const customConfigTest = {
162
visibility_rules: {
173
blacklist: [
@@ -78,68 +64,3 @@ export const customConfigTest = {
7864
],
7965
},
8066
};
81-
82-
/**
83-
* To add more Percy tests - add a mock file to /dev/percy, add it to /dev/percy/index.js
84-
* To specify which panels to test with the mock, add entry to panelsToTest, else all panels will be tested
85-
*/
86-
const panelsToTest = {
87-
bar: ['GraphCreatePanel', 'StyleTracesPanel'],
88-
box: ['GraphCreatePanel', 'StyleTracesPanel'],
89-
pie: ['GraphCreatePanel', 'StyleTracesPanel'],
90-
histogram: ['GraphCreatePanel', 'StyleTracesPanel'],
91-
histogram2d: ['GraphCreatePanel', 'StyleTracesPanel'],
92-
violin: ['GraphCreatePanel', 'StyleTracesPanel'],
93-
waterfall: ['GraphCreatePanel', 'StyleTracesPanel'],
94-
sunburst: ['GraphCreatePanel', 'StyleTracesPanel'],
95-
sankey: ['GraphCreatePanel', 'StyleTracesPanel'],
96-
geoTest: ['GraphCreatePanel', 'StyleMapsPanel', 'StyleTracesPanel'],
97-
funnel: ['GraphCreatePanel', 'StyleTracesPanel'],
98-
funnelarea: ['GraphCreatePanel', 'StyleTracesPanel'],
99-
};
100-
101-
window.URL.createObjectURL = function () {
102-
return null;
103-
};
104-
105-
const panelFixture = (Panel, group, name, figure, customConfig) => {
106-
const gd = setupGraphDiv(figure, plotly);
107-
gd._context = plotly.setPlotConfig();
108-
gd._context.setBackground = () => {
109-
return null;
110-
};
111-
112-
return (
113-
<div className="plotly_editor">
114-
<TestEditor
115-
plotly={plotly}
116-
graphDiv={gd}
117-
dataSources={fixtures.scatter().dataSources}
118-
dataSourceOptions={fixtures.scatter().dataSourceOptions}
119-
customConfig={customConfig || {}}
120-
>
121-
<PanelMenuWrapper>
122-
<Panel group={group} name={name} />
123-
</PanelMenuWrapper>
124-
</TestEditor>
125-
</div>
126-
);
127-
};
128-
129-
let stories = storiesOf('Panels', module);
130-
131-
Object.keys(mocks).forEach((m) => {
132-
const selectedPanels = panelsToTest[m] ? panelsToTest[m] : Object.keys(panels);
133-
134-
selectedPanels.forEach((p) => {
135-
const words = p.split(/(?=[A-Z])/);
136-
const panelGroup = words[0];
137-
const panelName = words.slice(1, -1).join(' ');
138-
139-
stories = stories
140-
.add(`${m}_${p}`, () => panelFixture(panels[p], panelGroup, panelName, mocks[m]))
141-
.add(`${m}_${p}_withCustomConfig`, () =>
142-
panelFixture(panels[p], panelGroup, panelName, mocks[m], customConfigTest)
143-
);
144-
});
145-
});

Diff for: package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
"build": "BABEL_ENV=production rimraf lib && mkdir lib && npm run build:js && npm run build:css && npm run build:combined-translation-keys",
1717
"watch": "webpack serve --hot --mode development",
1818
"prepublishOnly": "npm run build",
19-
"storybook": "start-storybook -p 9001 -c .storybook",
19+
"storybook": "storybook dev -p 9001 -c .storybook",
2020
"test": "npm run test:lint && npm run test:pretty && npm run test:js",
2121
"test:js": "jest --setupTestFrameworkScriptFile=raf/polyfill --maxWorkers=2",
2222
"test:lint": "eslint \"src/**/*.js\" \"dev/**/*.js\" \"examples/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
2323
"test:pretty": "prettier -l \"src/**/*.{js,scss}\" \"dev/**/*.{js,scss}\" \"examples/**/*.{js,scss}\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
24-
"test:percy": "node --max-old-space-size=4096 $(npm bin)/build-storybook && percy storybook ./storybook-static",
25-
"test:percy-local": "node --max-old-space-size=4096 $(npm bin)/build-storybook",
24+
"test:percy": "storybook build && percy storybook ./storybook-static",
25+
"test:percy-local": "storybook build",
2626
"test:watch": "jest --watch"
2727
},
2828
"dependencies": {
@@ -60,9 +60,10 @@
6060
"@hot-loader/react-dom": "16.14.0",
6161
"@percy/cli": "1.27.1",
6262
"@percy/storybook": "4.3.6",
63-
"@storybook/builder-webpack5": "^6.5.14",
64-
"@storybook/manager-webpack5": "^6.5.14",
65-
"@storybook/react": "6.5.16",
63+
"@storybook/blocks": "7.4.1",
64+
"@storybook/react": "7.4.1",
65+
"@storybook/react-webpack5": "7.4.1",
66+
"@storybook/source-loader": "^7.4.1",
6667
"autoprefixer": "10.4.15",
6768
"babel-jest": "26.6.3",
6869
"babel-loader": "9.1.3",
@@ -99,6 +100,7 @@
99100
"rimraf": "5.0.1",
100101
"sass": "1.66.1",
101102
"sass-loader": "13.3.2",
103+
"storybook": "7.4.1",
102104
"style-loader": "3.3.3",
103105
"webpack": "5.88.2",
104106
"webpack-cli": "5.1.4",
@@ -109,6 +111,9 @@
109111
"react": ">=16.14.0",
110112
"react-dom": ">=16.14.0"
111113
},
114+
"resolutions": {
115+
"jackspeak": "2.1.1"
116+
},
112117
"engines": {
113118
"node": ">=12.13.0"
114119
},

0 commit comments

Comments
 (0)