From c0413ca48cae389c57338acd285aa47a1db1461f Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Wed, 18 May 2016 22:10:18 +0300 Subject: [PATCH 1/5] TASK: React Storybook setup --- .storybook/config.js | 9 +++++++++ .storybook/webpack.config.js | 12 ++++++++++++ Build/Utilities/Environment.js | 3 ++- package.json | 4 +++- webpack.config.js | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .storybook/config.js create mode 100644 .storybook/webpack.config.js diff --git a/.storybook/config.js b/.storybook/config.js new file mode 100644 index 0000000000..2adefcc742 --- /dev/null +++ b/.storybook/config.js @@ -0,0 +1,9 @@ +import {configure} from '@kadira/storybook'; + +const req = require.context('./../Resources/Private/JavaScript', true, /story\.js$/); + +function loadStories() { + req.keys().forEach(req); +} + +configure(loadStories, module); diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js new file mode 100644 index 0000000000..45e02281a9 --- /dev/null +++ b/.storybook/webpack.config.js @@ -0,0 +1,12 @@ +const defaultConfig = require('./../webpack.config'); + +module.exports = Object.assign({}, defaultConfig, { + module: { + loaders: [ + { + test: /\.css$/, + loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader' + } + ] + } +}); diff --git a/Build/Utilities/Environment.js b/Build/Utilities/Environment.js index 470f67d05d..463d0948cd 100644 --- a/Build/Utilities/Environment.js +++ b/Build/Utilities/Environment.js @@ -1,4 +1,5 @@ module.exports = { isCi: process.env.CI, - isTesting: process.env.TEST + isTesting: process.env.TEST, + isStorybook: process.env.STORY }; diff --git a/package.json b/package.json index 40b1c8ddb2..1206a4000a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "Resources/Public/JavaScript/Host.js", "private": true, "devDependencies": { + "@kadira/storybook": "^1.27.0", "autoprefixer": "^6.2.2", "babel-core": "^6.4.0", "babel-eslint": "^6.0.2", @@ -117,7 +118,8 @@ "watch:karma": "export TEST=true && karma start", "watch": "npm run watch:build & npm run watch:karma", "prewatch": "Build/check-dependencies", - "prebuild": "Build/check-dependencies" + "prebuild": "Build/check-dependencies", + "storybook": "export STORY=true && start-storybook -p 9001" }, "contributors": [ { diff --git a/webpack.config.js b/webpack.config.js index b772a71cdf..27dec54cbd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -90,7 +90,7 @@ const config = { // // Adjust the config depending on the env. // -if (!env.isCi && !env.isTesting) { +if (!env.isCi && !env.isTesting && !env.isStorybook) { config.plugins.push(new LiveReloadPlugin({appendScriptTag: true})); } From 12e1eb45176097f1fb0de4be550771bfced051a7 Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Wed, 18 May 2016 22:11:16 +0300 Subject: [PATCH 2/5] TASK: add design story for Button component Also cleanup leftover hoverStyle. --- .../JavaScript/Components/Button/index.js | 1 - .../Components/Button/index.story.js | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Resources/Private/JavaScript/Components/Button/index.story.js diff --git a/Resources/Private/JavaScript/Components/Button/index.js b/Resources/Private/JavaScript/Components/Button/index.js index 7086cd61c4..843932ccfa 100644 --- a/Resources/Private/JavaScript/Components/Button/index.js +++ b/Resources/Private/JavaScript/Components/Button/index.js @@ -25,7 +25,6 @@ const Button = props => { [styles['btn--lighter']]: style === 'lighter', [styles['btn--transparent']]: style === 'transparent', [styles['btn--cleanHover']]: hoverStyle === 'clean', - [styles['btn--lighterHover']]: hoverStyle === 'lighter', [styles['btn--brandHover']]: hoverStyle === 'brand', [styles['btn--darkenHover']]: hoverStyle === 'darken', [styles['btn--brandActive']]: isActive, diff --git a/Resources/Private/JavaScript/Components/Button/index.story.js b/Resources/Private/JavaScript/Components/Button/index.story.js new file mode 100644 index 0000000000..9a668d9f1d --- /dev/null +++ b/Resources/Private/JavaScript/Components/Button/index.story.js @@ -0,0 +1,36 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import Button from './index.js'; + +storiesOf('Button', module) + .add('states', () => ( +
+ + + + +
+ )) + .add('background styles', () => ( +
+ + + +
+ )) + .add('hover styles', () => ( +
+ + + +
+ )) + .add('events', () => ( +
+ + + + + +
+ )); From 77a1d561a0bdd65feafa74b1ce984a80f90034f7 Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Wed, 18 May 2016 22:49:57 +0300 Subject: [PATCH 3/5] TASK: Add CheckBox story --- .../JavaScript/Components/CheckBox/index.story.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Resources/Private/JavaScript/Components/CheckBox/index.story.js diff --git a/Resources/Private/JavaScript/Components/CheckBox/index.story.js b/Resources/Private/JavaScript/Components/CheckBox/index.story.js new file mode 100644 index 0000000000..e0f5f266f5 --- /dev/null +++ b/Resources/Private/JavaScript/Components/CheckBox/index.story.js @@ -0,0 +1,13 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import CheckBox from './index.js'; + +storiesOf('CheckBox', module) + .add('default', () => ( +
+

Unchecked:

+ +

Checked:

+ +
+ )); From c763d6dded8ece912d4579a789ab76c0628ddbb8 Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Mon, 30 May 2016 18:47:16 +0300 Subject: [PATCH 4/5] TASK: create storybooks for remaining components --- .../JavaScript/Components/Bar/index.story.js | 15 ++++ .../Components/CheckBox/index.story.js | 2 +- .../Components/Dialog/index.story.js | 21 +++++ .../Components/DropDown/index.story.js | 15 ++++ .../JavaScript/Components/Grid/index.story.js | 16 ++++ .../Components/Headline/index.story.js | 15 ++++ .../JavaScript/Components/Icon/index.story.js | 24 ++++++ .../Components/IconButton/index.story.js | 10 +++ .../IconButtonDropDown/index.story.js | 20 +++++ .../Components/Label/index.story.js | 10 +++ .../Components/Portal/index.story.js | 8 ++ .../Components/SideBar/index.story.js | 11 +++ .../JavaScript/Components/Tabs/index.story.js | 13 ++++ .../Components/TextInput/index.story.js | 23 ++++++ .../Components/ToggablePanel/index.story.js | 10 +++ .../JavaScript/Components/Tree/index.story.js | 78 +++++++++++++++++++ 16 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 Resources/Private/JavaScript/Components/Bar/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Dialog/index.story.js create mode 100644 Resources/Private/JavaScript/Components/DropDown/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Grid/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Headline/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Icon/index.story.js create mode 100644 Resources/Private/JavaScript/Components/IconButton/index.story.js create mode 100644 Resources/Private/JavaScript/Components/IconButtonDropDown/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Label/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Portal/index.story.js create mode 100644 Resources/Private/JavaScript/Components/SideBar/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Tabs/index.story.js create mode 100644 Resources/Private/JavaScript/Components/TextInput/index.story.js create mode 100644 Resources/Private/JavaScript/Components/ToggablePanel/index.story.js create mode 100644 Resources/Private/JavaScript/Components/Tree/index.story.js diff --git a/Resources/Private/JavaScript/Components/Bar/index.story.js b/Resources/Private/JavaScript/Components/Bar/index.story.js new file mode 100644 index 0000000000..17640d5daa --- /dev/null +++ b/Resources/Private/JavaScript/Components/Bar/index.story.js @@ -0,0 +1,15 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Bar from './index.js'; + +storiesOf('Bar', module) + .add('default', () => ( +
+ + Top bar + + + Bottom bar + +
+ )); diff --git a/Resources/Private/JavaScript/Components/CheckBox/index.story.js b/Resources/Private/JavaScript/Components/CheckBox/index.story.js index e0f5f266f5..64fe2d4ac2 100644 --- a/Resources/Private/JavaScript/Components/CheckBox/index.story.js +++ b/Resources/Private/JavaScript/Components/CheckBox/index.story.js @@ -6,7 +6,7 @@ storiesOf('CheckBox', module) .add('default', () => (

Unchecked:

- +

Checked:

diff --git a/Resources/Private/JavaScript/Components/Dialog/index.story.js b/Resources/Private/JavaScript/Components/Dialog/index.story.js new file mode 100644 index 0000000000..49838c4112 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Dialog/index.story.js @@ -0,0 +1,21 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import Dialog from './index.js'; + +storiesOf('Dialog', module) + .add('default', () => ( +
+ Button
+ ]} + > + H1ello world + +
+
+ )); diff --git a/Resources/Private/JavaScript/Components/DropDown/index.story.js b/Resources/Private/JavaScript/Components/DropDown/index.story.js new file mode 100644 index 0000000000..a5df783066 --- /dev/null +++ b/Resources/Private/JavaScript/Components/DropDown/index.story.js @@ -0,0 +1,15 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import DropDown from './index.js'; + +storiesOf('DropDown', module) + .add('default', () => ( + + + Dropdown header + + + Dropdown contents + + + )); diff --git a/Resources/Private/JavaScript/Components/Grid/index.story.js b/Resources/Private/JavaScript/Components/Grid/index.story.js new file mode 100644 index 0000000000..a48b21abfd --- /dev/null +++ b/Resources/Private/JavaScript/Components/Grid/index.story.js @@ -0,0 +1,16 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Grid from './index.js'; +import GridItem from './GridItem/index.js'; + +storiesOf('Grid', module) + .add('default', () => ( + + Item 1 + Item 2 + Item 3 + Item 4 + Item 5 + Item 6 + + )); diff --git a/Resources/Private/JavaScript/Components/Headline/index.story.js b/Resources/Private/JavaScript/Components/Headline/index.story.js new file mode 100644 index 0000000000..442681c171 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Headline/index.story.js @@ -0,0 +1,15 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Headline from './index.js'; + +storiesOf('Headline', module) + .add('default', () => ( +
+ Heading 1 + Heading 2 + Heading 3 + Heading 4 + Heading 5 + Heading 6 +
+ )); diff --git a/Resources/Private/JavaScript/Components/Icon/index.story.js b/Resources/Private/JavaScript/Components/Icon/index.story.js new file mode 100644 index 0000000000..a0a1b73868 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Icon/index.story.js @@ -0,0 +1,24 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Icon from './index.js'; + +storiesOf('Icon', module) + .add('size', () => ( +
+
+
+
+
+ )) + .add('padded', () => ( +
+
+
+
+
+ )) + .add('spin', () => ( +
+ +
+ )); diff --git a/Resources/Private/JavaScript/Components/IconButton/index.story.js b/Resources/Private/JavaScript/Components/IconButton/index.story.js new file mode 100644 index 0000000000..b08887fe10 --- /dev/null +++ b/Resources/Private/JavaScript/Components/IconButton/index.story.js @@ -0,0 +1,10 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import IconButton from './index.js'; + +storiesOf('IconButton', module) + .add('default', () => ( +
+ +
+ )); diff --git a/Resources/Private/JavaScript/Components/IconButtonDropDown/index.story.js b/Resources/Private/JavaScript/Components/IconButtonDropDown/index.story.js new file mode 100644 index 0000000000..55d4f6843e --- /dev/null +++ b/Resources/Private/JavaScript/Components/IconButtonDropDown/index.story.js @@ -0,0 +1,20 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import IconButtonDropDown from './index.js'; +import Icon from './../Icon/index.js'; + +storiesOf('IconButtonDropDown', module) + .add('default', () => ( +
+ + + + + +
+ )); diff --git a/Resources/Private/JavaScript/Components/Label/index.story.js b/Resources/Private/JavaScript/Components/Label/index.story.js new file mode 100644 index 0000000000..7b46810246 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Label/index.story.js @@ -0,0 +1,10 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Label from './index.js'; + +storiesOf('Label', module) + .add('default', () => ( +
+ +
+ )); diff --git a/Resources/Private/JavaScript/Components/Portal/index.story.js b/Resources/Private/JavaScript/Components/Portal/index.story.js new file mode 100644 index 0000000000..1d3d3a612a --- /dev/null +++ b/Resources/Private/JavaScript/Components/Portal/index.story.js @@ -0,0 +1,8 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Portal from './index.js'; + +storiesOf('Portal', module) + .add('default', () => ( +
Test portal
+ )); diff --git a/Resources/Private/JavaScript/Components/SideBar/index.story.js b/Resources/Private/JavaScript/Components/SideBar/index.story.js new file mode 100644 index 0000000000..177b4aa8bf --- /dev/null +++ b/Resources/Private/JavaScript/Components/SideBar/index.story.js @@ -0,0 +1,11 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import SideBar from './index.js'; + +storiesOf('SideBar', module) + .add('default', () => ( +
+ Left sidebar + Right sidebar +
+ )); diff --git a/Resources/Private/JavaScript/Components/Tabs/index.story.js b/Resources/Private/JavaScript/Components/Tabs/index.story.js new file mode 100644 index 0000000000..5b8dead583 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Tabs/index.story.js @@ -0,0 +1,13 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import Tabs from './index.js'; + +storiesOf('Tabs', module) + .add('default', () => ( +
+ + Tab 1 contents + Tab 2 contents + +
+ )); diff --git a/Resources/Private/JavaScript/Components/TextInput/index.story.js b/Resources/Private/JavaScript/Components/TextInput/index.story.js new file mode 100644 index 0000000000..878164f88f --- /dev/null +++ b/Resources/Private/JavaScript/Components/TextInput/index.story.js @@ -0,0 +1,23 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import TextInput from './index.js'; + +storiesOf('TextInput', module) + .add('default', () => ( +
+ + +
+ )); diff --git a/Resources/Private/JavaScript/Components/ToggablePanel/index.story.js b/Resources/Private/JavaScript/Components/ToggablePanel/index.story.js new file mode 100644 index 0000000000..8fefd39af8 --- /dev/null +++ b/Resources/Private/JavaScript/Components/ToggablePanel/index.story.js @@ -0,0 +1,10 @@ +import React from 'react'; +import {storiesOf} from '@kadira/storybook'; +import ToggablePanel from './index.js'; + +storiesOf('ToggablePanel', module) + .add('default', () => ( +
+ Panel contents +
+ )); diff --git a/Resources/Private/JavaScript/Components/Tree/index.story.js b/Resources/Private/JavaScript/Components/Tree/index.story.js new file mode 100644 index 0000000000..820fcb24b4 --- /dev/null +++ b/Resources/Private/JavaScript/Components/Tree/index.story.js @@ -0,0 +1,78 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import Tree from './index.js'; + +storiesOf('Tree', module) + .add('default', () => ( +
+ adfasdfa + + + + + + + + + + + + + + + + +
+ )); From c1a357a0d01e289bb46ac925340029bb64f08f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tyll=20Wei=C3=9F?= Date: Fri, 3 Jun 2016 20:25:08 +0200 Subject: [PATCH 5/5] BUGFIX: Adopt the karma.entry regexp to ignore all .story.js files while creating the test bundle --- karma.entry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.entry.js b/karma.entry.js index fbfeedb26a..90c0113665 100644 --- a/karma.entry.js +++ b/karma.entry.js @@ -9,6 +9,6 @@ // Instead, this way of requiring all spec files results in one big test bundle webpack // needs to compile, which is a lot faster than the default configuration. // -const context = require.context('./Resources/Private/JavaScript', true, /.js$/); +const context = require.context('./Resources/Private/JavaScript', true, /(?!.*story.js$)^.*js$/); context.keys().forEach(context);