Skip to content

Commit

Permalink
Upgrade to Polymer 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Roeller committed Jun 7, 2017
1 parent d632c94 commit ded2fd1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _[Demo and API Docs](http://collaborne.github.io/paper-random-term-card)_
paper-random-term-card [![Build Status](https://travis-ci.org/Collaborne/paper-random-term-card.svg?branch=master)](https://travis-ci.org/Collaborne/paper-random-term-card)
=========

A Material Design card that displays a random term from the given array (Polymer 1.x)
A Material Design card that displays a random term from the given array (Polymer)

## Install

Expand Down
12 changes: 5 additions & 7 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"authors": [
"collaborne"
],
"description": "A Material Design card that displays a random term from the given array (Polymer 1.x)",
"description": "A Material Design card that displays a random term from the given array (Polymer)",
"main": "paper-random-term-card.html",
"keywords": [
"web-components",
Expand All @@ -19,13 +19,11 @@
"**/.*"
],
"dependencies": {
"polymer": "Polymer/polymer#^1.0.0",
"paper-card": "PolymerElements/paper-card#^1.0.0"
"polymer": "Polymer/polymer#^2.0.0",
"paper-card": "PolymerElements/paper-card#^2.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "*",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
"iron-component-page": "PolymerElements/iron-component-page#^2.0.0",
"web-component-tester": "*"
}
}
35 changes: 19 additions & 16 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
</head>

<body>
<template is="dom-bind">
<paper-random-term-card id="random" selected="----" values="[[values]]"></paper-random-term-card>
<paper-button raised on-tap="next">Next</paper-button>
</template>
<dom-bind>
<template>
<paper-random-term-card id="random" selected="----" values="[[values]]"></paper-random-term-card><br>
<br>
<paper-button raised on-tap="next">Next</paper-button>

<script>
var scope = document.querySelector('template[is=dom-bind]');
scope.next = function() {
this.$.random.next();
};
scope.values = [
"Value 1",
"Value 2",
"Value 3",
"Value 4"
];
</script>
<script>
var scope = document.querySelector('dom-bind');
scope.next = function() {
this.$.random.next();
};
scope.values = [
"Value 1",
"Value 2",
"Value 3",
"Value 4"
];
</script>
</template>
</dom-bind>
</body>
</html>
7 changes: 4 additions & 3 deletions paper-random-term-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<template>
<style>
paper-card {
@apply(--paper-random-term-card);
@apply --paper-random-term-card;
}
</style>
<paper-card>
Expand Down Expand Up @@ -67,9 +67,10 @@
this.selected = this.values[0];
return;
}

// Select a new random value which is not the current value
var currentIndex = this.values.indexOf(this.selected);
var nextIndex = undefined;
const currentIndex = this.values.indexOf(this.selected);
let nextIndex = undefined;
do {
nextIndex = Math.floor(Math.random() * this.values.length);
} while (nextIndex === currentIndex);
Expand Down

0 comments on commit ded2fd1

Please sign in to comment.