Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #704: Footer doesn't reflect theme changes solved #760

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 44 additions & 19 deletions darkMode.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
const checkbox = document.getElementById('checkbox')
const modeLabel = document.getElementById('mode-label')
// const checkbox = document.getElementById('checkbox')
// const modeLabel = document.getElementById('mode-label')

// Check if dark mode is already enabled
if (localStorage.getItem('theme') === 'dark') {
document.documentElement.setAttribute('data-theme', 'dark')
checkbox.checked = true
modeLabel.textContent = 'Dark Mode'
// // Check if dark mode is already enabled
// if (localStorage.getItem('theme') === 'dark') {
// document.documentElement.setAttribute('data-theme', 'dark')
// checkbox.checked = true
// modeLabel.textContent = 'Dark Mode'
// }

// // Add event listener for toggle switch
// checkbox.addEventListener('change', () => {
// if (checkbox.checked) {
// document.documentElement.setAttribute('data-theme', 'dark')
// localStorage.setItem('theme', 'dark')
// modeLabel.textContent = 'Dark Mode'
// } else {
// document.documentElement.setAttribute('data-theme', 'light')
// localStorage.setItem('theme', 'light')
// modeLabel.textContent = 'Light Mode'
// }
// })

// Variables
const themeToggle = document.getElementById('theme-toggle');
const darkTheme = 'dark-theme';
const iconTheme = 'ri-sun-line';

// Previously selected theme (if user selected)
const selectedTheme = localStorage.getItem('selected-theme');

// Determine current theme
const getCurrentTheme = () => document.body.classList.contains(darkTheme) ? 'dark' : 'light';

// Apply the previously selected theme, if any
if (selectedTheme) {
document.body.classList[selectedTheme === 'dark' ? 'add' : 'remove'](darkTheme);
themeToggle.checked = selectedTheme === 'dark'; // Set checkbox based on theme
}

// Add event listener for toggle switch
checkbox.addEventListener('change', () => {
if (checkbox.checked) {
document.documentElement.setAttribute('data-theme', 'dark')
localStorage.setItem('theme', 'dark')
modeLabel.textContent = 'Dark Mode'
} else {
document.documentElement.setAttribute('data-theme', 'light')
localStorage.setItem('theme', 'light')
modeLabel.textContent = 'Light Mode'
}
})
// Toggle theme on checkbox change
themeToggle.addEventListener('change', () => {
document.body.classList.toggle(darkTheme);

// Save selected theme
localStorage.setItem('selected-theme', getCurrentTheme());
});
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<link rel="stylesheet" href="./popup/popup.css" />
<link rel ="stylesheet" href="./Loader/Loader.css"/>
<link rel="manifest" href="/manifest.json">
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css" rel="stylesheet"> -->

</head>

<body>
Expand Down Expand Up @@ -82,6 +84,8 @@
<input type="checkbox" id="theme-toggle" onchange="toggleTheme()">
<span class="slider"></span>
</label></li>


</ul>
<!-- Hamburger Menu Icon -->
<img src="images/menu.png" class="menu-icon" onclick="toggleMenu()">
Expand Down Expand Up @@ -640,7 +644,7 @@ <h2>Contact Our Customer Support Team</h2>
</section>


<footer class="footer">
<footer class="footer" >
<div class="footer-content">
<div class="footer-section about">
<div class="logo-container">
Expand Down
6 changes: 6 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ button {
float: none;
}
}
/* General dark theme for the body */
.dark-theme {
background-color: #121212;
color: #f5f5f5;
}


.close-btn {
position: absolute;
Expand Down
Loading