Skip to content

Commit 82efd67

Browse files
committed
Setup StoryBook for demo
1 parent 17d180c commit 82efd67

File tree

5 files changed

+77
-2
lines changed

5 files changed

+77
-2
lines changed

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';

.storybook/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.js
4+
const req = require.context('../stories', true, /.stories.js$/);
5+
function loadStories() {
6+
req.keys().forEach((filename) => req(filename));
7+
}
8+
9+
configure(loadStories, module);

.storybook/preview-head.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<style>
2+
3+
4+
*, *:before, *:after {
5+
box-sizing: border-box;
6+
position: relative;
7+
}
8+
9+
html {
10+
font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
11+
font-weight: 400;
12+
font-size: 16px;
13+
line-height: 1.5;
14+
}
15+
16+
body, html, #root {
17+
margin: 0;
18+
height: 100vh;
19+
min-height: 100vh;
20+
width: 100vw;
21+
}
22+
23+
a {
24+
-webkit-tap-highlight-color: rgba(0,0,0,0);
25+
}
26+
27+
#root {
28+
display: flex;
29+
flex-direction: column;
30+
flex: 1;
31+
}
32+
33+
</style>

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
"react-dom": "^16.2.0",
5353
"surge": "^0.19.0",
5454
"typescript": "^2.6.2",
55-
"watchify": "^3.9.0"
55+
"watchify": "^3.9.0",
56+
"@storybook/react": "^3.3.3",
57+
"@storybook/addon-actions": "^3.3.3",
58+
"@storybook/addon-links": "^3.3.3"
5659
},
5760
"scripts": {
5861
"compile": "babel -d lib/ src/",
@@ -64,7 +67,9 @@
6467
"demo": "npm run compile && browserify demo/Examples.js -d -t -o demo/bundle.js",
6568
"demo:watch": "npm run compile:watch & watchify demo/Examples.js -d -t -o demo/bundle.js",
6669
"demo:publish": "npm run compile && browserify demo/Examples.js -d -t -o demo/bundle.js && surge demo react-split-pane-v2.surge.sh",
67-
"prettier": "prettier --single-quote --trailing-comma es5 --write './{src,test}/**/*.js'"
70+
"prettier": "prettier --single-quote --trailing-comma es5 --write './{src,test}/**/*.js'",
71+
"storybook": "start-storybook -p 6006",
72+
"build-storybook": "build-storybook"
6873
},
6974
"browserify": {
7075
"transform": [

stories/index.stories.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
3+
import { storiesOf } from '@storybook/react';
4+
import { action } from '@storybook/addon-actions';
5+
import { linkTo } from '@storybook/addon-links';
6+
7+
import SplitPane from '../lib/SplitPane';
8+
import Pane from "../lib/Pane";
9+
10+
import { Button, Welcome } from '@storybook/react/demo';
11+
12+
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
13+
14+
storiesOf('Vertical', module)
15+
.add('with divs', () =>
16+
<SplitPane split="vertical">
17+
<div>This is a div</div>
18+
<div>This is a div</div>
19+
</SplitPane>
20+
)
21+
.add('with Panes', () =>
22+
<SplitPane split="vertical">
23+
<Pane>This is a Pane</Pane>
24+
<Pane>This is a Pane</Pane>
25+
</SplitPane>
26+
);

0 commit comments

Comments
 (0)