Skip to content

Commit

Permalink
Revert "[feature/redux] merge master (#733)"
Browse files Browse the repository at this point in the history
This reverts commit cb0eb7f.
  • Loading branch information
langpavel committed Jul 10, 2016
1 parent cb0eb7f commit 888088c
Show file tree
Hide file tree
Showing 25 changed files with 297 additions and 396 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ All notable changes to this project will be documented in this file.

### [Unreleased][unreleased]

- Remove Jade dependency in favor of React-based templates: `src/views/index.jade => src/components/Html`
(BREAKING CHANGE) [#711](https://github.com/kriasoft/react-starter-kit/pull/711)
- Update `isomorphic-style-loader` to `v1.0.0`, it adds comparability with ES2015+ decorators.
Code such as `export default withStyles(MyComponent, style1, style2)` must be replaced with
`export default withStyles(style1, style2)(MyComponent)` (BREAKING CHANGE).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ branches that you can use either as a reference or merge into your project:
isomorphic Redux and React Intl by [Pavel Lang](https://github.com/langpavel) (see [how
to integrate React Intl](./docs/recipes/how-to-integrate-react-intl.md))

If you think that any of these features should be on `master`, or vice versa, some features should
If you think that any of these features should be on `master`, or vise versa, some features should
removed from the `master` branch, please [let us know](https://gitter.im/kriasoft/react-starter-kit).
We love your feedback!

Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* [React Style Guide](./react-style-guide.md)
* [How to configure text editors and IDEs](./how-to-configure-text-editors.md)
* [Data fetching with WHATWG Fetch](./data-fetching.md)
* [Testing your application](./testing-your-application.md)

### Questions

Expand Down
2 changes: 1 addition & 1 deletion docs/react-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Add `package.json` file into each component's folder.<br>
This will allow to easily reference such components from other places in
your code.<br>
Use `import Nav from '../Navigation'` instead of `import Nav from '../Navigation/Navigation.js'`
`import Nav from '../Nav'` vs `import Nav from '../Nav/Nav.js'`

```
/components/Navigation/icon.svg
Expand Down
97 changes: 0 additions & 97 deletions docs/testing-your-application.md

This file was deleted.

63 changes: 28 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,41 @@
"npm": ">=3.3 <4"
},
"dependencies": {
"babel-polyfill": "6.9.1",
"babel-runtime": "6.9.2",
"babel-polyfill": "6.9.0",
"babel-runtime": "6.9.0",
"bluebird": "3.4.0",
"body-parser": "1.15.1",
"classnames": "2.2.5",
"cookie-parser": "1.4.3",
"cookie-parser": "1.4.1",
"core-js": "2.4.0",
"eventemitter3": "1.2.0",
"express": "4.13.4",
"express-graphql": "0.5.3",
"express-graphql": "0.5.1",
"express-jwt": "3.4.0",
"fastclick": "1.0.6",
"fbjs": "0.8.3",
"front-matter": "2.1.0",
"graphiql": "0.7.2",
"fbjs": "0.8.2",
"front-matter": "2.0.7",
"graphiql": "0.7.1",
"graphql": "0.6.0",
"history": "3.0.0",
"history": "2.1.1",
"isomorphic-style-loader": "1.0.0",
"jsonwebtoken": "7.0.0",
"markdown-it": "6.0.5",
"node-fetch": "1.5.3",
"jade": "1.11.0",
"jsonwebtoken": "6.2.0",
"markdown-it": "6.0.2",
"node-fetch": "1.5.2",
"normalize.css": "4.1.1",
"passport": "0.3.2",
"passport-facebook": "2.1.1",
"pretty-error": "2.0.0",
"react": "15.1.0",
"react-dom": "15.1.0",
"react": "15.0.2",
"react-dom": "15.0.2",
"react-redux": "^4.4.5",
"redux": "^3.4.0",
"redux-thunk": "^2.1.0",
"sequelize": "3.23.3",
"sequelize": "3.23.2",
"source-map-support": "0.4.0",
"sqlite3": "3.1.4",
"universal-router": "1.2.2",
"universal-router": "1.2.1",
"whatwg-fetch": "1.0.0"
},
"devDependencies": {
Expand All @@ -52,7 +53,7 @@
"babel-plugin-rewire": "^1.0.0-rc-3",
"babel-plugin-transform-react-constant-elements": "^6.8.0",
"babel-plugin-transform-react-inline-elements": "^6.8.0",
"babel-plugin-transform-react-remove-prop-types": "^0.2.7",
"babel-plugin-transform-react-remove-prop-types": "^0.2.6",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-node5": "^11.1.0",
Expand All @@ -69,19 +70,20 @@
"eslint": "^2.10.2",
"eslint-config-airbnb": "^9.0.1",
"eslint-loader": "^1.3.0",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-jsx-a11y": "^1.2.2",
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-react": "^5.1.1",
"extend": "^3.0.0",
"file-loader": "^0.8.5",
"gaze": "^1.0.0",
"git-repository": "^0.1.4",
"glob": "^7.0.3",
"jade-loader": "^0.8.0",
"json-loader": "^0.5.4",
"mkdirp": "^0.5.1",
"mocha": "^2.5.3",
"mocha": "^2.4.5",
"ncp": "^2.0.0",
"pixrem": "^3.0.1",
"pixrem": "^3.0.0",
"pleeease-filters": "^3.0.0",
"postcss": "^5.0.21",
"postcss-calc": "^5.2.1",
Expand All @@ -97,16 +99,16 @@
"postcss-selector-matches": "^2.0.1",
"postcss-selector-not": "^2.0.0",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^15.1.0",
"react-addons-test-utils": "^15.0.2",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.2.6",
"redbox-react": "^1.2.4",
"redux-logger": "^2.6.1",
"sinon": "^2.0.0-pre",
"stylelint": "^6.6.0",
"stylelint-config-standard": "^9.0.0",
"stylelint": "^6.4.1",
"stylelint-config-standard": "^7.0.0",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack": "^1.13.0",
"webpack-hot-middleware": "^2.10.0",
"webpack-middleware": "^1.5.1"
},
Expand Down Expand Up @@ -145,16 +147,7 @@
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"string-quotes": "single",
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": [
"global",
"local"
]
}
]
"string-quotes": "single"
}
},
"scripts": {
Expand Down
75 changes: 27 additions & 48 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,15 @@
import 'babel-polyfill';
import ReactDOM from 'react-dom';
import FastClick from 'fastclick';
import UniversalRouter from 'universal-router';
import { match } from 'universal-router';
import routes from './routes';
import history from './core/history';
import configureStore from './store/configureStore';
import { readState, saveState } from 'history/lib/DOMStateStorage';
import {
addEventListener,
removeEventListener,
windowScrollX,
windowScrollY,
} from './core/DOMUtils';
import { addEventListener, removeEventListener } from './core/DOMUtils';

const context = {
store: null,
insertCss: (...styles) => {
const removeCss = styles.map(style => style._insertCss()); // eslint-disable-line no-underscore-dangle, max-len
return () => {
removeCss.forEach(f => f());
};
},
insertCss: styles => styles._insertCss(), // eslint-disable-line no-underscore-dangle
setTitle: value => (document.title = value),
setMeta: (name, content) => {
// Remove and create a new <meta /> tag in order to make it work
Expand Down Expand Up @@ -67,9 +56,7 @@ let renderComplete = (state, callback) => {

// Google Analytics tracking. Don't send 'pageview' event after
// the initial rendering, as it was already sent
if (window.ga) {
window.ga('send', 'pageview');
}
window.ga('send', 'pageview');

callback(true);
};
Expand All @@ -90,59 +77,51 @@ function render(container, state, component) {
}

function run() {
let currentLocation = null;
const container = document.getElementById('app');
const initialState = JSON.parse(
document.
getElementById('source').
getAttribute('data-initial-state')
);
let currentLocation = history.getCurrentLocation();

// Make taps on links and buttons work fast on mobiles
FastClick.attach(document.body);

context.store = configureStore(initialState, {});

// Re-render the app when window.location changes
function onLocationChange(location) {
// Save the page scroll position into the current location's state
if (currentLocation.key) {
saveState(currentLocation.key, {
...readState(currentLocation.key),
scrollX: windowScrollX(),
scrollY: windowScrollY(),
});
}
const removeHistoryListener = history.listen(location => {
currentLocation = location;

UniversalRouter.resolve(routes, {
match(routes, {
path: location.pathname,
query: location.query,
state: location.state,
context,
render: render.bind(undefined, container, location.state), // eslint-disable-line react/jsx-no-bind, max-len
render: render.bind(undefined, container, location.state),
}).catch(err => console.error(err)); // eslint-disable-line no-console
}

// Add History API listener and trigger initial change
const removeHistoryListener = history.listen(onLocationChange);
history.replace(currentLocation);
});

// https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration
let originalScrollRestoration;
if (window.history && 'scrollRestoration' in window.history) {
originalScrollRestoration = window.history.scrollRestoration;
window.history.scrollRestoration = 'manual';
}
// Save the page scroll position into the current location's state
const supportPageOffset = window.pageXOffset !== undefined;
const isCSS1Compat = ((document.compatMode || '') === 'CSS1Compat');
const setPageOffset = () => {
currentLocation.state = currentLocation.state || Object.create(null);
if (supportPageOffset) {
currentLocation.state.scrollX = window.pageXOffset;
currentLocation.state.scrollY = window.pageYOffset;
} else {
currentLocation.state.scrollX = isCSS1Compat ?
document.documentElement.scrollLeft : document.body.scrollLeft;
currentLocation.state.scrollY = isCSS1Compat ?
document.documentElement.scrollTop : document.body.scrollTop;
}
};

// Prevent listeners collisions during history navigation
addEventListener(window, 'pagehide', function onPageHide() {
removeEventListener(window, 'pagehide', onPageHide);
addEventListener(window, 'scroll', setPageOffset);
addEventListener(window, 'pagehide', () => {
removeEventListener(window, 'scroll', setPageOffset);
removeHistoryListener();
if (originalScrollRestoration) {
window.history.scrollRestoration = originalScrollRestoration;
originalScrollRestoration = undefined;
}
});
}

Expand Down
Loading

0 comments on commit 888088c

Please sign in to comment.