From 3c686ae56cd54513074704fb6926f7e5976f2595 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Mon, 23 May 2016 19:14:44 +0200 Subject: [PATCH 1/6] fix es6 components --- specs/button/Button.jsx | 36 +++++++++++++++++-------------- specs/placeholder/Placeholder.jsx | 24 ++++++++++----------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/specs/button/Button.jsx b/specs/button/Button.jsx index 03e57ae..f29b258 100644 --- a/specs/button/Button.jsx +++ b/specs/button/Button.jsx @@ -6,22 +6,12 @@ import s from './Button.css'; * The only true button. */ export default class Button extends Component { - static propTypes = { - /** - * Button label. - */ - children: PropTypes.string.isRequired, - color: PropTypes.string, - size: PropTypes.oneOf(['small', 'normal', 'large']), - } - static defaultProps = { - color: '#333', - size: 'normal' - } - static sizes = { - small: '10px', - normal: '14px', - large: '18px' + constructor() { + this.sizes = { + small: '10px', + normal: '14px', + large: '18px' + }; } onClick() { @@ -39,3 +29,17 @@ export default class Button extends Component { ); } } + +Button.propTypes = { + /** + * Button label. + */ + children: PropTypes.string.isRequired, + color: PropTypes.string, + size: PropTypes.oneOf(['small', 'normal', 'large']), +}; + +Button.defaultProps = { + color: '#333', + size: 'normal' +}; diff --git a/specs/placeholder/Placeholder.jsx b/specs/placeholder/Placeholder.jsx index 009505b..2219f9c 100644 --- a/specs/placeholder/Placeholder.jsx +++ b/specs/placeholder/Placeholder.jsx @@ -6,18 +6,6 @@ import s from './Placeholder.css'; * Image placeholders. */ export default class Placeholder extends Component { - static propTypes = { - type: PropTypes.oneOf(['animal', 'bacon', 'beard', 'bear', 'cat', 'food', 'city', 'nature', 'people']), - width: PropTypes.number, - height: PropTypes.number - } - - static defaultProps = { - type: 'animal', - width: 150, - height: 150 - } - getImageUrl() { let { type, width, height } = this.props; let types = { @@ -41,3 +29,15 @@ export default class Placeholder extends Component { ); } } + +Placeholder.propTypes = { + type: PropTypes.oneOf(['animal', 'bacon', 'beard', 'bear', 'cat', 'food', 'city', 'nature', 'people']), + width: PropTypes.number, + height: PropTypes.number +}; + +Placeholder.defaultProps = { + type: 'animal', + width: 150, + height: 150 +}; \ No newline at end of file From 76e4f24834348cd88d6f979df6ed96b7cb71bbf6 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Tue, 24 May 2016 12:06:33 +0200 Subject: [PATCH 2/6] add babel conf --- .babelrc | 3 +++ package.json | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..fe8cd1d --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} \ No newline at end of file diff --git a/package.json b/package.json index fbdb621..c62c9b9 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "postinstall": "node pre-build-production.js" }, "dependencies": { + "babel-preset-es2015": "^6.9.0", + "babel-preset-react": "^6.5.0", "react": "^0.14.2", "react-dom": "^0.14.2", "sourcejs": "^0.6.0-nightly.4", From a0973f0a9448730469c3f6e6e11aa647769bbb00 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Tue, 24 May 2016 12:06:54 +0200 Subject: [PATCH 3/6] fix es6 react components --- specs/button/Button.jsx | 6 ++++-- specs/placeholder/Placeholder.jsx | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/specs/button/Button.jsx b/specs/button/Button.jsx index f29b258..1621925 100644 --- a/specs/button/Button.jsx +++ b/specs/button/Button.jsx @@ -6,7 +6,9 @@ import s from './Button.css'; * The only true button. */ export default class Button extends Component { - constructor() { + constructor(props) { + super(props); + this.sizes = { small: '10px', normal: '14px', @@ -21,7 +23,7 @@ export default class Button extends Component { render() { let styles = { color: this.props.color, - fontSize: Button.sizes[this.props.size] + fontSize: this.sizes[this.props.size] }; return ( diff --git a/specs/placeholder/Placeholder.jsx b/specs/placeholder/Placeholder.jsx index 2219f9c..48b8908 100644 --- a/specs/placeholder/Placeholder.jsx +++ b/specs/placeholder/Placeholder.jsx @@ -6,6 +6,10 @@ import s from './Placeholder.css'; * Image placeholders. */ export default class Placeholder extends Component { + constructor(props) { + super(props); + } + getImageUrl() { let { type, width, height } = this.props; let types = { From 357445bf153bc6a02243134e816a10a1cfbe4865 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Tue, 31 May 2016 10:56:37 +0200 Subject: [PATCH 4/6] add babel react-hmre preset --- .babelrc | 12 +++++++++++- package.json | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index fe8cd1d..d3c57b2 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,13 @@ { - "presets": ["es2015", "react"] + "env": { + "development": { + "presets": [ + "react-hmre" + ] + } + }, + "presets": [ + "es2015", + "react" + ] } \ No newline at end of file diff --git a/package.json b/package.json index c62c9b9..9273a92 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.5.0", + "babel-preset-react-hmre": "^1.1.1", "react": "^0.14.2", "react-dom": "^0.14.2", "sourcejs": "^0.6.0-nightly.4", From 71604705e9a83e09c827214a81224aecbd8f9a99 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Tue, 31 May 2016 11:04:07 +0200 Subject: [PATCH 5/6] update sourcejs-react-styleguidist dependency and bump version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9273a92..d066430 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.2.0", + "version": "0.3.0", "author": { "name": "Robert Haritonov", "url": "http://rhr.me/" @@ -18,6 +18,6 @@ "react-dom": "^0.14.2", "sourcejs": "^0.6.0-nightly.4", "sourcejs-react-docgen": "^0.3.0", - "sourcejs-react-styleguidist": "^0.4.0" + "sourcejs-react-styleguidist": "^0.5.0" } } From c711cc0e600353762f237291aa253ef56af76848 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Tue, 31 May 2016 11:11:34 +0200 Subject: [PATCH 6/6] add mising dep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d066430..7dee243 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.5.0", "babel-preset-react-hmre": "^1.1.1", + "babel-standalone": "^6.7.7", "react": "^0.14.2", "react-dom": "^0.14.2", "sourcejs": "^0.6.0-nightly.4",