This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathpaper-button.js
133 lines (110 loc) · 3.25 KB
/
paper-button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import '../polymer/polymer.js';
import '../iron-flex-layout/iron-flex-layout.js';
import { PaperButtonBehavior, PaperButtonBehaviorImpl } from '../paper-behaviors/paper-button-behavior.js';
import '../paper-styles/element-styles/paper-material-styles.js';
import { Polymer } from '../polymer/lib/legacy/polymer-fn.js';
const $_documentContainer = document.createElement('div');
$_documentContainer.setAttribute('style', 'display: none;');
$_documentContainer.innerHTML = `<dom-module id="paper-button">
<template strip-whitespace="">
<style include="paper-material-styles">
/* Need to specify the same specificity as the styles imported from paper-material. */
:host {
@apply --layout-inline;
@apply --layout-center-center;
position: relative;
box-sizing: border-box;
min-width: 5.14em;
margin: 0 0.29em;
background: transparent;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
font: inherit;
text-transform: uppercase;
outline-width: 0;
border-radius: 3px;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
z-index: 0;
padding: 0.7em 0.57em;
@apply --paper-font-common-base;
@apply --paper-button;
}
:host([elevation="1"]) {
@apply --paper-material-elevation-1;
}
:host([elevation="2"]) {
@apply --paper-material-elevation-2;
}
:host([elevation="3"]) {
@apply --paper-material-elevation-3;
}
:host([elevation="4"]) {
@apply --paper-material-elevation-4;
}
:host([elevation="5"]) {
@apply --paper-material-elevation-5;
}
:host([hidden]) {
display: none !important;
}
:host([raised].keyboard-focus) {
font-weight: bold;
@apply --paper-button-raised-keyboard-focus;
}
:host(:not([raised]).keyboard-focus) {
font-weight: bold;
@apply --paper-button-flat-keyboard-focus;
}
:host([disabled]) {
background: #eaeaea;
color: #a8a8a8;
cursor: auto;
pointer-events: none;
@apply --paper-button-disabled;
}
:host([animated]) {
@apply --shadow-transition;
}
paper-ripple {
color: var(--paper-button-ink-color);
}
</style>
<slot></slot>
</template>
</dom-module>`;
document.head.appendChild($_documentContainer);
Polymer({
is: 'paper-button',
behaviors: [
PaperButtonBehavior
],
properties: {
/**
* If true, the button should be styled with a shadow.
*/
raised: {
type: Boolean,
reflectToAttribute: true,
value: false,
observer: '_calculateElevation'
}
},
_calculateElevation: function() {
if (!this.raised) {
this._setElevation(0);
} else {
PaperButtonBehaviorImpl._calculateElevation.apply(this);
}
}
/**
Fired when the animation finishes.
This is useful if you want to wait until
the ripple animation finishes to perform some action.
@event transitionend
Event param: {{node: Object}} detail Contains the animated node.
*/
});