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

apply dark moode in feedback form #216

Merged
merged 3 commits into from
Jun 6, 2024
Merged
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
151 changes: 142 additions & 9 deletions Official_Website/darkmode.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,148 @@
/* app.js */
// darkmode.js

function toggleTheme() {
document.body.classList.toggle("dark-mode");
document.querySelector("header").classList.toggle("dark-mode");
document.querySelector(".sponsor-button").classList.toggle("dark-mode");
document.querySelectorAll(".icons a").forEach((icon) => {
icon.classList.toggle("dark-mode");

// Check if dark mode is currently active and store the preference
if (document.body.classList.contains("dark-mode")) {
localStorage.setItem("theme", "dark");
} else {
localStorage.setItem("theme", "light");
}

applyThemeToElements();
}

function applyThemeToElements() {
const darkMode = document.body.classList.contains("dark-mode");
const elements = [
document.querySelector("header"),
document.querySelector(".sponsor-button"),
...document.querySelectorAll(".icons a"),
document.getElementById("search-bar"),
document.getElementById("search-box"),
...document.querySelectorAll("#folders-container div"),
document.querySelector(".feedback"),
document.querySelector("#feedback-section"),
...document.querySelectorAll(".feedback-form input"),
...document.querySelectorAll(".feedback-form textarea"),
...document.querySelectorAll(".feedback-form button")
];

elements.forEach((element) => {
if (element) {
if (darkMode) {
element.classList.add("dark-mode");
} else {
element.classList.remove("dark-mode");
}
}
});
}

function loadTheme() {
const theme = localStorage.getItem("theme");
if (theme === "dark") {
document.body.classList.add("dark-mode");
} else {
document.body.classList.remove("dark-mode");
}
applyThemeToElements();
}

document.addEventListener("DOMContentLoaded", loadTheme);


function toggleTheme() {
document.body.classList.toggle('dark-mode');
document.querySelectorAll('.card-header').forEach(element => {
element.classList.toggle('dark-mode');
});
document.querySelectorAll('.card-body').forEach(element => {
element.classList.toggle('dark-mode');
});
document.getElementById("search-bar").classList.toggle("dark-mode");
document.getElementById("search-box").classList.toggle("dark-mode");
document.querySelectorAll("#folders-container div").forEach((folder) => {
folder.classList.toggle("dark-mode");
document.querySelectorAll('.about-button1').forEach(element => {
element.classList.toggle('dark-mode');
});
document.querySelectorAll('.nav__item a').forEach(element => {
element.classList.toggle('dark-mode');
});
document.body.classList.toggle('dark-mode'); // Toggle dark mode on the body

// Toggle dark mode on specific elements as needed
document.querySelectorAll('.header').forEach(element => {
element.classList.toggle('dark-mode');
});

document.querySelectorAll('.nav__item a').forEach(element => {
element.classList.toggle('dark-mode');
});

document.querySelectorAll('.about-button').forEach(element => {
element.classList.toggle('dark-mode');
});
}
// darkmode.js

function toggleTheme() {
document.body.classList.toggle("dark-mode");

// Check if dark mode is currently active and store the preference
if (document.body.classList.contains("dark-mode")) {
localStorage.setItem("theme", "dark");
} else {
localStorage.setItem("theme", "light");
}

applyThemeToElements();
}

function applyThemeToElements() {
const darkMode = document.body.classList.contains("dark-mode");
const elements = [
document.querySelector("header"),
document.querySelector(".sponsor-button"),
...document.querySelectorAll(".icons a"),
document.getElementById("search-bar"),
document.getElementById("search-box"),
document.getElementById("folders-container"), // Add folders-container here
document.querySelector(".feedback"),
document.querySelector("#feedback-section"),
...document.querySelectorAll(".feedback-form input"),
...document.querySelectorAll(".feedback-form textarea"),
...document.querySelectorAll(".feedback-form button")
];

elements.forEach((element) => {
if (element) {
if (darkMode) {
element.classList.add("dark-mode");
} else {
element.classList.remove("dark-mode");
}
}
});
}

function loadTheme() {
const theme = localStorage.getItem("theme");
if (theme === "dark") {
document.body.classList.add("dark-mode");
} else {
document.body.classList.remove("dark-mode");
}
applyThemeToElements();
}

document.addEventListener("DOMContentLoaded", loadTheme);

// Additional logic for specific elements as per your design
document.addEventListener("DOMContentLoaded", function () {
// Example: Apply dark mode to folders-container initially
const foldersContainer = document.getElementById("folders-container");
if (localStorage.getItem("theme") === "dark") {
foldersContainer.classList.add("dark-mode");
} else {
foldersContainer.classList.remove("dark-mode");
}
});
Loading
Loading