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

Add Dark Mode Feature #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,23 @@ const handleResolve = async () => {
log(`❌ Rejected the color ${err}.`, true);
};
};

// Function to toggle Dark Mode on or off
function toggleDarkMode() {
// Get a reference to the document's body element
const body = document.body;

// Toggle the "dark-mode" class on the body element to change the theme
body.classList.toggle("dark-mode");

// Check if Dark Mode is active after toggling
const isDarkMode = body.classList.contains("dark-mode");

// Store the Dark Mode preference in local storage for future visits
localStorage.setItem("darkMode", isDarkMode);
}

// Check if the user has previously enabled Dark Mode and apply it
if (localStorage.getItem("darkMode") === "true") {
document.body.classList.add("dark-mode");
}
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
<main>
<header>
<h1>🤝 PromiViz</h1>

<!-- This code adds a button for toggling Dark Mode.
The button's click event is handled by JavaScript functions
that enable users to switch between light and dark themes. -->
<div>
<span style="font-size:30px;cursor:pointer" onclick="toggleNav()">&#9776;</span>
<button id="dark-mode-toggle" onclick="toggleDarkMode()">Toggle Dark Mode</button>
</div>

<div>
<span style="font-size:30px;cursor:pointer" onclick="toggleNav()">&#9776;</span>
</div>
Expand Down Expand Up @@ -228,4 +237,4 @@ <h2>Logs</h2>

<script src="./app.js"></script>
</body>
</html>
</html>
7 changes: 7 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ body.black {
background-size: 100% 820px;
}

/* Dark Mode Styles */
.dark-mode {
background-color: #333; /* Change to your preferred dark background color */
color: #fff; /* Change to your preferred dark text color */
}
/* Add any other styles for Dark Mode here */

/* changes */
select {
height: 25px;
Expand Down