diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index ce9a68c..a15a43b 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -51,7 +51,7 @@ body { background-repeat: repeat; } -[data-bs-theme="dark"] html { +[data-bs-theme="dark"] body { background-image: url('../images/background_dark.svg'); } @@ -551,15 +551,6 @@ div { display: none; } -/* ===== Dark Mode (Bootstrap 5.3: data-bs-theme="dark") ===== */ - -/* --- style.css --- */ -[data-bs-theme="dark"] body, -[data-bs-theme="dark"] .navbar-background { - background-image: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.75)), - url('../images/background.jpg'); -} - [data-bs-theme="dark"] .mainpage { background-color: rgba(33, 37, 41, 0.6); } diff --git a/src/main/resources/static/images/Icon_Dunkelmodus_hover.svg b/src/main/resources/static/images/Icon_Dunkelmodus_hover.svg index 119077e..ddbe8a6 100644 --- a/src/main/resources/static/images/Icon_Dunkelmodus_hover.svg +++ b/src/main/resources/static/images/Icon_Dunkelmodus_hover.svg @@ -9,7 +9,7 @@ } .cls-1, .cls-2 { - stroke: #ffffcc; + stroke: #008b8b; } .cls-1, .cls-2, .cls-3 { diff --git a/src/main/resources/static/images/Icon_Hellmodus.svg b/src/main/resources/static/images/Icon_Hellmodus.svg index df73522..4818562 100644 --- a/src/main/resources/static/images/Icon_Hellmodus.svg +++ b/src/main/resources/static/images/Icon_Hellmodus.svg @@ -9,7 +9,7 @@ } .cls-1, .cls-2 { - stroke: #313122; + stroke: #c1c1aa; } .cls-1, .cls-2, .cls-3 { diff --git a/src/main/resources/static/js/progress.js b/src/main/resources/static/js/progress.js index 6f9df27..fa02896 100644 --- a/src/main/resources/static/js/progress.js +++ b/src/main/resources/static/js/progress.js @@ -7,16 +7,3 @@ progress = { $("#requestopen").remove(); } } - - (function() { - const saved = localStorage.getItem('theme'); - const preferred = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; - document.documentElement.setAttribute('data-bs-theme', saved || preferred); - })(); - - function toggleTheme() { - const html = document.documentElement; - const next = html.getAttribute('data-bs-theme') === 'dark' ? 'light' : 'dark'; - html.setAttribute('data-bs-theme', next); - localStorage.setItem('theme', next); - } diff --git a/src/main/resources/static/js/theme.js b/src/main/resources/static/js/theme.js new file mode 100644 index 0000000..83e1414 --- /dev/null +++ b/src/main/resources/static/js/theme.js @@ -0,0 +1,47 @@ +(function () { + 'use strict'; + + var STORAGE_KEY = 'theme'; + var root = document.documentElement; + + function getStoredTheme() { + try { + return localStorage.getItem(STORAGE_KEY); + } catch (e) { + return null; + } + } + + function storeTheme(theme) { + try { + localStorage.setItem(STORAGE_KEY, theme); + } catch (e) { + } + } + + function getPreferredTheme() { + var stored = getStoredTheme(); + if (stored === 'dark' || stored === 'light') { + return stored; + } + return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + } + + function applyTheme(theme) { + root.setAttribute('data-bs-theme', theme); + } + + applyTheme(getPreferredTheme()); + + window.toggleTheme = function () { + var next = root.getAttribute('data-bs-theme') === 'dark' ? 'light' : 'dark'; + applyTheme(next); + storeTheme(next); + }; + + window.addEventListener('storage', function (e) { + if (e.key === STORAGE_KEY && (e.newValue === 'dark' || e.newValue === 'light')) { + applyTheme(e.newValue); + } + }); +})(); diff --git a/src/main/resources/templates/template.html b/src/main/resources/templates/template.html index 7eb5d6c..a3afba5 100644 --- a/src/main/resources/templates/template.html +++ b/src/main/resources/templates/template.html @@ -4,6 +4,7 @@