Update storybook and fix changes

This commit is contained in:
nndio 2019-01-09 01:08:34 +02:00
parent b2adfb1238
commit e2f9bf52b5
19 changed files with 59 additions and 103 deletions

View File

@ -1,23 +1,23 @@
import { configure, setAddon, addDecorator } from '@storybook/react'; import { configure, setAddon, addDecorator } from '@storybook/react';
import { setOptions } from '@storybook/addon-options'; import { withOptions } from '@storybook/addon-options';
import infoAddon from '@storybook/addon-info'; import { withInfo } from '@storybook/addon-info';
import { withKnobs } from '@storybook/addon-knobs'; import { withKnobs } from '@storybook/addon-knobs';
import { withTheme } from './themeAddon/theme'; import { withTheme } from './themeAddon/theme';
import '../src/presets.js'; import '../src/presets.js';
setAddon(infoAddon); addDecorator(withOptions({
setOptions({
name: 'DevUI', name: 'DevUI',
url: 'https://github.com/reduxjs/redux-devtools/tree/master/packages/devui', url: 'https://github.com/reduxjs/redux-devtools/tree/master/packages/devui',
goFullScreen: false, goFullScreen: false,
showLeftPanel: true, showStoriesPanel: true,
showDownPanel: true, showAddonPanel: true,
showSearchBox: false, showSearchBox: false,
downPanelInRight: true addonPanelInRight: true
}); }));
addDecorator(withTheme); addDecorator(withTheme);
addDecorator(withKnobs); addDecorator(withKnobs);
addDecorator(withInfo);
const req = require.context('../src/', true, /stories\/index\.js$/); const req = require.context('../src/', true, /stories\/index\.js$/);

View File

@ -14,7 +14,7 @@
font-family: "Helvetica Neue", "Lucida Grande", sans-serif; font-family: "Helvetica Neue", "Lucida Grande", sans-serif;
font-size: 11px; font-size: 11px;
} }
#root, #root > div, #root > div > div { #root, #root > div {
height: 100%; height: 100%;
} }
#root > div > div { #root > div > div {
@ -22,5 +22,6 @@
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow-y: auto;
} }
</style> </style>

View File

@ -25,6 +25,8 @@ export default class Panel extends React.Component {
this.setState(state); this.setState(state);
}; };
onClick = () => {};
render() { render() {
const { theme, scheme, light } = this.state; const { theme, scheme, light } = this.state;
return ( return (
@ -50,6 +52,7 @@ export default class Panel extends React.Component {
} }
]} ]}
onFieldChange={this.onChange} onFieldChange={this.onChange}
onFieldClick={this.onClick}
/> />
</FormWrapper> </FormWrapper>
); );

View File

@ -7,6 +7,10 @@ addons.register(ADDON_ID, api => {
const channel = addons.getChannel(); const channel = addons.getChannel();
addons.addPanel(PANEL_ID, { addons.addPanel(PANEL_ID, {
title: 'Theme', title: 'Theme',
render: () => <Panel channel={channel} api={api} /> render: ({ active }) => (
active ?
<Panel channel={channel} api={api} />
: null
)
}); });
}); });

View File

@ -1,22 +1,8 @@
import React from 'react'; import React from 'react';
import addons from '@storybook/addons'; import addons from '@storybook/addons';
import styled from 'styled-components';
import { EVENT_ID_DATA, DEFAULT_THEME_STATE } from './constant'; import { EVENT_ID_DATA, DEFAULT_THEME_STATE } from './constant';
import { Container } from '../../src'; import { Container } from '../../src';
const ContainerStyled = styled(Container)`
> div {
height: 100%;
width: 100%;
> div {
height: 100%;
width: 100%;
overflow-y: auto;
}
}
`;
const channel = addons.getChannel(); const channel = addons.getChannel();
class Theme extends React.Component { class Theme extends React.Component {
@ -35,7 +21,7 @@ class Theme extends React.Component {
}; };
render() { render() {
return <ContainerStyled themeData={this.state}>{this.props.children}</ContainerStyled>; return <Container themeData={this.state}>{this.props.children}</Container>;
} }
} }

View File

@ -1,4 +0,0 @@
module.exports = function (config) {
// This is the default webpack config defined in the `../webpack.config.js`
// modify as you need.
};

View File

@ -1,26 +1,8 @@
const path = require('path'); const path = require('path');
const updateConfig = require('./user/modify_webpack_config');
const config = { module.exports = (baseConfig, env, defaultConfig) => {
module: { // Add custom webpack config here like:
rules: [ // defaultConfig.module.rules.push
{
test: /\.css?$/, return defaultConfig;
use: [{ loader: 'style-loader' }, { loader: 'raw-loader' }],
include: path.resolve(__dirname, '../')
},
{
test: /\.json?$/,
loader: 'json-loader',
include: path.resolve(__dirname, '../')
},
{
test: /\.woff2?(\?\S*)?$/,
loader: 'url?limit=65000&mimetype=application/font-woff'
}
]
}
}; };
updateConfig(config);
module.exports = config;

View File

@ -30,11 +30,11 @@
}, },
"homepage": "https://github.com/reduxjs/redux-devtools", "homepage": "https://github.com/reduxjs/redux-devtools",
"devDependencies": { "devDependencies": {
"@storybook/addon-actions": "^3.2.13", "@storybook/addon-actions": "^4.1.4",
"@storybook/addon-info": "^3.2.13", "@storybook/addon-info": "^4.1.4",
"@storybook/addon-knobs": "^3.2.13", "@storybook/addon-knobs": "^4.1.4",
"@storybook/addon-options": "^3.2.13", "@storybook/addon-options": "^4.1.4",
"@storybook/react": "^3.2.13", "@storybook/react": "4.0.9",
"babel-cli": "^6.26.0", "babel-cli": "^6.26.0",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-eslint": "^6.0.2", "babel-eslint": "^6.0.2",
@ -45,7 +45,6 @@
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.16.0", "babel-preset-stage-0": "^6.16.0",
"css-loader": "^0.28.7",
"enzyme": "^3.1.0", "enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2", "enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4", "enzyme-to-json": "^3.1.4",
@ -54,25 +53,18 @@
"eslint-plugin-babel": "^3.2.0", "eslint-plugin-babel": "^3.2.0",
"eslint-plugin-jsx-a11y": "^0.6.2", "eslint-plugin-jsx-a11y": "^0.6.2",
"eslint-plugin-react": "^4.3.0", "eslint-plugin-react": "^4.3.0",
"file-loader": "^1.1.5",
"git-url-parse": "^7.0.1", "git-url-parse": "^7.0.1",
"jest": "^23.6.0", "jest": "^23.6.0",
"jsdom": "^11.3.0", "jsdom": "^11.3.0",
"node-sass": "^3.13.0",
"postcss-loader": "^2.0.8",
"prettier-eslint-cli": "^4.4.0", "prettier-eslint-cli": "^4.4.0",
"raw-loader": "^0.5.1",
"react": "^16.0.0", "react": "^16.0.0",
"react-addons-test-utils": "^15.6.2", "react-addons-test-utils": "^15.6.2",
"react-dom": "^16.0.0", "react-dom": "^16.0.0",
"react-test-renderer": "^16.0.0", "react-test-renderer": "^16.0.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"sass-loader": "^4.0.2",
"style-loader": "^0.19.0",
"stylelint": "^7.6.0", "stylelint": "^7.6.0",
"stylelint-config-standard": "^15.0.0", "stylelint-config-standard": "^15.0.0",
"stylelint-processor-styled-components": "^0.0.4", "stylelint-processor-styled-components": "^0.0.4"
"url-loader": "^0.6.2"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^0.14.9 || ^15.3.0" "react": "^0.14.9 || ^15.3.0"

View File

@ -16,9 +16,8 @@ export const Container = styled.div`
storiesOf('Button', module) storiesOf('Button', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<Button <Button
@ -37,9 +36,8 @@ storiesOf('Button', module)
</Container> </Container>
) )
) )
.addWithInfo( .add(
'mark', 'mark',
'',
() => ( () => (
<Container> <Container>
<Button <Button

View File

@ -16,9 +16,8 @@ export const Container = styled.div`
storiesOf('ContextMenu', module) storiesOf('ContextMenu', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<ContextMenu <ContextMenu

View File

@ -7,9 +7,8 @@ import { schema, uiSchema, formData } from '../../Form/stories/schema';
storiesOf('Dialog', module) storiesOf('Dialog', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Dialog <Dialog
title={text('title', 'Dialog Title')} title={text('title', 'Dialog Title')}
@ -25,9 +24,8 @@ storiesOf('Dialog', module)
/> />
) )
) )
.addWithInfo( .add(
'with form', 'with form',
'',
() => ( () => (
<Dialog <Dialog
open={boolean('open', true)} open={boolean('open', true)}

View File

@ -15,9 +15,8 @@ function getThemes() {
storiesOf('Editor', module) storiesOf('Editor', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'Based on [CodeMirror](http://codemirror.net/).',
() => ( () => (
<Editor <Editor
value={text('value', value)} value={text('value', value)}
@ -28,11 +27,11 @@ storiesOf('Editor', module)
onChange={action('change')} onChange={action('change')}
autofocus autofocus
/> />
) ),
{ info: 'Based on [CodeMirror](http://codemirror.net/).' }
) )
.addWithInfo( .add(
'with tabs', 'with tabs',
'',
() => ( () => (
<WithTabs <WithTabs
lineNumbers={boolean('lineNumbers', true)} lineNumbers={boolean('lineNumbers', true)}

View File

@ -7,9 +7,8 @@ import { schema, uiSchema, formData } from './schema';
storiesOf('Form', module) storiesOf('Form', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'Wrapper around [`react-jsonschema-form`](https://github.com/mozilla-services/react-jsonschema-form) with custom widgets.',
() => ( () => (
<Form <Form
formData={object('formData', formData)} formData={object('formData', formData)}
@ -19,5 +18,9 @@ storiesOf('Form', module)
onChange={action('form changed')} onChange={action('form changed')}
onSubmit={action('form submitted')} onSubmit={action('form submitted')}
/> />
) ),
{ info:
'Wrapper around [`react-jsonschema-form`](https://github.com/mozilla-services/react-jsonschema-form)'
+ ' with custom widgets.'
}
); );

View File

@ -15,9 +15,8 @@ export const Container = styled.div`
storiesOf('Notification', module) storiesOf('Notification', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<Notification <Notification

View File

@ -15,9 +15,8 @@ export const Container = styled.div`
storiesOf('SegmentedControl', module) storiesOf('SegmentedControl', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<SegmentedControl <SegmentedControl

View File

@ -20,9 +20,8 @@ export const Container = styled.div`
storiesOf('Select', module) storiesOf('Select', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'Wrapper around [React Select](https://github.com/JedWatson/react-select) with themes and new props like `openOuterUp` and `menuMaxHeight`.',
() => ( () => (
<Container> <Container>
<Select <Select
@ -39,5 +38,9 @@ storiesOf('Select', module)
openOuterUp={boolean('openOuterUp', false)} openOuterUp={boolean('openOuterUp', false)}
/> />
</Container> </Container>
) ),
{ info:
'Wrapper around [React Select](https://github.com/JedWatson/react-select) with themes '
+ 'and new props like `openOuterUp` and `menuMaxHeight`.'
}
); );

View File

@ -15,9 +15,8 @@ export const Container = styled.div`
storiesOf('Slider', module) storiesOf('Slider', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<Slider <Slider

View File

@ -16,9 +16,8 @@ const Container = styled.div`
storiesOf('Tabs', module) storiesOf('Tabs', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container><Tabs <Container><Tabs
tabs={simple10Tabs} tabs={simple10Tabs}
@ -30,9 +29,8 @@ storiesOf('Tabs', module)
/></Container> /></Container>
) )
) )
.addWithInfo( .add(
'with content', 'with content',
'',
() => ( () => (
<Tabs <Tabs
tabs={tabs} tabs={tabs}

View File

@ -26,9 +26,8 @@ export const SliderContainer = styled.div`
storiesOf('Toolbar', module) storiesOf('Toolbar', module)
.addDecorator(withKnobs) .addDecorator(withKnobs)
.addWithInfo( .add(
'default', 'default',
'',
() => ( () => (
<Container> <Container>
<Toolbar borderPosition={select('borderPosition', ['top', 'bottom'])}> <Toolbar borderPosition={select('borderPosition', ['top', 'bottom'])}>
@ -62,9 +61,8 @@ storiesOf('Toolbar', module)
</Container> </Container>
) )
) )
.addWithInfo( .add(
'tabs', 'tabs',
'',
() => ( () => (
<Container> <Container>
<Toolbar> <Toolbar>
@ -102,9 +100,8 @@ storiesOf('Toolbar', module)
</Container> </Container>
) )
) )
.addWithInfo( .add(
'with slider', 'with slider',
'',
() => ( () => (
<Container> <Container>
<SliderContainer> <SliderContainer>