Skip to content

Commit 8d6d761

Browse files
author
Amir Tocker
committed
Use AddInfo plugin in storybook
1 parent 1a5d0cd commit 8d6d761

File tree

4 files changed

+57
-14
lines changed

4 files changed

+57
-14
lines changed

.storybook/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { configure, setAddon } from '@kadira/storybook';
2+
import infoAddon from '@kadira/react-storybook-addon-info';
3+
function loadStories() {
4+
require('../stories');
5+
}
6+
setAddon(infoAddon);
7+
configure(loadStories, module);

.storybook/webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// you can use this file to add your custom webpack plugins, loaders and anything you like.
2+
// This is just the basic way to add addional webpack configurations.
3+
// For more information refer the docs: https://goo.gl/qPbSyX
4+
5+
// IMPORTANT
6+
// When you add this file, we won't add the default configurations which is similar
7+
// to "React Create App". This only has babel loader to load JavaScript.
8+
9+
module.exports = {
10+
plugins: [
11+
// your custom plugins
12+
],
13+
module: {
14+
loaders: [
15+
// add your custom loaders.
16+
],
17+
},
18+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"homepage": "https://github.com/CloudinaryLtd/cloudinary_react#readme",
2121
"devDependencies": {
22+
"@kadira/react-storybook-addon-info": "^3.2.1",
2223
"@kadira/storybook": "^2.5.2",
2324
"babel-cli": "^6.14.0",
2425
"babel-core": "^6.14.0",

stories/index.js

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,82 @@ import CloudinaryContext from '../src/components/CloudinaryContext';
66
import cloudinary from 'cloudinary-core';
77

88
storiesOf('Image', module)
9-
.add('image', ()=> {
9+
.addWithInfo('image', "Basic tag", ()=> {
1010
let t = { width: 0.5, crop: "scale"};
1111
return (
1212
<Image cloudName="demo" publicId="sample" transformation={t}/>
1313
)})
14-
.add('image with alt', ()=> {
14+
.addWithInfo('image with alt', "Demostrate using an img tag attribute", ()=> {
1515
let t = { width: 0.5, crop: "scale"};
1616
return(
1717
<Image cloudName="demo" publicId="does-not-exist" alt="This image is intentionally missing" transformation={t}/>
1818
)
1919
})
20-
.add('image with html attributes', ()=> {
20+
.addWithInfo('image with html attributes', 'image with html attributes', ()=> {
2121
return(
2222
<Image cloudName="demo" publicId="sample" html_width="100"/>
2323
)
2424
})
25-
.add('image with style', ()=> {
25+
.addWithInfo('image with style', 'image with style', ()=> {
2626
let t = { width: 0.5, crop: "scale"};
2727
return(
28-
<Image cloudName="demo" publicId="sample" style={{border: "20px solid"}} transformation={t}/>
28+
<Image cloudName="demo" publicId="sample" style={{border: "20px solid"}} />
29+
)
30+
}).addWithInfo('image with chained transformation', 'image with chained transformation', ()=> {
31+
let t = { width: 0.5, crop: "scale"};
32+
return(<div>
33+
<Image cloudName="demo" publicId="sample" width="100" crop="scale" angle="10" transformation={[{width:100, crop:"crop"}, {width:100, angle: -10, crop: "scale"}]} />
34+
<Image cloudName="demo" publicId="sample" width="100" crop="scale" angle="10" />
35+
</div>
36+
)
37+
}).addWithInfo('image with chained transformation', 'image with chained transformation', ()=> {
38+
let t = { width: 0.5, crop: "scale"};
39+
return(<div>
40+
<Image cloudName="demo" publicId="sample" width="100" crop="scale" angle="10">
41+
<Transformation width="100" crop="scale" angle="10"/>
42+
<Transformation width="100" crop="scale" angle="10"/>
43+
</Image>
44+
<Image cloudName="demo" publicId="sample" width="100" crop="scale" angle="10" />
45+
</div>
2946
)
3047
});
3148
storiesOf('Video', module)
32-
.add('Simple tag', ()=> {
49+
.addWithInfo('Simple tag', 'Simple tag', ()=> {
3350
return (
3451
<Video cloudName="demo" controls publicId="dog"/>
3552
)
36-
}).add('With fallback', ()=> {
53+
}).addWithInfo('With fallback', 'With fallback', ()=> {
3754
return (
3855
<Video cloudName="demo" controls="controls" publicId="dog" fallback="Cannot display video"/>
3956
)
40-
}).add('With inline fallback', ()=> {
57+
}).addWithInfo('With inline fallback', 'With inline fallback', ()=> {
4158
return (
4259
<Video cloudName="demo" controls="controls" publicId="dog" >
4360
Cannot display <b>video</b>.
4461
</Video>
4562
)
46-
}).add('With source types', ()=> {
63+
}).addWithInfo('With source types', 'With source types', ()=> {
4764
return (
4865
<Video cloudName="demo" controls="controls" publicId="dog" sourceTypes={['webm', 'ogv', 'mp4']}>
4966
Cannot display video.
5067
</Video>
5168
)
52-
}).add('Simple tag with width', ()=> {
69+
}).addWithInfo('Simple tag with width', 'Simple tag with width', ()=> {
5370
return (
5471
<Video cloudName="demo" controls publicId="dog" width="300" crop="scale"/>
5572
)
56-
}).add('Simple tag with poster url', ()=> {
73+
}).addWithInfo('Simple tag with poster url', 'Simple tag with poster url', ()=> {
5774
let url = cloudinary.Cloudinary.new({cloud_name: "demo"}).url("sample", {width:300, crop: "scale"});
5875
return (
5976
<Video cloudName="demo" controls publicId="dog" width="300" crop="scale" poster={url}/>
6077
)
61-
}).add('Simple tag with poster object', ()=> {
78+
}).addWithInfo('Simple tag with poster object', 'Simple tag with poster object', ()=> {
6279
return (
6380
<Video cloudName="demo" controls publicId="dog" width="300" crop="scale" poster={{publicId: "sample"}}/>
6481
)
6582
});
6683
storiesOf('CloudinaryContext', module)
67-
.add('CloudinaryContext', ()=> {
84+
.addWithInfo('CloudinaryContext', 'CloudinaryContext', ()=> {
6885
let t = { width: 0.5, crop: "scale"};
6986
return (
7087
<CloudinaryContext cloudName="demo" >
@@ -75,7 +92,7 @@ storiesOf('CloudinaryContext', module)
7592
<Image publicId="sample" transformation={t}/>
7693
</CloudinaryContext>
7794
)})
78-
.add('Nested Context', ()=> {
95+
.addWithInfo('Nested Context', 'Nested Context', ()=> {
7996
return (
8097
<CloudinaryContext cloudName="demo" width="50" crop="scale">
8198
<Image publicId="sample"/>

0 commit comments

Comments
 (0)