Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storybook and a basic datapair component #6

Merged
merged 1 commit into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { configure } from '@kadira/storybook';

function loadStories() {
require('../stories');
}

configure(loadStories, module);
18 changes: 18 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// you can use this file to add your custom webpack plugins, loaders and anything you like.
// This is just the basic way to add addional webpack configurations.
// For more information refer the docs: https://goo.gl/qPbSyX

// IMPORTANT
// When you add this file, we won't add the default configurations which is similar
// to "React Create App". This only has babel loader to load JavaScript.

module.exports = {
plugins: [
// your custom plugins
],
module: {
loaders: [
// add your custom loaders.
],
},
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"dist": "webpack -p",
"lint": "eslint src; exit 0",
"start": "webpack-dashboard -- node dev_server.js",
"test": "nyc --reporter text --reporter lcov mocha --recursive --timeout 10000 --compilers js:babel-register --require ignore-styles"
"test": "nyc --reporter text --reporter lcov mocha --recursive --timeout 10000 --compilers js:babel-register --require ignore-styles",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"babel-polyfill": "~6.13.0",
Expand Down Expand Up @@ -53,7 +55,8 @@
"webpack-dashboard": "~0.1.5",
"webpack-dev-middleware": "^1.8.1",
"webpack-hot-middleware": "~2.12.1",
"webpack-visualizer-plugin": "~0.1.5"
"webpack-visualizer-plugin": "~0.1.5",
"@kadira/storybook": "^2.5.2"
},
"nyc": {
"exclude": [
Expand Down
15 changes: 15 additions & 0 deletions src/components/datapair/Datapair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

const Datapair = (props) => (
<div className="datapair">
<span>{props.label}</span>
<div>{props.children || props.value}</div>
</div>
);

Datapair.PropTypes = {
label: React.PropTypes.string.isRequired,
value: React.PropTypes.string
}

export default Datapair;
12 changes: 12 additions & 0 deletions stories/Datapair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';

import Datapair from '../src/components/datapair/Datapair';

storiesOf('Datapair', module)
.add('with props', () => (
<Datapair label="Key" value="stuff" />
))
.add('with HTML value', () => (
<Datapair label="Label"><h1>Custom markup</h1></Datapair>
))
10 changes: 10 additions & 0 deletions stories/Welcome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';

storiesOf('Welcome', module)
.add('Introduction', () => (
<section>
<h1>xanthous</h1>
<p>badass</p>
</section>
));
3 changes: 3 additions & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './Welcome';

import './Datapair';