Improving UX: Implementing Dark Mode and Navigation Utilities
Enhancing User Experience
Developer experience is often discussed, but user experience improvements are just as critical for personal projects. When working on portafolio-luis-romero, I focused on three specific UI enhancements to improve usability and aesthetic flexibility: a dark mode toggle, a translation switcher, and an intuitive 'scroll-to-top' utility.
The Implementation
Adding these features requires a mix of CSS for styling and JavaScript for DOM interaction. By centralizing these UI controls, we can ensure the interface feels responsive and accessible.
1. Toggleable Dark Mode
Using a CSS class to toggle themes is a standard pattern. By toggling a class on the body element, we can easily swap CSS variables.
body.dark-mode {
background-color: #121212;
color: #ffffff;
}
const toggleDark = () => {
document.body.classList.toggle('dark-mode');
};
2. UI Utility Buttons
For the translation and arrow-up buttons, I utilized standard event listeners in JavaScript to handle user interactions without reloading the page.
// Simple scroll-to-top logic
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
document.getElementById('top-btn').addEventListener('click', scrollToTop);
Why These Small Features Matter
Small refinements like theme toggling and quick-navigation buttons often have a higher impact on user satisfaction than complex back-end logic. They signal that the application is actively maintained and considerate of the user's reading environment.
Actionable Takeaway
Start by auditing your own project for "friction points." If a user has to scroll long distances or read in high-contrast light environments for too long, prioritize adding a simple navigation shortcut or a theme switcher. You can implement both with less than 20 lines of code.
Generated with Gitvlg.com