Skip to content

Commit

Permalink
Merge pull request #11 from bitjourney/react-storybook
Browse files Browse the repository at this point in the history
Add React storybook
  • Loading branch information
kenju committed Jan 11, 2017
2 parents ef8ac38 + c52fa89 commit 1867b41
Show file tree
Hide file tree
Showing 12 changed files with 2,152 additions and 120 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.json
Expand Up @@ -7,10 +7,11 @@
"import"
],
"rules": {
"arrow-body-style": 0
"arrow-body-style": 0,
"react/jsx-closing-bracket-location": 0
},
"env": {
"es6": true,
"mocha": true
}
}
}
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -21,4 +21,4 @@ npm-debug.log

# app
lib

build
7 changes: 7 additions & 0 deletions .storybook/config.js
@@ -0,0 +1,7 @@
import { configure, addDecorator } from '@kadira/storybook';

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

configure(loadStories, module);
2 changes: 0 additions & 2 deletions .vscode/settings.json
Expand Up @@ -2,9 +2,7 @@
"editor.renderWhitespace": "all",
"editor.tabSize": 2,
"editor.insertSpaces": true,

"files.trimTrailingWhitespace": true,
"files.autoSave": "onFocusChange",

"eslint.autoFixOnSave": true
}
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -8,6 +8,8 @@
"build": "babel src --out-dir lib --source-maps",
"test": "nyc mocha --opts spec/mocha.opts spec/**/*.spec.jsx",
"coveralls": "nyc report --reporter=text-lcov | $(npm bin)/coveralls",
"story:start": "start-storybook -p 9001 -c .storybook",
"story:build": "build-storybook -c .storybook -o build",
"prepublish": "yarnpkg build"
},
"files": [
Expand All @@ -28,6 +30,7 @@
},
"homepage": "https://github.com/bitjourney/react-simple-image#readme",
"devDependencies": {
"@kadira/storybook": "^2.35.2",
"babel-cli": "^6.14.0",
"babel-plugin-istanbul": "^3.0.0",
"babel-preset-es2015": "^6.18.0",
Expand Down
2 changes: 1 addition & 1 deletion src/image.jsx
Expand Up @@ -56,7 +56,7 @@ export default class Image extends React.Component {
src={this.props.src}
srcSet={this.buildSrcSet()}
sizes={this.buildSizes()}
/>
/>
);
}
}
49 changes: 49 additions & 0 deletions stories/image.jsx
@@ -0,0 +1,49 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { storiesOf } from '@kadira/storybook';
import Image from '../src/image';
import photo1x from './images/astronaut.jpg';
import photo2x from './images/astronaut@2x.jpg';
import photo300 from './images/react-300.png';
import photo900 from './images/react-900.png';

storiesOf('<Image />', module)
.addDecorator(story => (
<div style={{ textAlign: 'center' }}>
{story()}
</div>
))
.add('with pixel descriptor', () => (
<div>
<Image
alt="react-simple-image storybook component"
src={photo1x}
className="additional-className"
srcSet={{
'1x': photo1x,
'2x': photo2x,
}}
/>
<p>License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication</p>
<p><a href="https://visualhunt.com/photo/15033/close-up-of-astronaut-in-space/">Visual Hunt</a></p>
</div>
))
.add('with width descriptor', () => (
<div>
<Image
alt="react-simple-image storybook component"
src={photo300}
className="additional-className"
srcSet={{
'300w': photo300,
'900w': photo900,
}}
sizes={[
{ size: '100vw', mediaCondition: '(max-width: 480px)' },
{ size: '50vw', mediaCondition: '(max-width: 1200px)' },
{ size: 'calc(33vw - 100px)' },
]}
/>
<p>License: <a href="https://facebook.github.io/react/">React</a></p>
</div>
));
Binary file added stories/images/astronaut.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added stories/images/astronaut@2x.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added stories/images/react-300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added stories/images/react-900.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1867b41

Please sign in to comment.