From d65d6e5da4c3be16791564910ea5461f4049e890 Mon Sep 17 00:00:00 2001 From: shpuld Date: Sat, 18 Nov 2017 13:13:51 +0200 Subject: Clean up, use translations, persist theme, add more presets. --- src/services/style_setter/style_setter.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/services') diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index bbb2c510..92ba9440 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -98,13 +98,14 @@ const setColors = (col, commit) => { styleSheet.insertRule(`.base0${8 - n}-background { background-color: ${color}`, 'index-max') }) - commit('setOption', { name: 'colors', value: colors }) - styleSheet.insertRule(`a { color: ${colors['base08']}`, 'index-max') styleSheet.insertRule(`body { color: ${colors['base05']}`, 'index-max') styleSheet.insertRule(`.base05-border { border-color: ${colors['base05']}`, 'index-max') styleSheet.insertRule(`.base03-border { border-color: ${colors['base03']}`, 'index-max') body.style.display = 'initial' + + commit('setOption', { name: 'colors', value: colors }) + commit('setOption', { name: 'customTheme', value: col }) } const hex2rgb = (hex) => { @@ -131,8 +132,15 @@ const setPreset = (val, commit) => { text: textRgb, link: linkRgb } - console.log(col) - setColors(col, commit) + // This is a hack, this function is only called during initial load. + // We want to cancel loading the theme from config.json if we're already + // loading a theme from the persisted state. + // Needed some way of dealing with the async way of things. + // load config -> set preset -> wait for styles.json to load -> + // load persisted state -> set colors -> styles.json loaded -> set colors + if (!window.themeLoaded) { + setColors(col, commit) + } }) } -- cgit v1.2.3-70-g09d2