forked from zombieFox/nightTab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.js
More file actions
56 lines (46 loc) · 1001 Bytes
/
Copy paththeme.js
File metadata and controls
56 lines (46 loc) · 1001 Bytes
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
var theme = (function() {
var state = {
r: 255,
g: 170,
b: 51,
};
var get = function() {
return state;
};
var bind = function() {
var themeAccent = helper.e(".theme-input");
themeAccent.addEventListener("change", function() {
_updateAcent(this);
render();
data.save();
});
};
var _updateAcent = function(input) {
state = helper.hexToRgb(input.value);
};
var _updateInput = function() {
var themeAccent = helper.e(".theme-input");
themeAccent.value = helper.rgbToHex(state);
};
var render = function(input) {
var html = helper.e("html");
html.style.setProperty("--accent", state.r + ", " + state.g + ", " + state.b);
};
var restore = function(object) {
if (object) {
state = object;
_updateInput();
render();
};
};
var init = function() {
bind();
};
// exposed methods
return {
init: init,
get: get,
restore: restore,
render: render
};
})();