Skip to content

Commit fe07047

Browse files
author
Amir Tocker
committed
Create project skeleton.
1 parent 080745f commit fe07047

File tree

9 files changed

+264
-0
lines changed

9 files changed

+264
-0
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react","es2015", "stage-1"]
3+
}

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "cloudinary_react",
3+
"version": "1.0.0-rc1",
4+
"description": "React components that utilize Cloudinary functionality",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"storybook": "start-storybook -p 6006",
9+
"build-storybook": "build-storybook"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/CloudinaryLtd/cloudinary_react.git"
14+
},
15+
"author": "Cloudinary",
16+
"license": "MIT",
17+
"bugs": {
18+
"url": "https://github.com/CloudinaryLtd/cloudinary_react/issues"
19+
},
20+
"homepage": "https://github.com/CloudinaryLtd/cloudinary_react#readme",
21+
"devDependencies": {
22+
"@kadira/storybook": "^2.5.2",
23+
"babel-cli": "^6.14.0",
24+
"babel-core": "^6.14.0",
25+
"babel-loader": "^6.2.5",
26+
"babel-plugin-transform-object-rest-spread": "^6.8.0",
27+
"babel-preset-es2015": "^6.14.0",
28+
"babel-preset-react": "^6.11.1",
29+
"babel-preset-stage-1": "^6.13.0",
30+
"react": "^15.3.1",
31+
"react-dom": "^15.3.1",
32+
"webpack": "^1.13.2"
33+
},
34+
"dependencies": {
35+
"cloudinary-core": "^2.1.2"
36+
},
37+
"babel": {
38+
"presets": [
39+
"react",
40+
"es2015",
41+
"stage-1"
42+
]
43+
}
44+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, {Component, PropTypes} from 'react';
2+
3+
export default class CloudinaryContext extends React.Component {
4+
constructor(props) {
5+
super(props);
6+
this.state = {};
7+
}
8+
9+
getChildContext() {
10+
return {cloud_name: "demo"};
11+
}
12+
13+
componentWillReceiveProps(nextProps) {
14+
}
15+
16+
componentWillMount() {
17+
}
18+
19+
componentDidMount() {
20+
}
21+
22+
componentWillUnmount() {
23+
}
24+
25+
componentWillUpdate(nextProps, nextState) {
26+
}
27+
28+
componentDidUpdate(prevProps, prevState) {
29+
}
30+
31+
shouldComponentUpdate(nextProps, nextState) {
32+
return true;
33+
}
34+
35+
render() {
36+
return (
37+
<span>CloudinaryContext Not Implemented yet</span>
38+
);
39+
}
40+
}
41+
CloudinaryContext.propTypes = {initialCount: React.PropTypes.number};
42+
CloudinaryContext.defaultProps = {initialCount: 0};
43+
CloudinaryContext.contextTypes = {
44+
cloud_name: PropTypes.string.isRequired
45+
};
46+
CloudinaryContext.childContextTypes = {
47+
cloud_name: PropTypes.string.isRequired
48+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "cloudinarycontext",
3+
"version": "1.0.0",
4+
"main": "./CloudinaryContext.js",
5+
"private": true
6+
}

src/components/Image/Image.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import React, {Component, PropTypes} from 'react';
2+
import cloudinary from 'cloudinary-core';
3+
4+
export default class Image extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
this.state = {bar: props.initialBar};
8+
// this.foo = this.foo.bind(this);
9+
}
10+
11+
componentWillReceiveProps(nextProps, nextContext) {
12+
var config = {};
13+
cloudinary.Configuration.CONFIG_PARAMS.forEach((param)=> {
14+
if(nextProps[param]){
15+
config[param] = nextProps[param];
16+
}
17+
});
18+
19+
this.setState({
20+
url: ""
21+
})
22+
}
23+
24+
componentWillMount() {
25+
}
26+
27+
componentDidMount() {
28+
}
29+
30+
componentWillUnmount() {
31+
}
32+
33+
componentWillUpdate(nextProps, nextState, nextContext) {
34+
}
35+
36+
componentDidUpdate(prevProps, prevState, prevContext) {
37+
}
38+
39+
shouldComponentUpdate(nextProps, nextState, nextContext) {
40+
return true;
41+
}
42+
43+
render() {
44+
let cl = cloudinary.Cloudinary.new({cloud_name: "demo"});
45+
var {publicId, transformation, ...other} = this.props;
46+
var url = cl.url(publicId, transformation);
47+
return (
48+
<img {...other} src={url} />
49+
);
50+
}
51+
}
52+
53+
Image.propTypes = {
54+
publicId: PropTypes.string.isRequired,
55+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
56+
height: PropTypes.number,
57+
transformation: PropTypes.oneOfType([
58+
PropTypes.string,
59+
PropTypes.object,
60+
PropTypes.arrayOf(React.PropTypes.object)
61+
]),
62+
handleLoad: PropTypes.func,
63+
breakpoints: PropTypes.oneOfType([
64+
PropTypes.func,
65+
PropTypes.arrayOf(React.PropTypes.number)
66+
])
67+
68+
};
69+
Image.defaultProps = {};
70+
Image.contextTypes = {
71+
config: React.PropTypes.object
72+
};

src/components/Image/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "image",
3+
"version": "1.0.0",
4+
"main": "./Image.js",
5+
"private": true
6+
}

src/components/Video/Video.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, {Component, PropTypes} from 'react';
2+
3+
export default class Video extends React.Component {
4+
constructor(props) {
5+
super(props);
6+
this.state = {};
7+
}
8+
9+
componentWillReceiveProps(nextProps) {
10+
}
11+
12+
componentWillMount() {
13+
}
14+
15+
componentDidMount() {
16+
}
17+
18+
componentWillUnmount() {
19+
}
20+
21+
componentWillUpdate(nextProps, nextState) {
22+
}
23+
24+
componentDidUpdate(prevProps, prevState) {
25+
}
26+
27+
shouldComponentUpdate(nextProps, nextState) {
28+
return true;
29+
}
30+
31+
render() {
32+
return (
33+
<div>Video Not Implemented yet.<video></video></div>
34+
);
35+
}
36+
}
37+
Video.propTypes = {initialCount: React.PropTypes.number};
38+
Video.defaultProps = {initialCount: 0};
39+
Video.contextTypes = {};

src/components/Video/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "video",
3+
"version": "1.0.0",
4+
"main": "./Video.js",
5+
"private": true
6+
}

stories/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { storiesOf, action, linkTo } from '@kadira/storybook';
3+
import Image from '../src/components/Image';
4+
import Video from '../src/components/Video';
5+
import CloudinaryContext from '../src/components/CloudinaryContext';
6+
7+
let CLImage = Image;
8+
9+
storiesOf('Cloudinary', module)
10+
.add('image', ()=> {
11+
let t = { width: 0.5, crop: "scale"};
12+
return (
13+
<Image publicId="sample" transformation={t}/>
14+
)})
15+
.add('image with alt', ()=> {
16+
let t = { width: 0.5, crop: "scale"};
17+
return(
18+
<Image publicId="does-not-exist" alt="This image is intentionally missing" transformation={t}/>
19+
)
20+
})
21+
.add('image with style', ()=> {
22+
let t = { width: 0.5, crop: "scale"};
23+
return(
24+
<Image publicId="sample" style={{border: "20px solid"}} transformation={t}/>
25+
)
26+
})
27+
.add('Video', ()=> {
28+
return (
29+
<Video />
30+
)})
31+
.add('CloudinaryContext', ()=> {
32+
let t = { width: 0.5, crop: "scale"};
33+
return (
34+
<CloudinaryContext >
35+
<div>
36+
<Image publicId="sample" transformation={t}/>
37+
</div>
38+
</CloudinaryContext>
39+
)})
40+
;

0 commit comments

Comments
 (0)