From 0e6c045411a73258815eea18663f73d0c427c455 Mon Sep 17 00:00:00 2001 From: ehab-hassan Date: Mon, 3 Feb 2025 18:31:57 +0200 Subject: [PATCH] update --- static/js/custom.js | 8 +-- templates/partials/header.html | 115 ++++++++++++++++----------------- 2 files changed, 58 insertions(+), 65 deletions(-) diff --git a/static/js/custom.js b/static/js/custom.js index f11c7adf1..f165a0c95 100644 --- a/static/js/custom.js +++ b/static/js/custom.js @@ -198,16 +198,14 @@ document.getElementById("year").innerHTML = new Date().getFullYear(); const toggleSwitch = document.getElementById('lightModeSwitch'); const body = document.body; -// Apply the saved theme on load +// Apply saved theme on load document.addEventListener('DOMContentLoaded', () => { - const savedTheme = localStorage.getItem('theme') || 'dark'; // Default to dark mode + const savedTheme = localStorage.getItem('theme') || 'dark'; // Default is dark mode if (savedTheme === 'light') { body.classList.add('light-mode'); - body.classList.remove('dark-mode'); toggleSwitch.checked = true; } else { - body.classList.add('dark-mode'); body.classList.remove('light-mode'); toggleSwitch.checked = false; } @@ -217,10 +215,8 @@ document.addEventListener('DOMContentLoaded', () => { toggleSwitch.addEventListener('change', () => { if (toggleSwitch.checked) { body.classList.add('light-mode'); - body.classList.remove('dark-mode'); localStorage.setItem('theme', 'light'); } else { - body.classList.add('dark-mode'); body.classList.remove('light-mode'); localStorage.setItem('theme', 'dark'); } diff --git a/templates/partials/header.html b/templates/partials/header.html index 0775e7f14..0f0051b42 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -116,14 +116,14 @@ --> - + @@ -236,6 +236,20 @@ color: #c7c7c7 !important; } +.active{ + color: #c7c7c7 !important; +} +.nav_btn:hover { + color: #c7c7c7 !important; +} + +.theme-toggle { + border: none !important; + box-shadow: none !important; +} + +/* logo image */ + .light { display: block; /* Show dark logo by default */ @@ -254,80 +268,63 @@ display: block;/* Show light logo in light mode */ } -.theme-toggle { - border: none !important; - box-shadow: none !important; -} - -.active{ - color: #c7c7c7 !important; -} -.nav_btn:hover { - color: #c7c7c7 !important; -} - - +/* Styling for the switch container */ .switch { position: relative; - display: inline-block; - width: 60px; - height: 34px; + display: inline-flex; + align-items: center; + width: 50px; + height: 25px; + background: #ccc; + border-radius: 50px; + cursor: pointer; + transition: background 0.3s ease-in-out; } +/* Hide the default checkbox */ .switch input { opacity: 0; width: 0; height: 0; } +/* Slider (toggle button) */ .slider { position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: #ccc; - transition: .4s; - border-radius: 34px; -} - -.slider:before { - position: absolute; - content: ""; - height: 26px; - width: 26px; - left: 4px; - bottom: 4px; - background-color: white; + top: 2px; + left: 3px; + width: 20px; + height: 20px; + background: white; border-radius: 50%; - transition: .4s; + transition: transform 0.3s ease-in-out; } -input:checked + .slider { - background-color: #2196F3; +/* Show moon by default (dark mode) */ +#lightIcon { + display: block; + margin-left: 5px; + color: white; } - -input:checked + .slider:before { - transform: translateX(26px); +#darkIcon { + display: inline-block; + margin-left: 5px; } -/* Icons */ -#lightIcon, #darkIcon { - position: absolute; - top: 50%; - transform: translateY(-50%); - font-size: 16px; +/* When light mode is active */ +.light-mode .switch { + background: #111; /* Dark background in light mode */ +} +.light-mode .slider { + transform: translateX(25px); /* Move slider to the right */ +} +.light-mode #lightIcon { + display: inline-block; color: white; } - -#lightIcon { - left: 10px; - display: none; /* Hide by default */ +.light-mode #darkIcon { + display: none; } -#darkIcon { - right: 10px; -} \ No newline at end of file