update icon buttons

This commit is contained in:
Luke Pulverenti 2016-06-05 16:46:19 -04:00
parent b7189bf6f8
commit 7f98cdfec2
27 changed files with 203 additions and 64 deletions

View file

@ -81,6 +81,72 @@
margin-left: .5em;
}
[is=paper-icon-button-light] {
position: relative;
display: inline-block;
align-items: center;
box-sizing: border-box;
margin: 0 .29em;
background: transparent;
text-align: center;
font-size: inherit;
font-family: inherit;
color: inherit;
outline-width: 0;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
z-index: 0;
width: 40px;
height: 40px;
padding: 8px;
font-weight: normal;
vertical-align: middle;
border: 0;
vertical-align: middle;
/* These are getting an outline in opera tv browsers, which run chrome 30 */
outline: none !important;
position: relative;
overflow: hidden;
font-weight: 500;
text-transform: uppercase;
border-radius: 50%;
}
[is=paper-icon-button-light] iron-icon {
width: 100%;
height: 100%;
/* Make sure its on top of the ripple */
position: relative;
z-index: 1;
}
[is=paper-icon-button-light] img {
width: 100%;
height: 100%;
/* Make sure its on top of the ripple */
position: relative;
z-index: 1;
}
[is=paper-icon-button-light]:after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
transition: opacity .3s ease-out;
background: currentcolor;
opacity: 0;
}
[is=paper-icon-button-light]:focus:after {
opacity: .3;
}
.ripple-effect {
position: absolute;
border-radius: 50%;

View file

@ -2,9 +2,8 @@
var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
function animateButton(e) {
function animateButtonInternal(e, btn) {
var btn = this;
var div = document.createElement('div');
div.classList.add('ripple-effect');
@ -24,6 +23,14 @@
}, false);
}
function animateButton(e) {
var btn = this;
requestAnimationFrame(function () {
animateButtonInternal(e, btn);
});
}
function onKeyDown(e) {
if (e.keyCode == 13) {

View file

@ -0,0 +1,57 @@
define(['css!./emby-button'], function () {
var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
function animateButtonInternal(e, btn) {
var div = document.createElement('div');
div.classList.add('ripple-effect');
var offsetX = e.offsetX || 0;
var offsetY = e.offsetY || 0;
if (offsetX > 0 && offsetY > 0) {
div.style.left = offsetX + 'px';
div.style.top = offsetY + 'px';
}
btn.appendChild(div);
div.addEventListener("animationend", function () {
div.parentNode.removeChild(div);
}, false);
}
function animateButton(e) {
var btn = this;
requestAnimationFrame(function () {
animateButtonInternal(e, btn);
});
}
function onKeyDown(e) {
if (e.keyCode == 13) {
animateButton.call(this, e);
}
}
EmbyButtonPrototype.attachedCallback = function () {
if (this.getAttribute('data-embybutton') == 'true') {
return;
}
this.setAttribute('data-embybutton', 'true');
this.addEventListener('keydown', onKeyDown);
this.addEventListener('click', animateButton);
};
document.registerElement('paper-icon-button-light', {
prototype: EmbyButtonPrototype,
extends: 'button'
});
});