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

Small fixes #99

Merged
merged 3 commits into from
Oct 29, 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
4 changes: 0 additions & 4 deletions example.env

This file was deleted.

16 changes: 11 additions & 5 deletions public/js/script.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
document.addEventListener('DOMContentLoaded', function(){
const darkModeToggle = document.getElementById("dark-mode-toggle");
const icon=document.getElementById('dark-icon');
const body = document.body;

const savedDarkMode = localStorage.getItem('darkMode');
if (savedDarkMode == 'enabled') {

body.classList.add('dark-mode');
icon.classList.add('fa-sun')
} else {
body.classList.remove('dark-mode');
if (darkModeToggle) darkModeToggle.textContent ='Dark Mode';
icon.classList.add('fa-moon')
}


if (darkModeToggle) {

darkModeToggle.addEventListener("click", function() {
body.classList.toggle("dark-mode");

if (body.classList.contains('dark-mode')){
localStorage.setItem('darkMode','enabled');
darkModeToggle.textContent ="Light Mode";
icon.classList.remove('fa-moon');
icon.classList.add('fa-sun');
} else {
localStorage.setItem('darkMode','disabled');
darkModeToggle.textContent ="Dark Mode";
icon.classList.remove('fa-sun');
icon.classList.add('fa-moon');
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions views/contact.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="contact-section">
<div class="contact-container">
<section class="welcome-section ">
<!-- <div class="contact-container"> -->
<h1>Contact Us</h1>
<p>If you have any questions or feedback, feel free to reach out!</p>

Expand All @@ -25,5 +25,5 @@
</div>
<button type="submit" class="btn-submit">Send Message</button>
</form>
</div>
<!-- </div> -->
</section>
8 changes: 1 addition & 7 deletions views/layouts/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
<div class="container">

<%- include('../partials/header.ejs') %>
<!-- Dark Mode Toggle Button -->
<div>
<button id="dark-mode-toggle">Dark Mode</button>
</div>

<%- include('../partials/header.ejs', { currentRoute: locals.currentRoute }) %>


<main class="main">
<%- body %>
</main>
Expand Down
10 changes: 6 additions & 4 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<li>
<a href="/contact" class="<%= isActiveRoute('/contact', currentRoute) %>">Contact</a>
</li>
<li>
<a href="/admin" class="<%= isActiveRoute('/admin', currentRoute) %>">Login</a>
</li>
<li>
<a href="/add-post" class="<%= isActiveRoute('/admin', currentRoute) %>">Post</a>
</li>
Expand All @@ -38,7 +35,12 @@
<button id="LogIn" onclick="window.location.href = '/admin'">Log In</button>
<% } %>


<!-- Dark Mode Toggle Button -->
<button id="dark-mode-toggle" style="margin-left: 0.5rem;">
<i class="fa-solid" id="dark-icon"></i>
</button>


</div>

</header>
Expand Down
Loading