-
Notifications
You must be signed in to change notification settings - Fork 1
/
cube-color.js
45 lines (38 loc) · 1004 Bytes
/
cube-color.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
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js';
class CubeColor extends PolymerElement {
static get is() {return 'cube-color'}
static get template() { return html``}
static get properties()
{
return {
theme: {type: String},
grade: {type: Number},
out: {type: String, notify: true}
}
}
static get observers()
{
return [
'_computeColor(theme, grade)'
]
}
_computeColor(theme, grade)
{
let self = this;
this.out = '';
import('./styles/' + this.theme + '.js')
.then(
module => {
let style = self.querySelector('style');
if(!style)
{
style = document.createElement('style');
self.root.appendChild(style);
}
style.innerHTML = module.default;
self.out = getComputedStyle(self).getPropertyValue('--' + theme + '-' + grade + '-color');
}
);
}
}
customElements.define(CubeColor.is, CubeColor);