Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ehab-hassan committed Feb 3, 2025
1 parent 7dcf876 commit 0e6c045
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 65 deletions.
8 changes: 2 additions & 6 deletions static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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');
}
Expand Down
115 changes: 56 additions & 59 deletions templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@
</a>
</li>
</ul> -->
<button class="theme-toggle px-2 mx-2">
<button class="theme-toggle mx-4">
<label for="lightModeSwitch" class="switch">
<i class="fa-solid fa-sun" id="lightIcon"></i>
<input type="checkbox" id="lightModeSwitch">
<span class="slider"></span>
<i class="fas fa-moon" id="darkIcon"></i>
<i class="fa-solid fa-sun" id="lightIcon"></i>
<input type="checkbox" id="lightModeSwitch">
<span class="slider"></span>
<i class="fas fa-moon" id="darkIcon"></i>
</label>
</button>
</button>



Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}

</style>

0 comments on commit 0e6c045

Please sign in to comment.