Skip to content

Commit

Permalink
Merge pull request #494 from REHAN-18/new
Browse files Browse the repository at this point in the history
fix the bugs ,ui, signup,feedback ui.. & REPONSIVE
  • Loading branch information
YadavAkhileshh authored Oct 22, 2024
2 parents 6486ff7 + ee74784 commit 982f547
Show file tree
Hide file tree
Showing 5 changed files with 406 additions and 472 deletions.
47 changes: 29 additions & 18 deletions darkMode.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
const checkbox = document.getElementById('checkbox')
const modeLabel = document.getElementById('mode-label')
document.addEventListener('DOMContentLoaded', () => {
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 checkbox and modeLabel exist
if (!checkbox || !modeLabel) {
console.error('Checkbox or Mode Label element not found!');
return;
}

// 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'
// 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';
} else {
document.documentElement.setAttribute('data-theme', 'light')
localStorage.setItem('theme', 'light')
modeLabel.textContent = 'Light Mode'
document.documentElement.setAttribute('data-theme', 'light');
modeLabel.textContent = 'Light Mode';
}
})

// Add event listener for the 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';
}
});
});
Loading

0 comments on commit 982f547

Please sign in to comment.