-
Notifications
You must be signed in to change notification settings - Fork 6
/
maxq-button.html
114 lines (98 loc) · 2.46 KB
/
maxq-button.html
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
<link rel="import" href="../polymer/polymer-element.html">
<dom-module id="maxq-button">
<template>
<style>
:host {
display: inline-flex;
font-family: inherit;
height: 32px;
border-radius: 32px;
padding: 0 16px;
font-size: 16px;
align-items: center;
background-color: #ebebeb;
transition: background-color 0.2s ease;
outline: none;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
:host(:hover) {
background-color: #f5f5f5;
}
:host(:active) {
background-color: #e1e1e1;
}
:host(.primary) {
background-color: #3569a4;
color: white;
}
:host(.primary:hover) {
background-color: #4978ad;
}
:host(.primary:active) {
background-color: #2B5384;
}
:host(.group-element:first-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
:host(.group-element:last-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
:host(.group-element:not(:first-child):not(:last-child)) {
border-radius: 0;
}
:host(.group-element:not(:last-child)) {
border-right: 1px solid #ddd;
margin-right: -4px;
}
:host([toggles][active]) {
background-color: #e1e1e1;
}
:host(.primary[toggles][active]) {
background-color: #2B5384;
}
</style>
<slot></slot>
</template>
<script>
/**
* `maxq-button`
* A button for the MaxQ design system
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class MaxqButton extends Polymer.Element {
static get is() { return 'maxq-button'; }
static get properties() {
return {
toggles: {
type: Boolean,
value: false,
reflectToAttribute: true,
observer: '_togglesChanged'
},
active: {
type: Boolean,
value: false,
reflectToAttribute: true
}
};
}
constructor() {
super();
this.tabIndex = 0;
}
_togglesChanged(newVal, oldVal) {
this.addEventListener('click', (e) => {
this.active = !this.active;
});
}
}
window.customElements.define(MaxqButton.is, MaxqButton);
</script>
</dom-module>