mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-11-24 09:03:39 +01:00
36 lines
720 B
JavaScript
36 lines
720 B
JavaScript
var theme = (function() {
|
|
|
|
var render = function() {
|
|
var html = helper.e("html");
|
|
var color = state.get().layout.theme.current;
|
|
html.style.setProperty("--accent", color.r + ", " + color.g + ", " + color.b);
|
|
};
|
|
|
|
var random = function() {
|
|
if (state.get().layout.theme.random) {
|
|
var randomColor = {
|
|
r: helper.randomNumber(0, 255),
|
|
g: helper.randomNumber(0, 255),
|
|
b: helper.randomNumber(0, 255)
|
|
};
|
|
state.change({
|
|
path: "layout.theme.current",
|
|
value: randomColor
|
|
});
|
|
};
|
|
};
|
|
|
|
var init = function() {
|
|
random();
|
|
render();
|
|
};
|
|
|
|
// exposed methods
|
|
return {
|
|
init: init,
|
|
random: random,
|
|
render: render
|
|
};
|
|
|
|
})();
|