Skip to content

Add Dark Mode Toggle and Interactive Mouse Pointer (#86) #101

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

Open
wants to merge 2 commits 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
Binary file added leaf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 56 additions & 1 deletion main.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,59 @@ footer {
background-color: #d1dd63;
transform: translateY(-2px) scale(1.05);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
}
/* 🌙 Dark Mode Styles */
body.dark-mode {
background-color: #121212;
color: #ffffff;
}

header.dark-mode,
nav.dark-mode,
main.dark-mode,
footer.dark-mode {
background-color: #1e1e1e;
color: #ffffff;
}

/* Smooth transition */
body, header, nav, main, footer {
transition: background-color 0.3s ease, color 0.3s ease;
}

/* Hover styles for buttons/links */
a:hover, button:hover {
cursor: pointer;
}
#dark-toggle {
position: fixed;
bottom: 20px; /* changed from top to bottom */
left: 20px; /* changed from right to left */
z-index: 9999;
background-color: #ffffff;
color: #000000;
border: none;
border-radius: 50%;
font-size: 20px;
width: 45px;
height: 45px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
}

#dark-toggle:hover {
background-color: #333333;
color: #ffffff;
transform: scale(1.1);
}

#dark-toggle:hover {
background-color: #333333;
color: #ffffff;
transform: scale(1.1);
}

body {
cursor: url("leaf.png") 16 16, auto;
}

33 changes: 29 additions & 4 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,36 @@ <h3>Crop Price Tracker</h3>

</section>

</main>
</main>

<footer>
<p>&copy; 2025 AgriTech. All rights reserved.</p>
</footer>

<button id="dark-toggle" title="Toggle Dark Mode">🌙</button>

<script>
const toggleButton = document.getElementById('dark-toggle');
const elementsToToggle = ['body', 'header', 'nav', 'main', 'footer'];

toggleButton.addEventListener('click', () => {
elementsToToggle.forEach(selector => {
document.querySelector(selector).classList.toggle('dark-mode');
});

// Toggle button style
if (document.body.classList.contains('dark-mode')) {
toggleButton.innerText = '🌞'; // Sun for light mode
toggleButton.style.backgroundColor = '#333333';
toggleButton.style.color = '#ffffff';
} else {
toggleButton.innerText = '🌙'; // Moon for dark mode
toggleButton.style.backgroundColor = '#ffffff';
toggleButton.style.color = '#000000';
}
});
</script>

<footer>
<p>&copy; 2025 AgriTech. All rights reserved.</p>
</footer>
</body>

</html>