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

Darkmode Toggle added #616

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
50 changes: 48 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,55 @@
<li class="nav-item">
<a class="nav-link" href="#" style="font-family: var(--ff-philosopher); color: black;">More</a>
</li>

<li class="nav-item">
<a class="nav-link" id="themeToggle" style="font-family: var(--ff-philosopher); color: black;">Toggle Theme</a>
</li>
</ul>

<style>
body {
transition: background-color 0.3s, color 0.3s; /* Smooth transition */
background-color: white;
}

.dark-mode {
background-color: #121212; /* Dark background */
color: white; /* Light text color */
}

.navbar {
transition: background-color 0.3s; /* Smooth transition */
background-color: #f8f9fa;
}

.navbar.dark-mode {
background-color: #333; /* Dark navbar background */
}

.navbar .nav-link {
color: black; /* Light navbar text color */
}

.navbar.dark-mode .nav-link {
color: white; /* Dark navbar text color */
}

#themeToggle {
cursor: pointer;
}
</style>
<script>
// JavaScript to toggle between light and dark themes
const themeToggle = document.getElementById('themeToggle');
const body = document.body;
const navbar = document.querySelector('.navbar');

themeToggle.addEventListener('click', () => {
body.classList.toggle('dark-mode');
navbar.classList.toggle('dark-mode');
const isDark = body.classList.contains('dark-mode');
themeToggle.textContent = isDark ? 'Light Mode' : 'Dark Mode';
});
</script>
<div class="navbar-right">
<ul class="navbar-nav">
<li class="nav-item">
Expand Down
3 changes: 3 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

body {
background-color: black;
transition: background-color 0.3s, color 0.3s; /* Smooth transition */
background-color: white; /* Default light background */
color: black; /* Default light text color */
}
/*
.navbar {
Expand Down