This repository has been archived by the owner on Aug 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.js
57 lines (45 loc) · 1.48 KB
/
shell.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
(function() {
// RANDOM INITIAL COLOR
const vibrantMaterialColors = [
"#f44336", // red
"#e91e63", // pink
"#9c27b0", // purple
"#673ab7", // deepPurple
"#3f51b5", // indigo
"#2196f3", // blue
"#03a9f4", // lightBlue
"#00bcd4", // cyan
"#009688", // teal
"#4caf50", // green
"#8bc34a", // lightGreen
"#cddc39", // lime
"#ffc107", // amber
"#ff9800", // orange
"#ff5722", // deepOrange
];
const initialColor = vibrantMaterialColors[
Math.floor(Math.random() * vibrantMaterialColors.length)
];
const headerStyle = document.createElement('style');
document.head.appendChild(headerStyle);
const timerControls = document.querySelector('timer-controls');
const timerDisplay = document.querySelector('timer-display');
const setInitialColor = function(color) {
headerStyle.textContent = '.control-panel h1{color:' + color + '}';
timerDisplay.setAttribute('default-color', color);
};
setInitialColor(initialColor);
// WIRE UP CUSTOM ELEMENTS
timerControls.setAttribute('initial-color', initialColor);
timerControls.addEventListener('initial-color', function(event) {
setInitialColor(event.detail.color);
});
timerControls.addEventListener('start-timer', function() {
timerDisplay.removeAttribute('paused');
});
timerControls.addEventListener('color-breakpoints', function(event) {
timerDisplay.setAttribute('color-breakpoints',
JSON.stringify(event.detail.breakpoints)
);
});
}());