nightTab/js/theme.js

36 lines
720 B
JavaScript
Raw Normal View History

2018-12-26 08:45:53 +01:00
var theme = (function() {
var render = function() {
2018-12-26 08:45:53 +01:00
var html = helper.e("html");
2019-01-07 15:42:14 +01:00
var color = state.get().layout.theme.current;
html.style.setProperty("--accent", color.r + ", " + color.g + ", " + color.b);
2018-12-26 08:45:53 +01:00
};
2019-01-07 15:42:14 +01:00
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
});
};
};
2018-12-26 08:45:53 +01:00
var init = function() {
2019-01-07 15:42:14 +01:00
random();
render();
2018-12-26 08:45:53 +01:00
};
// exposed methods
return {
init: init,
2019-01-07 15:42:14 +01:00
random: random,
2018-12-26 08:45:53 +01:00
render: render
};
})();