From 35b636391544807363c6df3bcb4eb017cf7e49f5 Mon Sep 17 00:00:00 2001 From: stephengrider Date: Mon, 30 Apr 2018 08:55:33 -0600 Subject: [PATCH] Revert "reorg" This reverts commit 1af735f5eb45c577b2bb768bcb2d02b94c2e86cd. --- LICENSE.MD | 21 +++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++++ index.html | 13 +++++++++++++ package.json | 37 +++++++++++++++++++++++++++++++++++++ src/actions/index.js | 0 src/components/app.js | 9 +++++++++ src/index.js | 15 +++++++++++++++ src/reducers/index.js | 7 +++++++ style/style.css | 0 test/components/app_test.js | 14 ++++++++++++++ test/test_helper.js | 36 ++++++++++++++++++++++++++++++++++++ webpack.config.js | 26 ++++++++++++++++++++++++++ 12 files changed, 203 insertions(+) create mode 100644 LICENSE.MD create mode 100644 README.md create mode 100644 index.html create mode 100644 package.json create mode 100644 src/actions/index.js create mode 100644 src/components/app.js create mode 100644 src/index.js create mode 100644 src/reducers/index.js create mode 100644 style/style.css create mode 100644 test/components/app_test.js create mode 100644 test/test_helper.js create mode 100644 webpack.config.js diff --git a/LICENSE.MD b/LICENSE.MD new file mode 100644 index 0000000..1148ff6 --- /dev/null +++ b/LICENSE.MD @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Stephen Grider + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca60fdf --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# ReduxSimpleStarter + +Interested in learning [Redux](https://www.udemy.com/react-redux/)? + +### Getting Started + +There are two methods for getting started with this repo. + +#### Familiar with Git? +Checkout this repo, install dependencies, then start the gulp process with the following: + +``` +> git clone https://github.com/StephenGrider/ReduxSimpleStarter.git +> cd ReduxSimpleStarter +> npm install +> npm start +``` + +#### Not Familiar with Git? +Click [here](https://github.com/StephenGrider/ReactStarter/releases) then download the .zip file. Extract the contents of the zip file, then open your terminal, change to the project directory, and: + +``` +> npm install +> npm start +``` diff --git a/index.html b/index.html new file mode 100644 index 0000000..c3452f2 --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..102a759 --- /dev/null +++ b/package.json @@ -0,0 +1,37 @@ +{ + "name": "redux-simple-starter", + "version": "1.0.0", + "description": "Simple starter package for Redux with React and Babel support", + "main": "index.js", + "repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git", + "scripts": { + "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js", + "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test", + "test:watch": "npm run test -- --watch" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "babel-core": "^6.2.1", + "babel-loader": "^6.2.0", + "babel-preset-es2015": "^6.1.18", + "babel-preset-react": "^6.1.18", + "chai": "^3.5.0", + "chai-jquery": "^2.0.0", + "jquery": "^2.2.1", + "jsdom": "^8.1.0", + "mocha": "^2.4.5", + "react-addons-test-utils": "^0.14.7", + "webpack": "^1.12.9", + "webpack-dev-server": "^1.14.0" + }, + "dependencies": { + "babel-preset-stage-1": "^6.1.18", + "lodash": "^3.10.1", + "react": "^0.14.3", + "react-dom": "^0.14.3", + "react-redux": "4.3.0", + "react-router": "^2.0.1", + "redux": "^3.0.4" + } +} diff --git a/src/actions/index.js b/src/actions/index.js new file mode 100644 index 0000000..e69de29 diff --git a/src/components/app.js b/src/components/app.js new file mode 100644 index 0000000..58614b0 --- /dev/null +++ b/src/components/app.js @@ -0,0 +1,9 @@ +import React, { Component } from 'react'; + +export default class App extends Component { + render() { + return ( +
React simple starter
+ ); + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..69d577a --- /dev/null +++ b/src/index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import { Provider } from 'react-redux'; +import { createStore, applyMiddleware } from 'redux'; + +import App from './components/app'; +import reducers from './reducers'; + +const createStoreWithMiddleware = applyMiddleware()(createStore); + +ReactDOM.render( + + + + , document.querySelector('.container')); diff --git a/src/reducers/index.js b/src/reducers/index.js new file mode 100644 index 0000000..d12506f --- /dev/null +++ b/src/reducers/index.js @@ -0,0 +1,7 @@ +import { combineReducers } from 'redux'; + +const rootReducer = combineReducers({ + state: (state = {}) => state +}); + +export default rootReducer; diff --git a/style/style.css b/style/style.css new file mode 100644 index 0000000..e69de29 diff --git a/test/components/app_test.js b/test/components/app_test.js new file mode 100644 index 0000000..d7a17a5 --- /dev/null +++ b/test/components/app_test.js @@ -0,0 +1,14 @@ +import { renderComponent , expect } from '../test_helper'; +import App from '../../src/components/app'; + +describe('App' , () => { + let component; + + beforeEach(() => { + component = renderComponent(App); + }); + + it('renders something', () => { + expect(component).to.exist; + }); +}); diff --git a/test/test_helper.js b/test/test_helper.js new file mode 100644 index 0000000..e4d00a0 --- /dev/null +++ b/test/test_helper.js @@ -0,0 +1,36 @@ +import _$ from 'jquery'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import TestUtils from 'react-addons-test-utils'; +import jsdom from 'jsdom'; +import chai, { expect } from 'chai'; +import chaiJquery from 'chai-jquery'; +import { Provider } from 'react-redux'; +import { createStore } from 'redux'; +import reducers from '../src/reducers'; + +global.document = jsdom.jsdom(''); +global.window = global.document.defaultView; +global.navigator = global.window.navigator; +const $ = _$(window); + +chaiJquery(chai, chai.util, $); + +function renderComponent(ComponentClass, props = {}, state = {}) { + const componentInstance = TestUtils.renderIntoDocument( + + + + ); + + return $(ReactDOM.findDOMNode(componentInstance)); +} + +$.fn.simulate = function(eventName, value) { + if (value) { + this.val(value); + } + TestUtils.Simulate[eventName](this[0]); +}; + +export {renderComponent, expect}; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..31d865c --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,26 @@ +module.exports = { + entry: [ + './src/index.js' + ], + output: { + path: __dirname, + publicPath: '/', + filename: 'bundle.js' + }, + module: { + loaders: [{ + exclude: /node_modules/, + loader: 'babel', + query: { + presets: ['react', 'es2015', 'stage-1'] + } + }] + }, + resolve: { + extensions: ['', '.js', '.jsx'] + }, + devServer: { + historyApiFallback: true, + contentBase: './' + } +};