forked from Saulis/iron-data-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-table-checkbox.html
141 lines (124 loc) · 3.22 KB
/
data-table-checkbox.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<dom-module id="data-table-checkbox">
<template>
<style>
:host {
height: 48px;
flex-basis: 48px;
flex-grow: 0;
flex-shrink: 0;
padding: 0 8px 0 12px;
display: flex;
align-items: center;
justify-content: center;
border-right: 1px solid #e3e3e3;
}
:host([header]) {
height: 56px;
}
:host([hidden]) {
display: none;
}
:host(:focus) {
outline: none;
}
#container {
position: relative;
box-sizing: border-box;
height: 18px;
width: 18px;
border: solid 2px;
border-color: var(--primary-text-color);
border-radius: 2px;
pointer-events: none;
-webkit-transition: background-color 140ms, border-color 140ms;
transition: background-color 140ms, border-color 140ms;
}
:host([checked]) #container {
border-color: var(--default-primary-color);
background-color: var(--default-primary-color);
}
:host([checked]) .checkmark {
border-bottom: 2px solid white;
border-right: 2px solid white;
width: 36%;
height: 70%;
-webkit-transform-origin: 97% 86%;
transform-origin: 97% 86%;
-webkit-animation: checkmark-expand 140ms ease-out forwards;
animation: checkmark-expand 140ms ease-out forwards;
}
@-webkit-keyframes checkmark-expand {
0% {
-webkit-transform: scale(0, 0) rotate(45deg);
}
100% {
-webkit-transform: scale(1, 1) rotate(45deg);
}
}
@keyframes checkmark-expand {
0% {
transform: scale(0, 0) rotate(45deg);
}
100% {
transform: scale(1, 1) rotate(45deg);
}
}
:host([indeterminate]) .checkmark {
border-bottom: 2px solid var(--primary-text-color);
width: 60%;
height: 45%;
margin-left: 3px;
-webkit-animation: indeterminate-expand 140ms ease-out forwards;
animation: indeterminate-expand 140ms ease-out forwards;
}
@-webkit-keyframes indeterminate-expand {
0% {
-webkit-transform: scale(0, 0);
}
100% {
-webkit-transform: scale(1, 1);
}
}
@keyframes indeterminate-expand {
0% {
transform: scale(0, 1);
}
100% {
transform: scale(1, 1);
}
}
</style>
<div id="container">
<div class="checkmark"></div>
</div>
</template>
<script>
Polymer({
is: 'data-table-checkbox',
properties: {
checked: {
type: Boolean,
observer: '_checkedChanged',
reflectToAttribute: true,
value: false
},
indeterminate: {
type: Boolean,
reflectToAttribute: true,
observer: '_indeterminateChanged',
value: false
}
},
_checkedChanged: function(checked) {
if (checked) {
this.indeterminate = false;
}
},
_indeterminateChanged: function(indeterminate) {
if (indeterminate) {
this.checked = false;
}
}
});
</script>
</dom-module>