From cd93e6bd1c97bec1406ab66ceb516bda3b5d1628 Mon Sep 17 00:00:00 2001 From: Andranik Antonyan Date: Wed, 20 Jan 2016 23:32:27 +0300 Subject: [PATCH 001/416] fix(routes.js): check response status. --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index c8f865ed0..59f9800aa 100644 --- a/src/routes.js +++ b/src/routes.js @@ -33,7 +33,7 @@ const router = new Router(on => { on('*', async (state) => { const response = await fetch(`/api/content?path=${state.path}`); const content = await response.json(); - return content && ; + return response.ok && content && ; }); on('error', (state, error) => state.statusCode === 404 ? From 9f565769b4eb3231380b1fccd798089b461d0849 Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus Date: Wed, 18 Nov 2015 19:47:31 +0300 Subject: [PATCH 002/416] Upgrade Babel to v6.x --- .babelrc | 11 +++++++++-- package.json | 13 +++++++++---- src/client.js | 2 +- src/components/ContactPage/ContactPage.js | 5 ++--- src/components/ContentPage/ContentPage.js | 5 ++--- src/components/ErrorPage/ErrorPage.js | 5 ++--- src/components/Feedback/Feedback.js | 5 ++--- src/components/Footer/Footer.js | 5 ++--- src/components/Header/Header.js | 5 ++--- src/components/Link/Link.js | 4 ++-- src/components/LoginPage/LoginPage.js | 5 ++--- src/components/Navigation/Navigation.js | 5 ++--- src/components/NotFoundPage/NotFoundPage.js | 5 ++--- src/components/RegisterPage/RegisterPage.js | 5 ++--- src/{decorators => components}/withStyles.js | 6 +++--- src/{decorators => components}/withViewport.js | 0 src/server.js | 4 ++-- tools/run.js | 18 ++++++++++-------- tools/start.js | 9 ++++----- 19 files changed, 60 insertions(+), 57 deletions(-) rename src/{decorators => components}/withStyles.js (82%) rename src/{decorators => components}/withViewport.js (100%) diff --git a/.babelrc b/.babelrc index ce840ab86..891533a11 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,10 @@ { - "stage": 0 -} \ No newline at end of file + "presets": [ + "es2015", + "stage-0", + "react" + ], + "plugins": [ + "transform-runtime" + ] +} diff --git a/package.json b/package.json index ec8d8196f..cfdfb6b57 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "npm": ">=3.3 <4" }, "dependencies": { - "babel-core": "5.8.34", + "babel-polyfill": "^6.3.14", + "babel-runtime": "^6.3.19", "bluebird": "3.1.1", "classnames": "2.2.1", "eventemitter3": "1.1.1", @@ -26,10 +27,14 @@ "devDependencies": { "assets-webpack-plugin": "^3.2.0", "autoprefixer": "^6.1.2", - "babel": "^5.8.34", + "babel-cli": "^6.4.5", "babel-eslint": "^4.1.6", - "babel-loader": "^5.4.0", - "babel-plugin-react-transform": "^1.1.1", + "babel-loader": "^6.2.1", + "babel-plugin-react-transform": "^2.0.0", + "babel-plugin-transform-runtime": "^6.4.3", + "babel-preset-es2015": "^6.3.13", + "babel-preset-react": "^6.3.13", + "babel-preset-stage-0": "^6.3.13", "browser-sync": "^2.10.1", "css-loader": "^0.23.0", "csscomb": "^3.1.8", diff --git a/src/client.js b/src/client.js index 4aa0582ec..c4c7e9737 100644 --- a/src/client.js +++ b/src/client.js @@ -7,7 +7,7 @@ * LICENSE.txt file in the root directory of this source tree. */ -import 'babel-core/polyfill'; +import 'babel-polyfill'; import ReactDOM from 'react-dom'; import FastClick from 'fastclick'; import Router from './routes'; diff --git a/src/components/ContactPage/ContactPage.js b/src/components/ContactPage/ContactPage.js index 9998f6248..57085779a 100644 --- a/src/components/ContactPage/ContactPage.js +++ b/src/components/ContactPage/ContactPage.js @@ -9,11 +9,10 @@ import React, { Component, PropTypes } from 'react'; import s from './ContactPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; const title = 'Contact Us'; -@withStyles(s) class ContactPage extends Component { static contextTypes = { @@ -37,4 +36,4 @@ class ContactPage extends Component { } -export default ContactPage; +export default withStyles(ContactPage, s); diff --git a/src/components/ContentPage/ContentPage.js b/src/components/ContentPage/ContentPage.js index 2868b667c..67752cc26 100644 --- a/src/components/ContentPage/ContentPage.js +++ b/src/components/ContentPage/ContentPage.js @@ -9,9 +9,8 @@ import React, { Component, PropTypes } from 'react'; import s from './ContentPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; -@withStyles(s) class ContentPage extends Component { static propTypes = { @@ -38,4 +37,4 @@ class ContentPage extends Component { } -export default ContentPage; +export default withStyles(ContentPage, s); diff --git a/src/components/ErrorPage/ErrorPage.js b/src/components/ErrorPage/ErrorPage.js index a29889b0a..f1f944390 100644 --- a/src/components/ErrorPage/ErrorPage.js +++ b/src/components/ErrorPage/ErrorPage.js @@ -9,11 +9,10 @@ import React, { Component, PropTypes } from 'react'; import s from './ErrorPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; const title = 'Error'; -@withStyles(s) class ErrorPage extends Component { static contextTypes = { @@ -36,4 +35,4 @@ class ErrorPage extends Component { } -export default ErrorPage; +export default withStyles(ErrorPage, s); diff --git a/src/components/Feedback/Feedback.js b/src/components/Feedback/Feedback.js index d512e0849..b82a4b301 100644 --- a/src/components/Feedback/Feedback.js +++ b/src/components/Feedback/Feedback.js @@ -9,9 +9,8 @@ import React, { Component } from 'react'; import s from './Feedback.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; -@withStyles(s) class Feedback extends Component { render() { @@ -28,4 +27,4 @@ class Feedback extends Component { } -export default Feedback; +export default withStyles(Feedback, s); diff --git a/src/components/Footer/Footer.js b/src/components/Footer/Footer.js index 88f896c28..e0272758a 100644 --- a/src/components/Footer/Footer.js +++ b/src/components/Footer/Footer.js @@ -9,10 +9,9 @@ import React, { Component } from 'react'; import s from './Footer.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; import Link from '../Link'; -@withStyles(s) class Footer extends Component { render() { @@ -33,4 +32,4 @@ class Footer extends Component { } -export default Footer; +export default withStyles(Footer, s); diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index fbda30dbf..b5fc71646 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -9,11 +9,10 @@ import React, { Component } from 'react'; import s from './Header.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; import Link from '../Link'; import Navigation from '../Navigation'; -@withStyles(s) class Header extends Component { render() { @@ -36,4 +35,4 @@ class Header extends Component { } -export default Header; +export default withStyles(Header, s); diff --git a/src/components/Link/Link.js b/src/components/Link/Link.js index 685919fd4..999b3ef26 100644 --- a/src/components/Link/Link.js +++ b/src/components/Link/Link.js @@ -28,7 +28,7 @@ class Link extends Component { onClick: PropTypes.func, }; - static handleClick = (event) => { + handleClick = (event) => { let allowTransition = true; let clickResult; @@ -65,7 +65,7 @@ class Link extends Component { render() { const { to, query, ...props } = this.props; - return ; + return ; } } diff --git a/src/components/LoginPage/LoginPage.js b/src/components/LoginPage/LoginPage.js index d3a550e9a..a37b4b591 100644 --- a/src/components/LoginPage/LoginPage.js +++ b/src/components/LoginPage/LoginPage.js @@ -9,11 +9,10 @@ import React, { Component, PropTypes } from 'react'; import s from './LoginPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; const title = 'Log In'; -@withStyles(s) class LoginPage extends Component { static contextTypes = { @@ -37,4 +36,4 @@ class LoginPage extends Component { } -export default LoginPage; +export default withStyles(LoginPage, s); diff --git a/src/components/Navigation/Navigation.js b/src/components/Navigation/Navigation.js index 0204fec41..029341638 100644 --- a/src/components/Navigation/Navigation.js +++ b/src/components/Navigation/Navigation.js @@ -10,10 +10,9 @@ import React, { Component, PropTypes } from 'react'; import cx from 'classnames'; import s from './Navigation.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; import Link from '../Link'; -@withStyles(s) class Navigation extends Component { static propTypes = { @@ -35,4 +34,4 @@ class Navigation extends Component { } -export default Navigation; +export default withStyles(Navigation, s); diff --git a/src/components/NotFoundPage/NotFoundPage.js b/src/components/NotFoundPage/NotFoundPage.js index b90235aec..bd4137da3 100644 --- a/src/components/NotFoundPage/NotFoundPage.js +++ b/src/components/NotFoundPage/NotFoundPage.js @@ -9,11 +9,10 @@ import React, { Component, PropTypes } from 'react'; import s from './NotFoundPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; const title = 'Page Not Found'; -@withStyles(s) class NotFoundPage extends Component { static contextTypes = { @@ -37,4 +36,4 @@ class NotFoundPage extends Component { } -export default NotFoundPage; +export default withStyles(NotFoundPage, s); diff --git a/src/components/RegisterPage/RegisterPage.js b/src/components/RegisterPage/RegisterPage.js index 6c0cf633e..08054ecd9 100644 --- a/src/components/RegisterPage/RegisterPage.js +++ b/src/components/RegisterPage/RegisterPage.js @@ -9,11 +9,10 @@ import React, { Component, PropTypes } from 'react'; import s from './RegisterPage.scss'; -import withStyles from '../../decorators/withStyles'; +import withStyles from '../withStyles'; const title = 'New User Registration'; -@withStyles(s) class RegisterPage extends Component { static contextTypes = { @@ -37,4 +36,4 @@ class RegisterPage extends Component { } -export default RegisterPage; +export default withStyles(RegisterPage, s); diff --git a/src/decorators/withStyles.js b/src/components/withStyles.js similarity index 82% rename from src/decorators/withStyles.js rename to src/components/withStyles.js index 70a64bdcd..b5fc87646 100644 --- a/src/decorators/withStyles.js +++ b/src/components/withStyles.js @@ -9,8 +9,8 @@ import React, { Component, PropTypes } from 'react'; -function withStyles(...styles) { - return (BaseComponent) => class StyledComponent extends Component { +function withStyles(BaseComponent, ...styles) { + return class StyledComponent extends Component { static contextTypes = { insertCss: PropTypes.func.isRequired, }; @@ -20,7 +20,7 @@ function withStyles(...styles) { } componentWillUnmount() { - this.removeCss(); + setTimeout(this.removeCss, 0); } render() { diff --git a/src/decorators/withViewport.js b/src/components/withViewport.js similarity index 100% rename from src/decorators/withViewport.js rename to src/components/withViewport.js diff --git a/src/server.js b/src/server.js index 62842cfe1..41911ddf8 100644 --- a/src/server.js +++ b/src/server.js @@ -7,7 +7,7 @@ * LICENSE.txt file in the root directory of this source tree. */ -import 'babel-core/polyfill'; +import 'babel-polyfill'; import path from 'path'; import express from 'express'; import React from 'react'; @@ -27,7 +27,7 @@ server.use(express.static(path.join(__dirname, 'public'))); // // Register API middleware // ----------------------------------------------------------------------------- -server.use('/api/content', require('./api/content')); +server.use('/api/content', require('./api/content').default); // // Register server-side rendering middleware diff --git a/tools/run.js b/tools/run.js index 51eb92e1f..1bf9cd535 100644 --- a/tools/run.js +++ b/tools/run.js @@ -11,19 +11,21 @@ function format(time) { return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1'); } -async function run(fn, options) { +function run(fn, options) { + const task = typeof fn.default === 'undefined' ? fn : fn.default; const start = new Date(); - console.log(`[${format(start)}] Starting '${fn.name}'...`); - await fn(options); - const end = new Date(); - const time = end.getTime() - start.getTime(); - console.log(`[${format(end)}] Finished '${fn.name}' after ${time} ms`); + console.log(`[${format(start)}] Starting '${task.name}'...`); + return task(options).then(() => { + const end = new Date(); + const time = end.getTime() - start.getTime(); + console.log(`[${format(end)}] Finished '${task.name}' after ${time} ms`); + }); } if (process.mainModule.children.length === 0 && process.argv.length > 2) { delete require.cache[__filename]; - const module = process.argv[2]; - run(require('./' + module + '.js')).catch(err => console.error(err.stack)); + const module = require('./' + process.argv[2] + '.js').default; + run(module).catch(err => console.error(err.stack)); } export default run; diff --git a/tools/start.js b/tools/start.js index 59beef384..3ddda7c7b 100644 --- a/tools/start.js +++ b/tools/start.js @@ -41,9 +41,8 @@ async function start() { .forEach(x => x.query = { // Wraps all React components into arbitrary transforms // https://github.com/gaearon/babel-plugin-react-transform - plugins: ['react-transform'], - extra: { - 'react-transform': { + plugins: [ + ['react-transform', { transforms: [ { transform: 'react-transform-hmr', @@ -54,8 +53,8 @@ async function start() { imports: ['react', 'redbox-react'], }, ], - }, - }, + }], + ], }); }); From 491ed16f2e643c9a97043c5dcc71a1b65eab4179 Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus Date: Wed, 20 Jan 2016 16:25:58 +0300 Subject: [PATCH 003/416] Update the remaining NPM modules and dependencies --- docs/data-fetching.md | 2 +- package.json | 46 ++++++++++----------- src/components/ContactPage/ContactPage.js | 2 +- src/components/ContentPage/ContentPage.js | 2 +- src/components/ErrorPage/ErrorPage.js | 2 +- src/components/Feedback/Feedback.js | 2 +- src/components/Footer/Footer.js | 2 +- src/components/Header/Header.js | 2 +- src/components/Link/Link.js | 2 +- src/components/LoginPage/LoginPage.js | 2 +- src/components/Navigation/Navigation.js | 2 +- src/components/NotFoundPage/NotFoundPage.js | 2 +- src/components/RegisterPage/RegisterPage.js | 2 +- src/components/TextBox/TextBox.js | 2 +- src/components/withStyles.js | 32 -------------- 15 files changed, 36 insertions(+), 68 deletions(-) delete mode 100644 src/components/withStyles.js diff --git a/docs/data-fetching.md b/docs/data-fetching.md index 6665c9af3..30a052423 100644 --- a/docs/data-fetching.md +++ b/docs/data-fetching.md @@ -10,7 +10,7 @@ export const path = '/products'; export const action = async () => { const response = await fetch('/api/products'); const data = await response.json(); - return ; + return ; }; ``` diff --git a/package.json b/package.json index cfdfb6b57..c547f70d0 100644 --- a/package.json +++ b/package.json @@ -8,63 +8,63 @@ "babel-polyfill": "^6.3.14", "babel-runtime": "^6.3.19", "bluebird": "3.1.1", - "classnames": "2.2.1", + "classnames": "2.2.3", "eventemitter3": "1.1.1", "express": "4.13.3", "fastclick": "1.0.6", - "fbjs": "0.5.1", - "front-matter": "2.0.1", - "history": "1.16.0", + "fbjs": "0.6.1", + "front-matter": "2.0.5", + "history": "2.0.0-rc2", + "isomorphic-style-loader": "0.0.6", "jade": "1.11.0", "node-fetch": "1.3.3", "normalize.css": "3.0.3", - "react": "0.14.3", - "react-dom": "0.14.3", - "react-routing": "0.0.6", + "react": "0.14.6", + "react-dom": "0.14.6", + "react-routing": "0.0.7", "source-map-support": "0.4.0", - "whatwg-fetch": "0.10.1" + "whatwg-fetch": "0.11.0" }, "devDependencies": { "assets-webpack-plugin": "^3.2.0", - "autoprefixer": "^6.1.2", + "autoprefixer": "^6.3.1", "babel-cli": "^6.4.5", - "babel-eslint": "^4.1.6", + "babel-eslint": "^5.0.0-beta6", "babel-loader": "^6.2.1", "babel-plugin-react-transform": "^2.0.0", "babel-plugin-transform-runtime": "^6.4.3", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "babel-preset-stage-0": "^6.3.13", - "browser-sync": "^2.10.1", - "css-loader": "^0.23.0", + "browser-sync": "^2.11.1", + "css-loader": "^0.23.1", "csscomb": "^3.1.8", "del": "^2.2.0", "eslint": "^1.10.3", - "eslint-config-airbnb": "^2.1.1", - "eslint-loader": "^1.1.1", - "eslint-plugin-react": "^3.11.3", + "eslint-config-airbnb": "^3.1.0", + "eslint-loader": "^1.2.0", + "eslint-plugin-react": "^3.15.0", "file-loader": "^0.8.5", "gaze": "^0.5.2", "git-repository": "^0.1.1", - "glob": "^6.0.1", - "isomorphic-style-loader": "0.0.5", + "glob": "^6.0.4", "jest-cli": "^0.8.2", - "jscs": "^2.7.0", + "jscs": "^2.8.0", "json-loader": "^0.5.4", - "lodash.merge": "^3.3.2", + "lodash.merge": "^4.0.1", "mkdirp": "^0.5.1", "ncp": "^2.0.0", - "postcss": "^5.0.13", + "postcss": "^5.0.14", "postcss-import": "^7.1.3", "postcss-loader": "^0.8.0", - "precss": "^1.3.0", + "precss": "^1.4.0", "raw-loader": "^0.5.1", - "react-transform-catch-errors": "^1.0.0", + "react-transform-catch-errors": "^1.0.1", "react-transform-hmr": "^1.0.1", "redbox-react": "^1.2.0", "replace": "^0.3.0", "url-loader": "^0.5.7", - "webpack": "^1.12.9", + "webpack": "^1.12.11", "webpack-hot-middleware": "^2.6.0", "webpack-middleware": "^1.4.0" }, diff --git a/src/components/ContactPage/ContactPage.js b/src/components/ContactPage/ContactPage.js index 57085779a..9776c38e6 100644 --- a/src/components/ContactPage/ContactPage.js +++ b/src/components/ContactPage/ContactPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './ContactPage.scss'; -import withStyles from '../withStyles'; const title = 'Contact Us'; diff --git a/src/components/ContentPage/ContentPage.js b/src/components/ContentPage/ContentPage.js index 67752cc26..d187db83d 100644 --- a/src/components/ContentPage/ContentPage.js +++ b/src/components/ContentPage/ContentPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './ContentPage.scss'; -import withStyles from '../withStyles'; class ContentPage extends Component { diff --git a/src/components/ErrorPage/ErrorPage.js b/src/components/ErrorPage/ErrorPage.js index f1f944390..ffb07a5ed 100644 --- a/src/components/ErrorPage/ErrorPage.js +++ b/src/components/ErrorPage/ErrorPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './ErrorPage.scss'; -import withStyles from '../withStyles'; const title = 'Error'; diff --git a/src/components/Feedback/Feedback.js b/src/components/Feedback/Feedback.js index b82a4b301..3c08de6ed 100644 --- a/src/components/Feedback/Feedback.js +++ b/src/components/Feedback/Feedback.js @@ -8,8 +8,8 @@ */ import React, { Component } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Feedback.scss'; -import withStyles from '../withStyles'; class Feedback extends Component { diff --git a/src/components/Footer/Footer.js b/src/components/Footer/Footer.js index e0272758a..ab9e35366 100644 --- a/src/components/Footer/Footer.js +++ b/src/components/Footer/Footer.js @@ -8,8 +8,8 @@ */ import React, { Component } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Footer.scss'; -import withStyles from '../withStyles'; import Link from '../Link'; class Footer extends Component { diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index b5fc71646..0a44156d5 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -8,8 +8,8 @@ */ import React, { Component } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Header.scss'; -import withStyles from '../withStyles'; import Link from '../Link'; import Navigation from '../Navigation'; diff --git a/src/components/Link/Link.js b/src/components/Link/Link.js index 999b3ef26..035207d75 100644 --- a/src/components/Link/Link.js +++ b/src/components/Link/Link.js @@ -65,7 +65,7 @@ class Link extends Component { render() { const { to, query, ...props } = this.props; - return ; + return ; } } diff --git a/src/components/LoginPage/LoginPage.js b/src/components/LoginPage/LoginPage.js index a37b4b591..4e327306e 100644 --- a/src/components/LoginPage/LoginPage.js +++ b/src/components/LoginPage/LoginPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './LoginPage.scss'; -import withStyles from '../withStyles'; const title = 'Log In'; diff --git a/src/components/Navigation/Navigation.js b/src/components/Navigation/Navigation.js index 029341638..8de90b875 100644 --- a/src/components/Navigation/Navigation.js +++ b/src/components/Navigation/Navigation.js @@ -9,8 +9,8 @@ import React, { Component, PropTypes } from 'react'; import cx from 'classnames'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Navigation.scss'; -import withStyles from '../withStyles'; import Link from '../Link'; class Navigation extends Component { diff --git a/src/components/NotFoundPage/NotFoundPage.js b/src/components/NotFoundPage/NotFoundPage.js index bd4137da3..71234823f 100644 --- a/src/components/NotFoundPage/NotFoundPage.js +++ b/src/components/NotFoundPage/NotFoundPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './NotFoundPage.scss'; -import withStyles from '../withStyles'; const title = 'Page Not Found'; diff --git a/src/components/RegisterPage/RegisterPage.js b/src/components/RegisterPage/RegisterPage.js index 08054ecd9..aaf82f78e 100644 --- a/src/components/RegisterPage/RegisterPage.js +++ b/src/components/RegisterPage/RegisterPage.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './RegisterPage.scss'; -import withStyles from '../withStyles'; const title = 'New User Registration'; diff --git a/src/components/TextBox/TextBox.js b/src/components/TextBox/TextBox.js index 8acd7536d..67f57753b 100644 --- a/src/components/TextBox/TextBox.js +++ b/src/components/TextBox/TextBox.js @@ -8,8 +8,8 @@ */ import React, { Component, PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './TextBox.scss'; -import withStyles from '../../decorators/withStyles'; @withStyles(s) class TextBox extends Component { diff --git a/src/components/withStyles.js b/src/components/withStyles.js deleted file mode 100644 index b5fc87646..000000000 --- a/src/components/withStyles.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * React Starter Kit (https://www.reactstarterkit.com/) - * - * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE.txt file in the root directory of this source tree. - */ - -import React, { Component, PropTypes } from 'react'; - -function withStyles(BaseComponent, ...styles) { - return class StyledComponent extends Component { - static contextTypes = { - insertCss: PropTypes.func.isRequired, - }; - - componentWillMount() { - this.removeCss = this.context.insertCss.apply(undefined, styles); - } - - componentWillUnmount() { - setTimeout(this.removeCss, 0); - } - - render() { - return ; - } - }; -} - -export default withStyles; From b92bd0a825c66790804818393dedbfabca8620c4 Mon Sep 17 00:00:00 2001 From: nodkz Date: Thu, 21 Jan 2016 13:04:47 +0600 Subject: [PATCH 004/416] Fix problem with babel6 with react-transform-hmr for server script. Problem: config.module.loaders pointed in same object in memory. So react-transform (in start.js) applies for server config too, in despite of x.target !== 'node'. --- package.json | 1 + tools/webpack.config.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c547f70d0..8b1074b3d 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "jest-cli": "^0.8.2", "jscs": "^2.8.0", "json-loader": "^0.5.4", + "lodash.clonedeep": "4.0.1", "lodash.merge": "^4.0.1", "mkdirp": "^0.5.1", "ncp": "^2.0.0", diff --git a/tools/webpack.config.js b/tools/webpack.config.js index 7167e7250..1a02e110d 100644 --- a/tools/webpack.config.js +++ b/tools/webpack.config.js @@ -10,6 +10,7 @@ import path from 'path'; import webpack from 'webpack'; import merge from 'lodash.merge'; +import cloneDeep from 'lodash.clonedeep'; import AssetsPlugin from 'assets-webpack-plugin'; const DEBUG = !process.argv.includes('--release'); @@ -109,7 +110,7 @@ const config = { // Configuration for the client-side bundle (client.js) // ----------------------------------------------------------------------------- -const clientConfig = merge({}, config, { +const clientConfig = merge({}, cloneDeep(config), { entry: './src/client.js', output: { path: path.join(__dirname, '../build/public'), @@ -146,7 +147,7 @@ const clientConfig = merge({}, config, { // Configuration for the server-side bundle (server.js) // ----------------------------------------------------------------------------- -const serverConfig = merge({}, config, { +const serverConfig = merge({}, cloneDeep(config), { entry: './src/server.js', output: { path: './build', From 5470843f43958b0de59e550efa9c7805ee912ac5 Mon Sep 17 00:00:00 2001 From: nodkz Date: Thu, 21 Jan 2016 19:11:22 +0600 Subject: [PATCH 005/416] Change `lodash.merge` and `lodash.clonedeep` to `extend` module. --- package.json | 3 +-- tools/webpack.config.js | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8b1074b3d..cbc1eea06 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "eslint-config-airbnb": "^3.1.0", "eslint-loader": "^1.2.0", "eslint-plugin-react": "^3.15.0", + "extend": "^3.0.0", "file-loader": "^0.8.5", "gaze": "^0.5.2", "git-repository": "^0.1.1", @@ -51,8 +52,6 @@ "jest-cli": "^0.8.2", "jscs": "^2.8.0", "json-loader": "^0.5.4", - "lodash.clonedeep": "4.0.1", - "lodash.merge": "^4.0.1", "mkdirp": "^0.5.1", "ncp": "^2.0.0", "postcss": "^5.0.14", diff --git a/tools/webpack.config.js b/tools/webpack.config.js index 1a02e110d..415672a7e 100644 --- a/tools/webpack.config.js +++ b/tools/webpack.config.js @@ -9,8 +9,7 @@ import path from 'path'; import webpack from 'webpack'; -import merge from 'lodash.merge'; -import cloneDeep from 'lodash.clonedeep'; +import extend from 'extend'; import AssetsPlugin from 'assets-webpack-plugin'; const DEBUG = !process.argv.includes('--release'); @@ -110,7 +109,7 @@ const config = { // Configuration for the client-side bundle (client.js) // ----------------------------------------------------------------------------- -const clientConfig = merge({}, cloneDeep(config), { +const clientConfig = extend(true, {}, config, { entry: './src/client.js', output: { path: path.join(__dirname, '../build/public'), @@ -147,7 +146,7 @@ const clientConfig = merge({}, cloneDeep(config), { // Configuration for the server-side bundle (server.js) // ----------------------------------------------------------------------------- -const serverConfig = merge({}, cloneDeep(config), { +const serverConfig = extend(true, {}, config, { entry: './src/server.js', output: { path: './build', From b780ca4e2dc5a95ba1618479c3b78a1f463df64e Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus Date: Thu, 21 Jan 2016 22:54:33 +0300 Subject: [PATCH 006/416] Update HOC sample in docs/react-style-guide.md --- docs/react-style-guide.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/react-style-guide.md b/docs/react-style-guide.md index 6cb39617b..8408af694 100644 --- a/docs/react-style-guide.md +++ b/docs/react-style-guide.md @@ -120,8 +120,8 @@ Navigation.propTypes = { items: PropTypes.array.isRequired }; ```jsx // Navigation.js import React, { PropTypes } from 'react'; +import withStyles from 'isomorphic-style-loader/lib/withStyles'; import s from './Navigation.scss'; -import withStyles from '../../decorators/withStyles'; function Navigation() { return ( @@ -140,7 +140,7 @@ function Navigation() { Navigation.propTypes = { className: PropTypes.string }; -export default withStyles(s)(Navigation); +export default withStyles(Navigation, s); ``` ### Use higher-order components @@ -195,7 +195,6 @@ export default withViewport; import React from 'react'; import withViewport from './withViewport'; -@withViewport class MyComponent { render() { let { width, height } = this.props.viewport; @@ -203,7 +202,7 @@ class MyComponent { } } -export default MyComponent; +export default withViewport(MyComponent); ``` **[⬆ back to top](#table-of-contents)** From ad3147cd9ec7e2a971394f4df7d7519aa9297043 Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus Date: Mon, 25 Jan 2016 03:16:06 +0300 Subject: [PATCH 007/416] Fix ESLint, JSCS warnings Close kriasoft/react-starter-kit#417, kriasoft/react-starter-kit#418 --- src/components/TextBox/TextBox.js | 19 ++++++++++++++++--- tools/start.js | 7 +++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/TextBox/TextBox.js b/src/components/TextBox/TextBox.js index 67f57753b..a6ee74199 100644 --- a/src/components/TextBox/TextBox.js +++ b/src/components/TextBox/TextBox.js @@ -25,9 +25,22 @@ class TextBox extends Component { render() { return (
- {this.props.maxLines > 1 ? -