diff options
Diffstat (limited to 'src/js/switch-storage.js')
-rw-r--r-- | src/js/switch-storage.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/js/switch-storage.js b/src/js/switch-storage.js new file mode 100644 index 0000000..fb200c4 --- /dev/null +++ b/src/js/switch-storage.js @@ -0,0 +1,13 @@ +// This code is only used to remember theme selection +const themeSwitch = document.getElementById('theme-switch'); +themeSwitch.checked = localStorage.getItem('switchedTheme') === 'true'; + +themeSwitch.addEventListener('change', function (e) { + if(e.currentTarget.checked === true) { + localStorage.setItem('switchedTheme', 'true'); + console.info('Add light theme to localstorage'); + } else { + localStorage.removeItem('switchedTheme'); + console.info('Remove light theme of localstorage'); + } +}); |