Skip to content

Can we add a hover effect to the sidebar, like the one we had before? #2

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

Merged
merged 1 commit into from
Dec 28, 2024
Merged
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
18 changes: 17 additions & 1 deletion ExpenseTracker.Web/ExpenseTracker.Web/wwwroot/js/site.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.

// Write your JavaScript code.
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.e-menu-item').forEach(link => {
const linkText = link.textContent.toLowerCase();
const currentPath = location.pathname.toLowerCase();
if (linkText === 'dashboard' && currentPath === '/') {
link.classList.add('active-menu-item');
console.log('Dashboard active:', link);
}
else if (currentPath.endsWith(linkText)) {
link.classList.add('active-menu-item');
console.log(link);
}
else {
link.classList.remove('active-menu-item');
}
});
});