Skip to content

Commit

Permalink
Merge pull request #84 from tur-nr/release/v1
Browse files Browse the repository at this point in the history
Release/v1
  • Loading branch information
tur-nr authored Jun 13, 2017
2 parents 9d8e5dd + 317e635 commit 35f38ff
Show file tree
Hide file tree
Showing 32 changed files with 5,547 additions and 3,531 deletions.
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
],
"plugins": [
"transform-object-rest-spread"
]
}
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[{*.json,.babelrc,.travis.yml}]
indent_style = space
indent_size = 2

[*.md]
indent_style = space

[*.html]
indent_size = 2
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bower_components
coverage
node_modules
.idea
*.log
.DS_Store
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bower_components
coverage
test
.babelrc
.editorconfig
.gitignore
.npmignore
.travis.yml
gulpfile.babel.js
wct.conf.json
22 changes: 14 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
language: node_js
sudo: true
dist: trusty
node_js: 4
cache:
directories:
- node_modules

sudo: true

language: node_js

node_js: stable

addons:
firefox: 46.0
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable

cache:
yarn: true

before_script:
- bower install
- npm run lint

script:
- xvfb-run npm test

after_script:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Christopher Turner
Copyright (c) 2017 Christopher Turner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ 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.
SOFTWARE.
18 changes: 8 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"description": "Polymer bindings for Redux.",
"main": "polymer-redux.html",
"moduleType": [
"globals"
"amd",
"globals",
"node"
],
"keywords": [
"redux",
"polymer",
"web",
"component",
"reducer"
"reducer",
"state",
"web-components"
],
"license": "MIT",
"homepage": "https://github.com/tur-nr/polymer-redux",
Expand All @@ -25,13 +27,9 @@
"tests"
],
"dependencies": {
"polymer": "^1.4.0"
"polymer": "^2.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"vaadin-combo-box": "^1.3.3"
"web-component-tester": "^6.0.0"
}
}
162 changes: 29 additions & 133 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,136 +1,32 @@
<!doctype html>
<html>
<head>
<title>Polymer Redux Demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../node_modules/redux/dist/redux.js"></script>

<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">

<link rel="import" href="../polymer-redux.html">

<style is="custom-style" include="demo-pages-shared-styles">
</style>
</head>
<body>

<div class="vertical-section-container">
<h3>Polymer Redux Demo</h3>
<demo-snippet>
<template>
<!-- redux setup -->
<script>
const reducer = (state, action) => {
if (!state) return { friends: [] };

// copy friends list
friends = state.friends.slice(0);

switch (action.type) {
case 'ADD_FRIEND':
friends.push(action.friend);
break;
case 'REMOVE_FRIEND':
const idx = friends.indexOf(action.friend)
if (idx !== -1) {
friends.splice(idx, 1)
}
break;
case 'SORT_FRIENDS':
friends.sort()
break;
}

state.friends = friends;

return state;
}
const store = Redux.createStore(reducer);
const ReduxBehavior = PolymerRedux(store);
</script>

<!-- friends list module -->
<dom-module id="friends-list">
<template>
<p>
<span>You have [[friends.length]] friend(s).</span>
<template is="dom-if" if="[[canSortFriends(friends.length)]]">
<button on-click="sortFriends">Sort Friends</button>
</template>
</p>
<ul>
<template is="dom-repeat" items="[[friends]]">
<li>
<span>[[item]]</span>
<button on-click="removeFriend">Remove</button>
</li>
</template>
</ul>
<input id="friend-name" placeholder="Name" on-keypress="handleKeypress">
<button on-click="addFriend">Add Friend</button>
</template>
</dom-module>
<script>
Polymer({
is: 'friends-list',
behaviors: [ ReduxBehavior ],
properties: {
friends: {
type: Array,
statePath: 'friends'
}
},
actions: {
add: function(name) {
return {
type: 'ADD_FRIEND',
friend: name
};
},
remove: function(name) {
return {
type: 'REMOVE_FRIEND',
friend: name
};
},
sort: function() {
return {
type: 'SORT_FRIENDS'
};
},
},
addFriend: function() {
const input = this.$['friend-name'];
if (input.value) {
this.dispatch('add', input.value);
input.value = '';
input.focus();
}
},
removeFriend: function(event) {
this.dispatch('remove', event.model.item);
},
sortFriends: function() {
this.dispatch('sort');
},
canSortFriends: function(length) {
return length > 1;
},
handleKeypress: function(event) {
if (event.charCode === 13) {
this.addFriend();
}
}
});
</script>

<!-- demo -->
<friends-list></friends-list>
</template>
</demo-snippet>
</div>
</body>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">

<title>polymer-redux Demo</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="./message-mixin.html">
</head>
<body>
<dom-module id="my-element">
<template>
<p>[[message]]</p>
<button on-click="handleUpdateMessage">Update message</button>
</template>
<script>
class MyElement extends MessageMixin(Polymer.Element) {
static get is() { return 'my-element'; }

handleUpdateMessage() {
this.dispatch('updateMessage', 'Nothing changes by staying the same, quite literally.');
}
}
window.customElements.define(MyElement.is, MyElement);
</script>
</dom-module>
<my-element></my-element>
</body>
</html>
24 changes: 24 additions & 0 deletions demo/message-mixin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<link rel="import" href="./redux-mixin.html">
<script>
MessageMixin = Parent => class MessageMixin extends ReduxMixin(Parent) {
static get properties() {
return {
message: {
type: String,
statePath: 'message'
}
};
}

static get actions() {
return {
updateMessage(message) {
return {
type: 'UPDATE_MESSAGE',
message
}
}
};
}
};
</script>
20 changes: 20 additions & 0 deletions demo/redux-mixin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<link rel="import" href="../polymer-redux.html">
<script src="../node_modules/redux/dist/redux.js"></script>
<script>
const initial = {
message: 'Hello from PolymerRedux'
};
const reducer = (state = initial, action) => {
switch (action.type) {
case 'UPDATE_MESSAGE':
return Object.assign({}, state, {
message: action.message
});

default:
return state;
}
};
const store = Redux.createStore(reducer);
ReduxMixin = PolymerRedux(store);
</script>
Loading

0 comments on commit 35f38ff

Please sign in to comment.