From 3f198332e1e007bb41f17fa467fc4c5ba00a73e2 Mon Sep 17 00:00:00 2001 From: Chris Landa Date: Sun, 26 Jun 2016 15:56:57 +0200 Subject: [PATCH 1/5] Initial commit for react-router-redux example --- examples/react-router-redux/.babelrc | 6 ++ examples/react-router-redux/.editorconfig | 12 +++ examples/react-router-redux/.eslintrc | 35 +++++++++ examples/react-router-redux/.gitignore | 30 ++++++++ examples/react-router-redux/.yo-rc.json | 8 ++ examples/react-router-redux/cfg/base.js | 42 ++++++++++ examples/react-router-redux/cfg/defaults.js | 64 ++++++++++++++++ examples/react-router-redux/cfg/dev.js | 39 ++++++++++ examples/react-router-redux/cfg/dist.js | 42 ++++++++++ examples/react-router-redux/cfg/test.js | 58 ++++++++++++++ examples/react-router-redux/dist/README.md | 2 + examples/react-router-redux/karma.conf.js | 36 +++++++++ examples/react-router-redux/package.json | 72 ++++++++++++++++++ examples/react-router-redux/server.js | 17 +++++ .../react-router-redux/src/actions/README.md | 14 ++++ .../react-router-redux/src/actions/const.js | 1 + .../react-router-redux/src/actions/index.js | 10 +++ .../react-router-redux/src/components/Main.js | 22 ++++++ .../react-router-redux/src/config/README.md | 17 +++++ .../react-router-redux/src/config/base.js | 5 ++ examples/react-router-redux/src/config/dev.js | 9 +++ .../react-router-redux/src/config/dist.js | 9 +++ .../react-router-redux/src/config/test.js | 9 +++ .../react-router-redux/src/containers/App.js | 41 ++++++++++ examples/react-router-redux/src/favicon.ico | Bin 0 -> 4286 bytes .../react-router-redux/src/images/yeoman.png | Bin 0 -> 13501 bytes examples/react-router-redux/src/index.html | 16 ++++ examples/react-router-redux/src/index.js | 14 ++++ .../react-router-redux/src/reducers/index.js | 12 +++ .../react-router-redux/src/sources/README.md | 14 ++++ .../react-router-redux/src/stores/README.md | 14 ++++ .../react-router-redux/src/stores/index.js | 16 ++++ .../react-router-redux/src/styles/App.css | 21 +++++ .../react-router-redux/test/actions/.keep | 0 .../test/components/MainTest.js | 23 ++++++ .../test/config/ConfigTest.js | 12 +++ .../test/helpers/shallowRenderHelper.js | 23 ++++++ examples/react-router-redux/test/loadtests.js | 8 ++ .../react-router-redux/test/sources/.keep | 0 examples/react-router-redux/test/stores/.keep | 0 examples/react-router-redux/webpack.config.js | 32 ++++++++ 41 files changed, 805 insertions(+) create mode 100644 examples/react-router-redux/.babelrc create mode 100644 examples/react-router-redux/.editorconfig create mode 100644 examples/react-router-redux/.eslintrc create mode 100644 examples/react-router-redux/.gitignore create mode 100644 examples/react-router-redux/.yo-rc.json create mode 100644 examples/react-router-redux/cfg/base.js create mode 100644 examples/react-router-redux/cfg/defaults.js create mode 100644 examples/react-router-redux/cfg/dev.js create mode 100644 examples/react-router-redux/cfg/dist.js create mode 100644 examples/react-router-redux/cfg/test.js create mode 100644 examples/react-router-redux/dist/README.md create mode 100644 examples/react-router-redux/karma.conf.js create mode 100644 examples/react-router-redux/package.json create mode 100644 examples/react-router-redux/server.js create mode 100644 examples/react-router-redux/src/actions/README.md create mode 100644 examples/react-router-redux/src/actions/const.js create mode 100644 examples/react-router-redux/src/actions/index.js create mode 100644 examples/react-router-redux/src/components/Main.js create mode 100644 examples/react-router-redux/src/config/README.md create mode 100644 examples/react-router-redux/src/config/base.js create mode 100644 examples/react-router-redux/src/config/dev.js create mode 100644 examples/react-router-redux/src/config/dist.js create mode 100644 examples/react-router-redux/src/config/test.js create mode 100644 examples/react-router-redux/src/containers/App.js create mode 100644 examples/react-router-redux/src/favicon.ico create mode 100644 examples/react-router-redux/src/images/yeoman.png create mode 100644 examples/react-router-redux/src/index.html create mode 100644 examples/react-router-redux/src/index.js create mode 100644 examples/react-router-redux/src/reducers/index.js create mode 100644 examples/react-router-redux/src/sources/README.md create mode 100644 examples/react-router-redux/src/stores/README.md create mode 100644 examples/react-router-redux/src/stores/index.js create mode 100644 examples/react-router-redux/src/styles/App.css create mode 100644 examples/react-router-redux/test/actions/.keep create mode 100644 examples/react-router-redux/test/components/MainTest.js create mode 100644 examples/react-router-redux/test/config/ConfigTest.js create mode 100644 examples/react-router-redux/test/helpers/shallowRenderHelper.js create mode 100644 examples/react-router-redux/test/loadtests.js create mode 100644 examples/react-router-redux/test/sources/.keep create mode 100644 examples/react-router-redux/test/stores/.keep create mode 100644 examples/react-router-redux/webpack.config.js diff --git a/examples/react-router-redux/.babelrc b/examples/react-router-redux/.babelrc new file mode 100644 index 0000000..bd20dc1 --- /dev/null +++ b/examples/react-router-redux/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "es2015", + "react" + ] +} diff --git a/examples/react-router-redux/.editorconfig b/examples/react-router-redux/.editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/examples/react-router-redux/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/examples/react-router-redux/.eslintrc b/examples/react-router-redux/.eslintrc new file mode 100644 index 0000000..b542daa --- /dev/null +++ b/examples/react-router-redux/.eslintrc @@ -0,0 +1,35 @@ +{ + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "env": { + "browser": true, + "amd": true, + "es6": true, + "node": true, + "mocha": true + }, + "rules": { + "comma-dangle": 1, + "quotes": [ 1, "single" ], + "no-undef": 1, + "global-strict": 0, + "no-extra-semi": 1, + "no-underscore-dangle": 0, + "no-console": 1, + "no-unused-vars": 1, + "no-trailing-spaces": [1, { "skipBlankLines": true }], + "no-unreachable": 1, + "no-alert": 0, + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1 + } +} diff --git a/examples/react-router-redux/.gitignore b/examples/react-router-redux/.gitignore new file mode 100644 index 0000000..7830694 --- /dev/null +++ b/examples/react-router-redux/.gitignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +node_modules + +# Bower +bower_components/ diff --git a/examples/react-router-redux/.yo-rc.json b/examples/react-router-redux/.yo-rc.json new file mode 100644 index 0000000..20cc7be --- /dev/null +++ b/examples/react-router-redux/.yo-rc.json @@ -0,0 +1,8 @@ +{ + "generator-react-webpack": { + "appName": "reactRouterRedux", + "style": "css", + "postcss": false, + "generatedWithVersion": 3 + } +} \ No newline at end of file diff --git a/examples/react-router-redux/cfg/base.js b/examples/react-router-redux/cfg/base.js new file mode 100644 index 0000000..37e1fcc --- /dev/null +++ b/examples/react-router-redux/cfg/base.js @@ -0,0 +1,42 @@ +'use strict'; +let path = require('path'); +let defaultSettings = require('./defaults'); + +// Additional npm or bower modules to include in builds +// Add all foreign plugins you may need into this array +// @example: +// let npmBase = path.join(__dirname, '../node_modules'); +// let additionalPaths = [ path.join(npmBase, 'react-bootstrap') ]; +let additionalPaths = []; + +module.exports = { + additionalPaths: additionalPaths, + port: defaultSettings.port, + debug: true, + devtool: 'eval', + output: { + path: path.join(__dirname, '/../dist/assets'), + filename: 'app.js', + publicPath: defaultSettings.publicPath + }, + devServer: { + contentBase: './src/', + historyApiFallback: true, + hot: true, + port: defaultSettings.port, + publicPath: defaultSettings.publicPath, + noInfo: false + }, + resolve: { + extensions: ['', '.js', '.jsx'], + alias: { + actions: `${defaultSettings.srcPath}/actions/`, + components: `${defaultSettings.srcPath}/components/`, + sources: `${defaultSettings.srcPath}/sources/`, + stores: `${defaultSettings.srcPath}/stores/`, + styles: `${defaultSettings.srcPath}/styles/`, + config: `${defaultSettings.srcPath}/config/` + process.env.REACT_WEBPACK_ENV + } + }, + module: {} +}; diff --git a/examples/react-router-redux/cfg/defaults.js b/examples/react-router-redux/cfg/defaults.js new file mode 100644 index 0000000..67a4328 --- /dev/null +++ b/examples/react-router-redux/cfg/defaults.js @@ -0,0 +1,64 @@ +/** + * Function that returns default values. + * Used because Object.assign does a shallow instead of a deep copy. + * Using [].push will add to the base array, so a require will alter + * the base array output. + */ +'use strict'; + +const path = require('path'); +const srcPath = path.join(__dirname, '/../src'); +const dfltPort = 8000; + +/** + * Get the default modules object for webpack + * @return {Object} + */ +function getDefaultModules() { + return { + preLoaders: [ + { + test: /\.(js|jsx)$/, + include: srcPath, + loader: 'eslint-loader' + } + ], + loaders: [ + { + test: /\.css$/, + loader: 'style-loader!css-loader' + }, + { + test: /\.sass/, + loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax' + }, + { + test: /\.scss/, + loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded' + }, + { + test: /\.less/, + loader: 'style-loader!css-loader!less-loader' + }, + { + test: /\.styl/, + loader: 'style-loader!css-loader!stylus-loader' + }, + { + test: /\.(png|jpg|gif|woff|woff2)$/, + loader: 'url-loader?limit=8192' + }, + { + test: /\.(mp4|ogg|svg)$/, + loader: 'file-loader' + } + ] + }; +} + +module.exports = { + srcPath: srcPath, + publicPath: '/assets/', + port: dfltPort, + getDefaultModules: getDefaultModules +}; diff --git a/examples/react-router-redux/cfg/dev.js b/examples/react-router-redux/cfg/dev.js new file mode 100644 index 0000000..6185d7b --- /dev/null +++ b/examples/react-router-redux/cfg/dev.js @@ -0,0 +1,39 @@ +'use strict'; + +let path = require('path'); +let webpack = require('webpack'); +let baseConfig = require('./base'); +let defaultSettings = require('./defaults'); + +// Add needed plugins here +let BowerWebpackPlugin = require('bower-webpack-plugin'); + +let config = Object.assign({}, baseConfig, { + entry: [ + 'webpack-dev-server/client?http://127.0.0.1:' + defaultSettings.port, + 'webpack/hot/only-dev-server', + './src/index' + ], + cache: true, + devtool: 'eval-source-map', + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new webpack.NoErrorsPlugin(), + new BowerWebpackPlugin({ + searchResolveModulesDirectories: false + }) + ], + module: defaultSettings.getDefaultModules() +}); + +// Add needed loaders to the defaults here +config.module.loaders.push({ + test: /\.(js|jsx)$/, + loader: 'react-hot!babel-loader', + include: [].concat( + config.additionalPaths, + [ path.join(__dirname, '/../src') ] + ) +}); + +module.exports = config; diff --git a/examples/react-router-redux/cfg/dist.js b/examples/react-router-redux/cfg/dist.js new file mode 100644 index 0000000..1fc19c4 --- /dev/null +++ b/examples/react-router-redux/cfg/dist.js @@ -0,0 +1,42 @@ +'use strict'; + +let path = require('path'); +let webpack = require('webpack'); + +let baseConfig = require('./base'); +let defaultSettings = require('./defaults'); + +// Add needed plugins here +let BowerWebpackPlugin = require('bower-webpack-plugin'); + +let config = Object.assign({}, baseConfig, { + entry: path.join(__dirname, '../src/index'), + cache: false, + devtool: 'sourcemap', + plugins: [ + new webpack.optimize.DedupePlugin(), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': '"production"' + }), + new BowerWebpackPlugin({ + searchResolveModulesDirectories: false + }), + new webpack.optimize.UglifyJsPlugin(), + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.optimize.AggressiveMergingPlugin(), + new webpack.NoErrorsPlugin() + ], + module: defaultSettings.getDefaultModules() +}); + +// Add needed loaders to the defaults here +config.module.loaders.push({ + test: /\.(js|jsx)$/, + loader: 'babel', + include: [].concat( + config.additionalPaths, + [ path.join(__dirname, '/../src') ] + ) +}); + +module.exports = config; diff --git a/examples/react-router-redux/cfg/test.js b/examples/react-router-redux/cfg/test.js new file mode 100644 index 0000000..f139c49 --- /dev/null +++ b/examples/react-router-redux/cfg/test.js @@ -0,0 +1,58 @@ +'use strict'; + +let path = require('path'); +let srcPath = path.join(__dirname, '/../src/'); + +let baseConfig = require('./base'); + +// Add needed plugins here +let BowerWebpackPlugin = require('bower-webpack-plugin'); + +module.exports = { + devtool: 'eval', + module: { + preLoaders: [ + { + test: /\.(js|jsx)$/, + loader: 'isparta-instrumenter-loader', + include: [ + path.join(__dirname, '/../src') + ] + } + ], + loaders: [ + { + test: /\.(png|jpg|gif|woff|woff2|css|sass|scss|less|styl)$/, + loader: 'null-loader' + }, + { + test: /\.(js|jsx)$/, + loader: 'babel-loader', + include: [].concat( + baseConfig.additionalPaths, + [ + path.join(__dirname, '/../src'), + path.join(__dirname, '/../test') + ] + ) + } + ] + }, + resolve: { + extensions: [ '', '.js', '.jsx' ], + alias: { + actions: srcPath + 'actions/', + helpers: path.join(__dirname, '/../test/helpers'), + components: srcPath + 'components/', + sources: srcPath + 'sources/', + stores: srcPath + 'stores/', + styles: srcPath + 'styles/', + config: srcPath + 'config/' + process.env.REACT_WEBPACK_ENV + } + }, + plugins: [ + new BowerWebpackPlugin({ + searchResolveModulesDirectories: false + }) + ] +}; diff --git a/examples/react-router-redux/dist/README.md b/examples/react-router-redux/dist/README.md new file mode 100644 index 0000000..0d138c2 --- /dev/null +++ b/examples/react-router-redux/dist/README.md @@ -0,0 +1,2 @@ +# About the dist folder +After building the dist version of your project, the generated files are stored in this folder. You should keep it under version control. diff --git a/examples/react-router-redux/karma.conf.js b/examples/react-router-redux/karma.conf.js new file mode 100644 index 0000000..87401bf --- /dev/null +++ b/examples/react-router-redux/karma.conf.js @@ -0,0 +1,36 @@ +var webpackCfg = require('./webpack.config'); + +// Set node environment to testing +process.env.NODE_ENV = 'test'; + +module.exports = function(config) { + config.set({ + basePath: '', + browsers: [ 'PhantomJS' ], + files: [ + 'test/loadtests.js' + ], + port: 8000, + captureTimeout: 60000, + frameworks: [ 'mocha', 'chai' ], + client: { + mocha: {} + }, + singleRun: true, + reporters: [ 'mocha', 'coverage' ], + preprocessors: { + 'test/loadtests.js': [ 'webpack', 'sourcemap' ] + }, + webpack: webpackCfg, + webpackServer: { + noInfo: true + }, + coverageReporter: { + dir: 'coverage/', + reporters: [ + { type: 'html' }, + { type: 'text' } + ] + } + }); +}; diff --git a/examples/react-router-redux/package.json b/examples/react-router-redux/package.json new file mode 100644 index 0000000..2f7f4e1 --- /dev/null +++ b/examples/react-router-redux/package.json @@ -0,0 +1,72 @@ +{ + "name": "reactRouterRedux", + "private": true, + "version": "0.0.1", + "description": "YOUR DESCRIPTION - Generated by generator-react-webpack", + "main": "", + "scripts": { + "clean": "rimraf dist/*", + "copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist", + "dist": "npm run copy & webpack --env=dist", + "lint": "eslint ./src", + "posttest": "npm run lint", + "release:major": "npm version major && npm publish && git push --follow-tags", + "release:minor": "npm version minor && npm publish && git push --follow-tags", + "release:patch": "npm version patch && npm publish && git push --follow-tags", + "serve": "node server.js --env=dev", + "serve:dist": "node server.js --env=dist", + "start": "node server.js --env=dev", + "test": "karma start", + "test:watch": "karma start --autoWatch=true --singleRun=false" + }, + "repository": "", + "keywords": [], + "author": "Your name here", + "devDependencies": { + "babel-core": "^6.0.0", + "babel-eslint": "^6.0.0", + "babel-loader": "^6.0.0", + "babel-polyfill": "^6.3.14", + "babel-preset-es2015": "^6.0.15", + "babel-preset-react": "^6.0.15", + "bower-webpack-plugin": "^0.1.9", + "chai": "^3.2.0", + "copyfiles": "^0.2.1", + "css-loader": "^0.23.0", + "eslint": "^2.2.0", + "eslint-loader": "^1.0.0", + "eslint-plugin-react": "^5.0.0", + "file-loader": "^0.8.4", + "glob": "^7.0.0", + "isparta-instrumenter-loader": "^1.0.0", + "karma": "^0.13.9", + "karma-chai": "^0.1.0", + "karma-coverage": "^1.0.0", + "karma-mocha": "^1.0.0", + "karma-mocha-reporter": "^2.0.0", + "karma-phantomjs-launcher": "^1.0.0", + "karma-sourcemap-loader": "^0.3.5", + "karma-webpack": "^1.7.0", + "minimist": "^1.2.0", + "mocha": "^2.2.5", + "null-loader": "^0.1.1", + "open": "0.0.5", + "phantomjs-prebuilt": "^2.0.0", + "react-addons-test-utils": "^15.0.0", + "react-hot-loader": "^1.2.9", + "rimraf": "^2.4.3", + "style-loader": "^0.13.0", + "url-loader": "^0.5.6", + "webpack": "^1.12.0", + "webpack-dev-server": "^1.12.0" + }, + "dependencies": { + "core-js": "^2.0.0", + "normalize.css": "^4.0.0", + "react": "^15.0.0", + "react-dom": "^15.0.0", + "react-redux": "^4.4.5", + "react-router-redux": "^4.0.5", + "redux": "^3.5.2" + } +} diff --git a/examples/react-router-redux/server.js b/examples/react-router-redux/server.js new file mode 100644 index 0000000..9fd4659 --- /dev/null +++ b/examples/react-router-redux/server.js @@ -0,0 +1,17 @@ +/*eslint no-console:0 */ +'use strict'; +require('core-js/fn/object/assign'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const config = require('./webpack.config'); +const open = require('open'); + +new WebpackDevServer(webpack(config), config.devServer) +.listen(config.port, 'localhost', (err) => { + if (err) { + console.log(err); + } + console.log('Listening at localhost:' + config.port); + console.log('Opening your system browser...'); + open('http://localhost:' + config.port + '/webpack-dev-server/'); +}); diff --git a/examples/react-router-redux/src/actions/README.md b/examples/react-router-redux/src/actions/README.md new file mode 100644 index 0000000..7267347 --- /dev/null +++ b/examples/react-router-redux/src/actions/README.md @@ -0,0 +1,14 @@ +# About this folder +This folder will hold all of your **flux** actions if you are using flux. +You can include actions into your components or stores like this: + +```javascript +let react = require('react/addons'); +let MyAction = require('actions/MyAction'); +class MyComponent extends React.Component { + constructor(props) { + super(props); + MyAction.exampleMethod(); + } +} +``` diff --git a/examples/react-router-redux/src/actions/const.js b/examples/react-router-redux/src/actions/const.js new file mode 100644 index 0000000..6880f7d --- /dev/null +++ b/examples/react-router-redux/src/actions/const.js @@ -0,0 +1 @@ +/* Populated by react-webpack-redux:action */ diff --git a/examples/react-router-redux/src/actions/index.js b/examples/react-router-redux/src/actions/index.js new file mode 100644 index 0000000..d7b9796 --- /dev/null +++ b/examples/react-router-redux/src/actions/index.js @@ -0,0 +1,10 @@ +/* Exports all the actions from a single point. + +Allows to import actions like so: + +import {action1, action2} from '../actions/' + +Populated by react-webpack-redux:action +*/ +const actions = {}; +module.exports = actions; diff --git a/examples/react-router-redux/src/components/Main.js b/examples/react-router-redux/src/components/Main.js new file mode 100644 index 0000000..9c404ac --- /dev/null +++ b/examples/react-router-redux/src/components/Main.js @@ -0,0 +1,22 @@ +require('normalize.css/normalize.css'); +require('styles/App.css'); + +import React from 'react'; + +let yeomanImage = require('../images/yeoman.png'); + +class AppComponent extends React.Component { + render() { + return ( +
+ Yeoman Generator +
Please edit src/components/Main.js to get started!
+
+ ); + } +} + +AppComponent.defaultProps = { +}; + +export default AppComponent; diff --git a/examples/react-router-redux/src/config/README.md b/examples/react-router-redux/src/config/README.md new file mode 100644 index 0000000..099c59b --- /dev/null +++ b/examples/react-router-redux/src/config/README.md @@ -0,0 +1,17 @@ +# About this folder +This folder holds configuration files for different environments. +You can use it to provide your app with different settings based on the +current environment, e.g. to configure different API base urls depending on +whether your setup runs in dev mode or is built for distribution. +You can include the configuration into your code like this: + +```javascript +let react = require('react/addons'); +let config = require('config'); +class MyComponent extends React.Component { + constructor(props) { + super(props); + let currentAppEnv = config.appEnv; + } +} +``` diff --git a/examples/react-router-redux/src/config/base.js b/examples/react-router-redux/src/config/base.js new file mode 100644 index 0000000..65b6aff --- /dev/null +++ b/examples/react-router-redux/src/config/base.js @@ -0,0 +1,5 @@ +'use strict'; + +// Settings configured here will be merged into the final config object. +export default { +} diff --git a/examples/react-router-redux/src/config/dev.js b/examples/react-router-redux/src/config/dev.js new file mode 100644 index 0000000..09f544c --- /dev/null +++ b/examples/react-router-redux/src/config/dev.js @@ -0,0 +1,9 @@ +'use strict'; + +import baseConfig from './base'; + +let config = { + appEnv: 'dev' // feel free to remove the appEnv property here +}; + +export default Object.freeze(Object.assign({}, baseConfig, config)); diff --git a/examples/react-router-redux/src/config/dist.js b/examples/react-router-redux/src/config/dist.js new file mode 100644 index 0000000..e9cc29d --- /dev/null +++ b/examples/react-router-redux/src/config/dist.js @@ -0,0 +1,9 @@ +'use strict'; + +import baseConfig from './base'; + +let config = { + appEnv: 'dist' // feel free to remove the appEnv property here +}; + +export default Object.freeze(Object.assign({}, baseConfig, config)); diff --git a/examples/react-router-redux/src/config/test.js b/examples/react-router-redux/src/config/test.js new file mode 100644 index 0000000..3d17b75 --- /dev/null +++ b/examples/react-router-redux/src/config/test.js @@ -0,0 +1,9 @@ +'use strict'; + +import baseConfig from './base'; + +let config = { + appEnv: 'test' // don't remove the appEnv property here +}; + +export default Object.freeze(Object.assign(baseConfig, config)); diff --git a/examples/react-router-redux/src/containers/App.js b/examples/react-router-redux/src/containers/App.js new file mode 100644 index 0000000..bda5720 --- /dev/null +++ b/examples/react-router-redux/src/containers/App.js @@ -0,0 +1,41 @@ +/* CAUTION: When using the generators, this file is modified in some places. + * This is done via AST traversal - Some of your formatting may be lost + * in the process - no functionality should be broken though. + * This modifications only run once when the generator is invoked - if + * you edit them, they are not updated again. + */ +import React, { + Component, + PropTypes +} from 'react'; +import {} from '../actions/'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; +import Main from '../components/Main'; +/* Populated by react-webpack-redux:reducer */ +class App extends Component { + render() { + const {actions} = this.props; + return
; + } +} +/* Populated by react-webpack-redux:reducer + * + * HINT: if you adjust the initial type of your reducer, you will also have to + * adjust it here. + */ +App.propTypes = { + actions: PropTypes.object.isRequired +}; +function mapStateToProps(state) { + /* Populated by react-webpack-redux:reducer */ + const props = {}; + return props; +} +function mapDispatchToProps(dispatch) { + /* Populated by react-webpack-redux:action */ + const actions = {}; + const actionMap = { actions: bindActionCreators(actions, dispatch) }; + return actionMap; +} +export default connect(mapStateToProps, mapDispatchToProps)(App); diff --git a/examples/react-router-redux/src/favicon.ico b/examples/react-router-redux/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..6527905307f19ba00762f9241f7eb535fa84a2f9 GIT binary patch literal 4286 zcmchaPe@cz6vpqQW1y54B@{_hhFD-kWPgyXjSGVaf);_51TESOlSPOdvy}@W5Q+** zs6~RrtlR}7(V|sCkP&1f7!5{Hixw@4+x@+HXSm*Z^WGalm2d8S=brO@=iGm9MyZ7P zPo)%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~JcKWUBjG=jr>;wjN|u4UnPuQ#%s#;L91jv*)j%CU1^V_Qw0#xQeh>Ey9M?1&0pA9G z9+WP^A8g%%G9<=seP>w!^T@n!pw4*U-HQ4@!ur9#h)4~;Cqm9w&TP} zOu|?vetR}LM5VY)4+0ORhW(-iO6iZn(E{y)L##lwgHuSD%$xA@@yCik@sWNh`vw0wIIcO5I%Rfa z&Ta`g$k+*rTp5s^0&%9<%*JOT{za&vF6X;1?x0u}S*q+rgb9Zuem3eBBW%IZ&g46o z^N|KmUF4+CyW|%GCw2Q9==84;e+u!Ph~r%-Ydna2B7CYV!i8{D8O6Z=8Q`ixnEf~m zajrFMv2nc`c+Lc#ClDumGaipOBcC7eR-0R-%|(0>;+vpq-a{Ir9EGg3ISQU1X_ z)j_*Yz|C~((4+cv+o9yBzM;&G%mn_E99&ABIrvpMr015uf#q|oMz_x?jum*WV?F_l zn&IFa93#sh?cb4233lt|;#d7aKG$JISC)6mK7cgBZi3>@`fPUo-vAn)fh=5);AifY z1mMLnqYr<^WZSSR2Ff0ca_j^d#yioRB|`xDY}bQX#MwwmA`rJ)K;c({AhR&*sfO^U z46Ig2DOE@t9KkJ%KVRTG1o${Gwx^^Mc$*P!hodOZffThMNW%b8-;6xvnNQrzXa9+x zeN^-Tz9xh_;0SIRwKidV_&anq$Fd!H-N?k1x83^V;#c?-7SIOFnF~4&fR67Vjd@C) zIQa*Jm)l_yn1tCAFmG@9x%G&5IPTp1;o;n}!}Az_ul#&4?d}VWS<%U^5-)v#W**CX;EVD1|<>F<3hR2aK1okDL74wbJ#j&@%A&okC r_B5{HWj~64M1hYe@DT+*>=gL_d-r`<6cl&$00000NkvXXu0mjfZzoN6 literal 0 HcmV?d00001 diff --git a/examples/react-router-redux/src/index.html b/examples/react-router-redux/src/index.html new file mode 100644 index 0000000..a52dafe --- /dev/null +++ b/examples/react-router-redux/src/index.html @@ -0,0 +1,16 @@ + + + + + React Webpack Template Title + + + + + +
APPLICATION CONTENT
+ + + + + diff --git a/examples/react-router-redux/src/index.js b/examples/react-router-redux/src/index.js new file mode 100644 index 0000000..e600e9d --- /dev/null +++ b/examples/react-router-redux/src/index.js @@ -0,0 +1,14 @@ +import React from 'react'; +import { render } from 'react-dom'; +import { Provider } from 'react-redux'; +import configureStore from './stores'; +import App from './containers/App'; + +const store = configureStore(); + +render( + + + , + document.getElementById('app') +); diff --git a/examples/react-router-redux/src/reducers/index.js b/examples/react-router-redux/src/reducers/index.js new file mode 100644 index 0000000..bd1834b --- /dev/null +++ b/examples/react-router-redux/src/reducers/index.js @@ -0,0 +1,12 @@ +/* Combine all available reducers to a single root reducer. + * + * CAUTION: When using the generators, this file is modified in some places. + * This is done via AST traversal - Some of your formatting may be lost + * in the process - no functionality should be broken though. + * This modifications only run once when the generator is invoked - if + * you edit them, they are not updated again. + */ +import { combineReducers } from 'redux'; +/* Populated by react-webpack-redux:reducer */ +const reducers = {}; +module.exports = combineReducers(reducers); diff --git a/examples/react-router-redux/src/sources/README.md b/examples/react-router-redux/src/sources/README.md new file mode 100644 index 0000000..9f929ae --- /dev/null +++ b/examples/react-router-redux/src/sources/README.md @@ -0,0 +1,14 @@ +# About this folder +This folder will hold all of your **flux** datasources. +You can include them into your components or stores like this: + +```javascript +let react = require('react/addons'); +let MySource = require('sources/MyAction'); +class MyComponent extends React.Component { + constructor(props) { + super(props); + MySource.getRemoteData(); + } +} +``` diff --git a/examples/react-router-redux/src/stores/README.md b/examples/react-router-redux/src/stores/README.md new file mode 100644 index 0000000..5ee1aeb --- /dev/null +++ b/examples/react-router-redux/src/stores/README.md @@ -0,0 +1,14 @@ +# About this folder +This folder will hold all of your **flux** stores. +You can include them into your components like this: + +```javascript +let react = require('react/addons'); +let MyStore = require('stores/MyStore'); +class MyComponent extends React.Component { + constructor(props) { + super(props); + MyStore.doSomething(); + } +} +``` diff --git a/examples/react-router-redux/src/stores/index.js b/examples/react-router-redux/src/stores/index.js new file mode 100644 index 0000000..1623090 --- /dev/null +++ b/examples/react-router-redux/src/stores/index.js @@ -0,0 +1,16 @@ +const redux = require('redux'); +const reducers = require('../reducers'); + +module.exports = function(initialState) { + const store = redux.createStore(reducers, initialState) + + if (module.hot) { + // Enable Webpack hot module replacement for reducers + module.hot.accept('../reducers', () => { + const nextReducer = require('../reducers') + store.replaceReducer(nextReducer) + }) + } + + return store +} diff --git a/examples/react-router-redux/src/styles/App.css b/examples/react-router-redux/src/styles/App.css new file mode 100644 index 0000000..0a0ccc4 --- /dev/null +++ b/examples/react-router-redux/src/styles/App.css @@ -0,0 +1,21 @@ +/* Base Application Styles */ +body { + color: #fff; + background: #222; +} + +.index img { + margin: 40px auto; + border-radius: 4px; + background: #fff; + display: block; +} + +.index .notice { + margin: 20px auto; + padding: 15px 0; + text-align: center; + border: 1px solid #000; + border-width: 1px 0; + background: #666; +} diff --git a/examples/react-router-redux/test/actions/.keep b/examples/react-router-redux/test/actions/.keep new file mode 100644 index 0000000..e69de29 diff --git a/examples/react-router-redux/test/components/MainTest.js b/examples/react-router-redux/test/components/MainTest.js new file mode 100644 index 0000000..a56889e --- /dev/null +++ b/examples/react-router-redux/test/components/MainTest.js @@ -0,0 +1,23 @@ +/*eslint-env node, mocha */ +/*global expect */ +/*eslint no-console: 0*/ +'use strict'; + +// Uncomment the following lines to use the react test utilities +// import React from 'react/addons'; +// const TestUtils = React.addons.TestUtils; +import createComponent from 'helpers/shallowRenderHelper'; + +import Main from 'components/Main'; + +describe('MainComponent', () => { + let MainComponent; + + beforeEach(() => { + MainComponent = createComponent(Main); + }); + + it('should have its component name as default className', () => { + expect(MainComponent.props.className).to.equal('index'); + }); +}); diff --git a/examples/react-router-redux/test/config/ConfigTest.js b/examples/react-router-redux/test/config/ConfigTest.js new file mode 100644 index 0000000..7c9d35b --- /dev/null +++ b/examples/react-router-redux/test/config/ConfigTest.js @@ -0,0 +1,12 @@ +/*eslint-env node, mocha */ +/*global expect */ +/*eslint no-console: 0*/ +'use strict'; + +import config from 'config'; + +describe('appEnvConfigTests', () => { + it('should load app config file depending on current --env', () => { + expect(config.appEnv).to.equal('test'); + }); +}); diff --git a/examples/react-router-redux/test/helpers/shallowRenderHelper.js b/examples/react-router-redux/test/helpers/shallowRenderHelper.js new file mode 100644 index 0000000..e8cc1d4 --- /dev/null +++ b/examples/react-router-redux/test/helpers/shallowRenderHelper.js @@ -0,0 +1,23 @@ +/** + * Function to get the shallow output for a given component + * As we are using phantom.js, we also need to include the fn.proto.bind shim! + * + * @see http://simonsmith.io/unit-testing-react-components-without-a-dom/ + * @author somonsmith + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +/** + * Get the shallow rendered component + * + * @param {Object} component The component to return the output for + * @param {Object} props [optional] The components properties + * @param {Mixed} ...children [optional] List of children + * @return {Object} Shallow rendered output + */ +export default function createComponent(component, props = {}, ...children) { + const shallowRenderer = TestUtils.createRenderer(); + shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0])); + return shallowRenderer.getRenderOutput(); +} diff --git a/examples/react-router-redux/test/loadtests.js b/examples/react-router-redux/test/loadtests.js new file mode 100644 index 0000000..6e80a96 --- /dev/null +++ b/examples/react-router-redux/test/loadtests.js @@ -0,0 +1,8 @@ +'use strict'; + +require('babel-polyfill'); +require('core-js/fn/object/assign'); + +// Add support for all files in the test directory +const testsContext = require.context('.', true, /(Test\.js$)|(Helper\.js$)/); +testsContext.keys().forEach(testsContext); diff --git a/examples/react-router-redux/test/sources/.keep b/examples/react-router-redux/test/sources/.keep new file mode 100644 index 0000000..e69de29 diff --git a/examples/react-router-redux/test/stores/.keep b/examples/react-router-redux/test/stores/.keep new file mode 100644 index 0000000..e69de29 diff --git a/examples/react-router-redux/webpack.config.js b/examples/react-router-redux/webpack.config.js new file mode 100644 index 0000000..6b6a939 --- /dev/null +++ b/examples/react-router-redux/webpack.config.js @@ -0,0 +1,32 @@ +'use strict'; + +const path = require('path'); +const args = require('minimist')(process.argv.slice(2)); + +// List of allowed environments +const allowedEnvs = ['dev', 'dist', 'test']; + +// Set the correct environment +let env; +if (args._.length > 0 && args._.indexOf('start') !== -1) { + env = 'test'; +} else if (args.env) { + env = args.env; +} else { + env = 'dev'; +} +process.env.REACT_WEBPACK_ENV = env; + +/** + * Build the webpack configuration + * @param {String} wantedEnv The wanted environment + * @return {Object} Webpack config + */ +function buildConfig(wantedEnv) { + let isValid = wantedEnv && wantedEnv.length > 0 && allowedEnvs.indexOf(wantedEnv) !== -1; + let validEnv = isValid ? wantedEnv : 'dev'; + let config = require(path.join(__dirname, 'cfg/' + validEnv)); + return config; +} + +module.exports = buildConfig(env); From fff9d0cc266583c1d2a7140121260123557a8272 Mon Sep 17 00:00:00 2001 From: Chris Landa Date: Sun, 26 Jun 2016 18:59:53 +0200 Subject: [PATCH 2/5] react-router-redux example The router is the next element directly after the provider. Every route is a container connected to the reducer and action dispatcher. Routes are defined in routes.js. The route containers dispatch actions and props to their child components. --- .../react-router-redux/src/actions/const.js | 1 + .../react-router-redux/src/actions/index.js | 2 +- .../react-router-redux/src/actions/login.js | 5 +++ .../src/components/LoginComponent.js | 32 +++++++++++++++++ .../react-router-redux/src/components/Main.js | 3 +- .../src/components/SelfComponent.js | 27 ++++++++++++++ .../react-router-redux/src/containers/App.js | 16 +++++---- .../src/containers/routes/Index.js | 36 +++++++++++++++++++ .../src/containers/routes/Self.js | 31 ++++++++++++++++ examples/react-router-redux/src/index.js | 8 +++-- .../react-router-redux/src/reducers/index.js | 6 +++- .../react-router-redux/src/reducers/user.js | 27 ++++++++++++++ examples/react-router-redux/src/routes.js | 17 +++++++++ .../react-router-redux/src/styles/Login.css | 3 ++ .../react-router-redux/src/styles/Self.css | 3 ++ .../src/styles/routes/Index.css | 3 ++ .../test/components/LoginComponentTest.js | 22 ++++++++++++ .../test/components/SelfComponentTest.js | 22 ++++++++++++ .../components/routes/IndexComponentTest.js | 22 ++++++++++++ .../test/reducers/userTest.js | 12 +++++++ 20 files changed, 287 insertions(+), 11 deletions(-) create mode 100644 examples/react-router-redux/src/actions/login.js create mode 100644 examples/react-router-redux/src/components/LoginComponent.js create mode 100644 examples/react-router-redux/src/components/SelfComponent.js create mode 100644 examples/react-router-redux/src/containers/routes/Index.js create mode 100644 examples/react-router-redux/src/containers/routes/Self.js create mode 100644 examples/react-router-redux/src/reducers/user.js create mode 100644 examples/react-router-redux/src/routes.js create mode 100644 examples/react-router-redux/src/styles/Login.css create mode 100644 examples/react-router-redux/src/styles/Self.css create mode 100644 examples/react-router-redux/src/styles/routes/Index.css create mode 100644 examples/react-router-redux/test/components/LoginComponentTest.js create mode 100644 examples/react-router-redux/test/components/SelfComponentTest.js create mode 100644 examples/react-router-redux/test/components/routes/IndexComponentTest.js create mode 100644 examples/react-router-redux/test/reducers/userTest.js diff --git a/examples/react-router-redux/src/actions/const.js b/examples/react-router-redux/src/actions/const.js index 6880f7d..2d4bee4 100644 --- a/examples/react-router-redux/src/actions/const.js +++ b/examples/react-router-redux/src/actions/const.js @@ -1 +1,2 @@ /* Populated by react-webpack-redux:action */ +export const LOGIN = 'LOGIN'; diff --git a/examples/react-router-redux/src/actions/index.js b/examples/react-router-redux/src/actions/index.js index d7b9796..938d95d 100644 --- a/examples/react-router-redux/src/actions/index.js +++ b/examples/react-router-redux/src/actions/index.js @@ -6,5 +6,5 @@ import {action1, action2} from '../actions/' Populated by react-webpack-redux:action */ -const actions = {}; +const actions = { login: require('../actions/login.js') }; module.exports = actions; diff --git a/examples/react-router-redux/src/actions/login.js b/examples/react-router-redux/src/actions/login.js new file mode 100644 index 0000000..fcc6a46 --- /dev/null +++ b/examples/react-router-redux/src/actions/login.js @@ -0,0 +1,5 @@ +import {LOGIN} from './const'; + +module.exports = function(parameter) { + return { type: LOGIN, parameter }; +}; diff --git a/examples/react-router-redux/src/components/LoginComponent.js b/examples/react-router-redux/src/components/LoginComponent.js new file mode 100644 index 0000000..2f9342a --- /dev/null +++ b/examples/react-router-redux/src/components/LoginComponent.js @@ -0,0 +1,32 @@ +'use strict'; + +import React, { + PropTypes +} from 'react'; +import { Link } from 'react-router'; + +require('styles//Login.css'); + +class LoginComponent extends React.Component { + render() { + let elem = ; + if(this.props.loggedIn) { + elem = Member Area; + } + + return ( +
+ {elem} +
+ ); + } +} + +LoginComponent.displayName = 'LoginComponent'; + +LoginComponent.propTypes = { + login: PropTypes.func.isRequired, + loggedIn: PropTypes.bool.isRequired +}; + +export default LoginComponent; diff --git a/examples/react-router-redux/src/components/Main.js b/examples/react-router-redux/src/components/Main.js index 9c404ac..4b8e685 100644 --- a/examples/react-router-redux/src/components/Main.js +++ b/examples/react-router-redux/src/components/Main.js @@ -2,6 +2,7 @@ require('normalize.css/normalize.css'); require('styles/App.css'); import React from 'react'; +import { Link } from 'react-router'; let yeomanImage = require('../images/yeoman.png'); @@ -10,7 +11,7 @@ class AppComponent extends React.Component { return (
Yeoman Generator -
Please edit src/components/Main.js to get started!
+
react-router-redux example
); } diff --git a/examples/react-router-redux/src/components/SelfComponent.js b/examples/react-router-redux/src/components/SelfComponent.js new file mode 100644 index 0000000..afd8a00 --- /dev/null +++ b/examples/react-router-redux/src/components/SelfComponent.js @@ -0,0 +1,27 @@ +'use strict'; + +import React, { PropTypes } from 'react'; + +require('styles//Self.css'); + +class SelfComponent extends React.Component { + render() { + let elem =

Not logged in!

; + if(this.props.login) elem =

You are logged in

; + return ( +
+ {elem} +
+ ); + } +} + +SelfComponent.displayName = 'SelfComponent'; + +// Uncomment properties you need +SelfComponent.propTypes = { + login: PropTypes.bool.isRequired +}; +// SelfComponent.defaultProps = {}; + +export default SelfComponent; diff --git a/examples/react-router-redux/src/containers/App.js b/examples/react-router-redux/src/containers/App.js index bda5720..29a1994 100644 --- a/examples/react-router-redux/src/containers/App.js +++ b/examples/react-router-redux/src/containers/App.js @@ -8,15 +8,17 @@ import React, { Component, PropTypes } from 'react'; -import {} from '../actions/'; +import { login } from '../actions/'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import Main from '../components/Main'; /* Populated by react-webpack-redux:reducer */ class App extends Component { render() { - const {actions} = this.props; - return
; + const {actions, user} = this.props; + return ( +
+ ); } } /* Populated by react-webpack-redux:reducer @@ -25,16 +27,18 @@ class App extends Component { * adjust it here. */ App.propTypes = { - actions: PropTypes.object.isRequired + actions: PropTypes.object.isRequired, + history: PropTypes.object.isRequired, + user: PropTypes.object.isRequired }; function mapStateToProps(state) { /* Populated by react-webpack-redux:reducer */ - const props = {}; + const props = { user: state.user }; return props; } function mapDispatchToProps(dispatch) { /* Populated by react-webpack-redux:action */ - const actions = {}; + const actions = { login }; const actionMap = { actions: bindActionCreators(actions, dispatch) }; return actionMap; } diff --git a/examples/react-router-redux/src/containers/routes/Index.js b/examples/react-router-redux/src/containers/routes/Index.js new file mode 100644 index 0000000..ddb9432 --- /dev/null +++ b/examples/react-router-redux/src/containers/routes/Index.js @@ -0,0 +1,36 @@ +'use strict'; + +import React from 'react'; +import { login } from '../../actions/'; +import { bindActionCreators } from 'redux'; + +import { connect } from 'react-redux'; +import LoginComponent from '../../components/LoginComponent'; + +require('styles/routes/Index.css'); + +class Index extends React.Component { + render() { + return ( + + ); + } +} + +Index.displayName = 'RoutesIndex'; + +function mapStateToProps(state) { + const props = { user: state.user }; + return props; +} + +function mapDispatchToProps(dispatch) { + const actions = { login }; + const actionMap = { actions: bindActionCreators(actions, dispatch) }; + return actionMap; +} + +export default connect(mapStateToProps, mapDispatchToProps)(Index); diff --git a/examples/react-router-redux/src/containers/routes/Self.js b/examples/react-router-redux/src/containers/routes/Self.js new file mode 100644 index 0000000..41faa44 --- /dev/null +++ b/examples/react-router-redux/src/containers/routes/Self.js @@ -0,0 +1,31 @@ +import React, { + Component, + PropTypes +} from 'react'; +import {} from '../../actions/'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; +import SelfComponent from '../../components/SelfComponent'; + +class Self extends Component { + render() { + return ; + } +} + +self.propTypes = { + actions: PropTypes.object.isRequired +}; + +function mapStateToProps(state) { + const props = { user: state.user }; + return props; +} + +function mapDispatchToProps(dispatch) { + const actions = {}; + const actionMap = { actions: bindActionCreators(actions, dispatch) }; + return actionMap; +} + +export default connect(mapStateToProps, mapDispatchToProps)(Self); diff --git a/examples/react-router-redux/src/index.js b/examples/react-router-redux/src/index.js index e600e9d..f088b48 100644 --- a/examples/react-router-redux/src/index.js +++ b/examples/react-router-redux/src/index.js @@ -1,14 +1,18 @@ import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; +import { browserHistory } from 'react-router'; +import { syncHistoryWithStore } from 'react-router-redux' import configureStore from './stores'; -import App from './containers/App'; +import { Router } from 'react-router'; +import routes from './routes'; const store = configureStore(); +const history = syncHistoryWithStore(browserHistory, store); render( - + , document.getElementById('app') ); diff --git a/examples/react-router-redux/src/reducers/index.js b/examples/react-router-redux/src/reducers/index.js index bd1834b..0fef3c0 100644 --- a/examples/react-router-redux/src/reducers/index.js +++ b/examples/react-router-redux/src/reducers/index.js @@ -7,6 +7,10 @@ * you edit them, they are not updated again. */ import { combineReducers } from 'redux'; +import { routerReducer } from 'react-router-redux'; /* Populated by react-webpack-redux:reducer */ -const reducers = {}; +const reducers = { + routing: routerReducer, + user: require('../reducers/user.js') +}; module.exports = combineReducers(reducers); diff --git a/examples/react-router-redux/src/reducers/user.js b/examples/react-router-redux/src/reducers/user.js new file mode 100644 index 0000000..aaa024a --- /dev/null +++ b/examples/react-router-redux/src/reducers/user.js @@ -0,0 +1,27 @@ +import {LOGIN} from '../actions/const'; + +/* Define your initial state here. + * + * If you change the type from object to something else, do not forget to update + * src/container/App.js accordingly. + */ +const initialState = { + login: false +}; + +module.exports = function(state = initialState, action) { + /* Keep the reducer clean - do not mutate the original state. */ + let nextState = Object.assign({}, state); + + switch(action.type) { + case LOGIN: { + nextState.login = true; + return nextState; + } + + default: { + /* Return original state if no actions were consumed. */ + return state; + } + } +} diff --git a/examples/react-router-redux/src/routes.js b/examples/react-router-redux/src/routes.js new file mode 100644 index 0000000..7490b05 --- /dev/null +++ b/examples/react-router-redux/src/routes.js @@ -0,0 +1,17 @@ +import Index from './containers/routes/Index'; +import Self from './containers/routes/Self'; +import App from './containers/App'; + +const routes = [ + { path: '/', + component: App + }, + { path: '/example', + component: Index + }, + { path: '/example/self', + component: Self + } +]; + +export default routes; diff --git a/examples/react-router-redux/src/styles/Login.css b/examples/react-router-redux/src/styles/Login.css new file mode 100644 index 0000000..48b1a67 --- /dev/null +++ b/examples/react-router-redux/src/styles/Login.css @@ -0,0 +1,3 @@ +.login-component { + border: 1px dashed #f00; +} diff --git a/examples/react-router-redux/src/styles/Self.css b/examples/react-router-redux/src/styles/Self.css new file mode 100644 index 0000000..c7f68d3 --- /dev/null +++ b/examples/react-router-redux/src/styles/Self.css @@ -0,0 +1,3 @@ +.self-component { + border: 1px dashed #f00; +} diff --git a/examples/react-router-redux/src/styles/routes/Index.css b/examples/react-router-redux/src/styles/routes/Index.css new file mode 100644 index 0000000..f811ac1 --- /dev/null +++ b/examples/react-router-redux/src/styles/routes/Index.css @@ -0,0 +1,3 @@ +.index-component { + border: 1px dashed #f00; +} diff --git a/examples/react-router-redux/test/components/LoginComponentTest.js b/examples/react-router-redux/test/components/LoginComponentTest.js new file mode 100644 index 0000000..8870e5b --- /dev/null +++ b/examples/react-router-redux/test/components/LoginComponentTest.js @@ -0,0 +1,22 @@ +/* eslint-env node, mocha */ +/* global expect */ +/* eslint no-console: 0 */ +'use strict'; + +// Uncomment the following lines to use the react test utilities +// import TestUtils from 'react-addons-test-utils'; +import createComponent from 'helpers/shallowRenderHelper'; + +import LoginComponent from 'components//LoginComponent.js'; + +describe('LoginComponent', () => { + let component; + + beforeEach(() => { + component = createComponent(LoginComponent); + }); + + it('should have its component name as default className', () => { + expect(component.props.className).to.equal('login-component'); + }); +}); diff --git a/examples/react-router-redux/test/components/SelfComponentTest.js b/examples/react-router-redux/test/components/SelfComponentTest.js new file mode 100644 index 0000000..26c95f4 --- /dev/null +++ b/examples/react-router-redux/test/components/SelfComponentTest.js @@ -0,0 +1,22 @@ +/* eslint-env node, mocha */ +/* global expect */ +/* eslint no-console: 0 */ +'use strict'; + +// Uncomment the following lines to use the react test utilities +// import TestUtils from 'react-addons-test-utils'; +import createComponent from 'helpers/shallowRenderHelper'; + +import SelfComponent from 'components//SelfComponent.js'; + +describe('SelfComponent', () => { + let component; + + beforeEach(() => { + component = createComponent(SelfComponent); + }); + + it('should have its component name as default className', () => { + expect(component.props.className).to.equal('self-component'); + }); +}); diff --git a/examples/react-router-redux/test/components/routes/IndexComponentTest.js b/examples/react-router-redux/test/components/routes/IndexComponentTest.js new file mode 100644 index 0000000..5f0d686 --- /dev/null +++ b/examples/react-router-redux/test/components/routes/IndexComponentTest.js @@ -0,0 +1,22 @@ +/* eslint-env node, mocha */ +/* global expect */ +/* eslint no-console: 0 */ +'use strict'; + +// Uncomment the following lines to use the react test utilities +// import TestUtils from 'react-addons-test-utils'; +import createComponent from 'helpers/shallowRenderHelper'; + +import IndexComponent from 'components/routes/IndexComponent.js'; + +describe('IndexComponent', () => { + let component; + + beforeEach(() => { + component = createComponent(IndexComponent); + }); + + it('should have its component name as default className', () => { + expect(component.props.className).to.equal('index-component'); + }); +}); diff --git a/examples/react-router-redux/test/reducers/userTest.js b/examples/react-router-redux/test/reducers/userTest.js new file mode 100644 index 0000000..9371fc5 --- /dev/null +++ b/examples/react-router-redux/test/reducers/userTest.js @@ -0,0 +1,12 @@ +var reducer = require('../../src/reducers/user'); + +describe('user', () => { + + it('should not change the passed state', (done) => { + + const state = Object.freeze({}); + reducer(state, {type: 'INVALID'}); + + done(); + }); +}); From 6e2f35a2e1e3954a01aed2005095a4208e88fc45 Mon Sep 17 00:00:00 2001 From: Chris Landa Date: Sun, 26 Jun 2016 23:20:14 +0200 Subject: [PATCH 3/5] Changed wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5474f17..5b3df8c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It also has support for the the features that are available in its parent projec There are currently some features missing from the generator. These will be available in a later version: - [ ] Add optional routing via [react-router-redux](https://github.com/rackt/react-router-redux) -- [ ] Scaffold routes +- [ ] Route generator ## Installation ```bash From b737d8f66bbc18884e066040b2402ca3a842eeeb Mon Sep 17 00:00:00 2001 From: Chris Landa Date: Sun, 26 Jun 2016 23:20:40 +0200 Subject: [PATCH 4/5] Updated example --- .../react-router-redux/src/containers/App.js | 6 ++++-- examples/react-router-redux/src/index.js | 6 +++--- examples/react-router-redux/src/routes.js | 16 +++++++++------- examples/react-router-redux/src/stores/index.js | 4 +++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/examples/react-router-redux/src/containers/App.js b/examples/react-router-redux/src/containers/App.js index 29a1994..e962e66 100644 --- a/examples/react-router-redux/src/containers/App.js +++ b/examples/react-router-redux/src/containers/App.js @@ -17,7 +17,10 @@ class App extends Component { render() { const {actions, user} = this.props; return ( -
+
+
+ {this.props.children} +
); } } @@ -28,7 +31,6 @@ class App extends Component { */ App.propTypes = { actions: PropTypes.object.isRequired, - history: PropTypes.object.isRequired, user: PropTypes.object.isRequired }; function mapStateToProps(state) { diff --git a/examples/react-router-redux/src/index.js b/examples/react-router-redux/src/index.js index f088b48..39d4dc1 100644 --- a/examples/react-router-redux/src/index.js +++ b/examples/react-router-redux/src/index.js @@ -1,10 +1,10 @@ import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; -import { browserHistory } from 'react-router'; -import { syncHistoryWithStore } from 'react-router-redux' +import { browserHistory, Router } from 'react-router'; +import { syncHistoryWithStore } from 'react-router-redux'; + import configureStore from './stores'; -import { Router } from 'react-router'; import routes from './routes'; const store = configureStore(); diff --git a/examples/react-router-redux/src/routes.js b/examples/react-router-redux/src/routes.js index 7490b05..2a78ec7 100644 --- a/examples/react-router-redux/src/routes.js +++ b/examples/react-router-redux/src/routes.js @@ -4,13 +4,15 @@ import App from './containers/App'; const routes = [ { path: '/', - component: App - }, - { path: '/example', - component: Index - }, - { path: '/example/self', - component: Self + component: App, + childRoutes: [ + { path: 'example', + component: Index + }, + { path: 'example/self', + component: Self + } + ] } ]; diff --git a/examples/react-router-redux/src/stores/index.js b/examples/react-router-redux/src/stores/index.js index 1623090..1f40f15 100644 --- a/examples/react-router-redux/src/stores/index.js +++ b/examples/react-router-redux/src/stores/index.js @@ -2,7 +2,9 @@ const redux = require('redux'); const reducers = require('../reducers'); module.exports = function(initialState) { - const store = redux.createStore(reducers, initialState) + const store = redux.createStore(reducers, initialState, redux.compose( + window.devToolsExtension ? window.devToolsExtension() : f => f + )); if (module.hot) { // Enable Webpack hot module replacement for reducers From bf4402d207706dc5382bf667e2cb1e0c74821e9f Mon Sep 17 00:00:00 2001 From: Chris Landa Date: Sun, 26 Jun 2016 23:55:06 +0200 Subject: [PATCH 5/5] Updated eslint config --- .eslintrc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5a04140..9c1e24a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,10 @@ { - "ecmaFeatures": { - "modules": true, - "jsx": true + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } }, "env": { "browser": false,