-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e586b8
Showing
22 changed files
with
660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
max_line_length = 80 | ||
indent_brace_style = 1TBS | ||
spaces_around_operators = true | ||
quote_type = auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"mocha": true, | ||
"es6": true | ||
}, | ||
"globals": { | ||
"angular": true, | ||
"moment": true, | ||
"R": true, | ||
"inject": true, | ||
"Q": true, | ||
"sinon": true, | ||
"getService": true, | ||
"expect": true, | ||
"xit": true, | ||
"dealoc": true, | ||
"require": true | ||
}, | ||
"rules": { | ||
"camelcase": 2, | ||
"curly": 2, | ||
"brace-style": [2, "1tbs"], | ||
"quotes": [2, "single"], | ||
"semi": [2, "always"], | ||
"object-curly-spacing": [2, "never"], | ||
"array-bracket-spacing": [2, "never"], | ||
"computed-property-spacing": [2, "never"], | ||
"space-infix-ops": 2, | ||
"space-after-keywords": [2, "always"], | ||
"dot-notation": 2, | ||
"eqeqeq": [2, "smart"], | ||
"no-use-before-define": 2, | ||
"no-redeclare": 2, | ||
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}], | ||
"no-floating-decimal": 2, | ||
"no-spaced-func": 2, | ||
"no-extra-parens": 1, | ||
"no-underscore-dangle": 0, | ||
"valid-jsdoc": 1, | ||
"space-after-keywords": 2, | ||
"max-len": [2, 120], | ||
"no-use-before-define": [2, "nofunc"], | ||
"no-warning-comments": 0, | ||
"strict": 0, | ||
"eol-last": 0, | ||
"semi": 2 | ||
}, | ||
"ecmaFeatures": { | ||
"modules": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Sass cache folder | ||
.sass-cache | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
.idea/ | ||
*~ | ||
\#*# | ||
.#* | ||
*.keystore | ||
*.sw* | ||
.DS_Store | ||
._* | ||
Thumbs.db | ||
.cache | ||
*.sublime-project | ||
*.sublime-workspace | ||
*swp | ||
*swo | ||
*swn | ||
build | ||
dist | ||
temp | ||
.tmp | ||
node_modules | ||
bower_components | ||
jspm_packages | ||
.test | ||
www | ||
|
||
keys.md | ||
.env | ||
|
||
# Cordova | ||
platforms/ | ||
plugins/ | ||
|
||
# emacs | ||
.tern-port | ||
# -*- mode: gitignore; -*- | ||
*~ | ||
\#*\# | ||
/.emacs.desktop | ||
/.emacs.desktop.lock | ||
*.elc | ||
auto-save-list | ||
tramp | ||
.\#* | ||
|
||
# Org-mode | ||
.org-id-locations | ||
*_archive | ||
|
||
# flymake-mode | ||
*_flymake.* | ||
|
||
# eshell files | ||
/eshell/history | ||
/eshell/lastdir | ||
|
||
# elpa packages | ||
/elpa/ | ||
|
||
# reftex files | ||
*.rel | ||
|
||
# AUCTeX auto folder | ||
/auto/ | ||
|
||
# cask packages | ||
.cask/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html ng-app="app"> | ||
<head> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css"> | ||
<link rel="stylesheet" href="./styles.css"> | ||
<title>ng-redux-ui-router</title> | ||
</head> | ||
<body> | ||
<main ui-view="main"></main> | ||
</body> | ||
<script src="/static/bundle.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
|
||
import ngUiRouterMiddleware from '../src'; | ||
import ngRedux from 'ng-redux'; | ||
import * as redux from 'redux'; | ||
import createLogger from 'redux-logger'; | ||
|
||
const logger = createLogger({ | ||
level: 'info', | ||
collapsed: true | ||
}); | ||
|
||
import uiRouterState from '../src/router-state-reducer'; | ||
|
||
const reducers = redux.combineReducers({ | ||
uiRouterState | ||
}); | ||
|
||
import thunk from 'redux-thunk'; | ||
|
||
export default angular | ||
.module('app', [ | ||
uiRouter, | ||
ngRedux, | ||
ngUiRouterMiddleware | ||
]) | ||
.config(($urlRouterProvider, $stateProvider) => { | ||
$urlRouterProvider.otherwise('/app'); | ||
|
||
$stateProvider | ||
.state('app', { | ||
url: '/app', | ||
views: { | ||
main: { | ||
template: ` | ||
<pre>{{ globalState | json }}</pre> | ||
<div class="mainView"> | ||
<h1>Main View</h1> | ||
<ul> | ||
<li> | ||
<a ui-sref="app">Main View</a> | ||
<ul> | ||
<li><a ui-sref="app.child1">Child View 1</a></li> | ||
<li><a ui-sref="app.child2">Child View 2</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<div ui-view="child"></div> | ||
</div> | ||
`, | ||
controller: ($scope, $ngRedux) => { | ||
$scope.globalState = {}; | ||
|
||
$ngRedux.connect(state => state, state => $scope.globalState = state); | ||
} | ||
} | ||
} | ||
}) | ||
.state('app.child1', { | ||
url: '/child1?hello?optional', | ||
views: { | ||
child: { | ||
controller: ($scope, ngUiRouterActions) => { | ||
$scope.goto = () => { | ||
ngUiRouterActions.stateGo('app.child2'); | ||
} | ||
}, | ||
template: ` | ||
<div class="child-view"> | ||
<h2>Child View 1</h2> | ||
<button ng-click="goto()">Child View 2</button> | ||
</div> | ||
` | ||
} | ||
} | ||
}) | ||
.state('app.child2', { | ||
url: '/child2', | ||
views: { | ||
child: { | ||
controller: ($scope, ngUiRouterActions) => { | ||
$scope.goto = () => { | ||
ngUiRouterActions.stateGo('app.child1'); | ||
} | ||
|
||
$scope.goWithReload = () => { | ||
ngUiRouterActions.stateReload('app.child1'); | ||
} | ||
|
||
$scope.goWithParams = () => { | ||
ngUiRouterActions.stateGo('app.child1', { | ||
hello: 'world', | ||
optional: true | ||
}); | ||
} | ||
}, | ||
template: ` | ||
<div class="child-view"> | ||
<h2>Child View 2</h2> | ||
<button ng-click="goto()">Child View 1</button> | ||
<button ng-click="goWithReload()">Go with Reload</button> | ||
<button ng-click="goWithParams()">Go with Params</button> | ||
</div> | ||
` | ||
} | ||
} | ||
}) | ||
}) | ||
.config(($ngReduxProvider) => { | ||
$ngReduxProvider.createStoreWith(reducers, ['ngUiRouterMiddleware', logger, thunk]); | ||
}) | ||
.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "angular-ui-router-redux", | ||
"version": "0.1.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node server.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "5.6.15", | ||
"babel-loader": "^5.1.4", | ||
"react-hot-loader": "^1.2.7", | ||
"redux-batched-updates": "^0.1.0", | ||
"webpack": "^1.9.11", | ||
"webpack-dev-server": "^1.9.0" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"react-pure-component": "^0.1.0", | ||
"react-redux": "^0.2.1", | ||
"redux": "^1.0.0-alpha", | ||
"redux-logger": "^1.0.4", | ||
"redux-thunk": "^0.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var webpack = require('webpack'); | ||
var WebpackDevServer = require('webpack-dev-server'); | ||
var config = require('./webpack.config'); | ||
|
||
new WebpackDevServer(webpack(config), { | ||
publicPath: config.output.publicPath, | ||
hot: true, | ||
stats: { | ||
colors: true | ||
} | ||
}) | ||
.listen(3000, 'localhost', function (err) { | ||
if (err) { | ||
console.log(err); | ||
} | ||
|
||
console.log('http://localhost:3000'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
main { | ||
background-color: lightgray; | ||
} | ||
|
||
pre { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 300px; | ||
bottom: 0; | ||
background-color: black; | ||
color: white; | ||
} | ||
|
||
.mainView { | ||
margin-left: 400px; | ||
min-height: 100vh; | ||
} | ||
|
||
.child-view { | ||
background-color: white; | ||
padding: 15px; | ||
margin: 15px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
module.exports = { | ||
devtool: 'eval', | ||
entry: [ | ||
'webpack-dev-server/client?http://localhost:3000', | ||
'webpack/hot/dev-server', | ||
'./index' | ||
], | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: 'bundle.js', | ||
publicPath: '/static/' | ||
}, | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoErrorsPlugin() | ||
], | ||
resolve: { | ||
extensions: ['', '.js'], | ||
alias: { | ||
'react': path.join(__dirname, '..', '..', 'node_modules', 'react') | ||
} | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.js$/, | ||
loaders: ['babel'], | ||
exclude: /node_modules/ | ||
}, { | ||
test: /\.css?$/, | ||
loaders: ['style', 'raw'], | ||
exclude: /node_modules/ | ||
}] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- Wondering if `toState` and `toParams` doesn't make sense in the context of the router state? | ||
- `toParams` implies that the router is still going to a state | ||
- Possibly rename to `currentParams` and `currentState` | ||
- `fromState` and `fromParams` would become `prevState` and `prevParams` | ||
|
Oops, something went wrong.