fix: adding theme toggle for better UX#122
fix: adding theme toggle for better UX#122shadow-dawg wants to merge 1 commit intoStabilityNexus:mainfrom
Conversation
WalkthroughThis PR converts semantic navigation elements from anchors to buttons and replaces the theme dropdown menu with a single accessible toggle button. The navigation change preserves existing tab-switching behavior while improving HTML semantics, and the theme component simplifies user interactions by collapsing multi-step dropdown selection into a single toggle. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related issues
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/routes/Theme.svelte (2)
23-42: Accessibility implementation looks good with a minor note.The accessible button implementation is well done:
aria-pressedcorrectly indicates toggle statearia-hidden="true"on decorative icons prevents redundant announcementssr-onlyspan provides accessible label- Dynamic
titleattribute provides visual feedbackMinor note: While browsers accept boolean values for
aria-pressed, the ARIA specification prefers string"true"/"false". Consideraria-pressed={isDark ? "true" : "false"}for strict spec compliance.
17-20: Consider adding system/auto theme support for consistency with modern UX patterns.The current implementation only supports light and dark modes. While mode-watcher v0.5.0 supports a system/auto mode via
setMode("system")andresetMode(), the implementation deliberately chose a simpler binary toggle. Adding system preference support would allow users to automatically match their OS theme, which is a common expectation in modern applications. This can be implemented as a three-state cycle (light → dark → system) if desired.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/routes/App.svelte(6 hunks)src/routes/Theme.svelte(1 hunks)
🔇 Additional comments (4)
src/routes/App.svelte (4)
232-249: Semantic improvement: buttons are more appropriate for tab switching.Converting navigation items from anchors to buttons is semantically correct since these elements trigger JavaScript-driven tab changes rather than actual page navigation. The
type="button"attribute correctly prevents unintended form submission.
322-339: Mobile navigation changes are consistent with desktop.The mobile navigation correctly mirrors the desktop navigation changes, maintaining consistency across breakpoints.
576-612: CSS changes comprehensively support button styling.The CSS updates properly extend styles to button elements:
- Base navigation styles (line 576)
- Hover states (line 587)
- Active states (line 593)
- Button-specific reset to neutralize default chrome (lines 600-612)
The button reset appropriately removes default button styling (background, border, padding) and inherits font properties to match the previous anchor appearance.
721-740: Mobile navigation CSS consistently updated.Mobile navigation styles correctly extended to support both anchor and button elements, maintaining visual parity with desktop navigation.
Related Issue
Closes #120
Summary
This PR replaces the theme dropdown menu in the Ergo navigation bar with a direct toggle button, providing a more intuitive and efficient way for users to switch between light and dark themes.
Changes Made
➖ Removed
Theme dropdown menu component
Dropdown trigger button/icon
Multi-option theme selector (Light, Dark, System)
Multiple click workflow for theme switching
➕ Added
Direct toggle button in navigation bar
Dynamic icon system:
🌙 Moon icon in light mode → Click to enable dark mode
☀️ Sun icon in dark mode → Click to enable light mode
Single-click theme switching
Improved visual feedback for current theme state
Enhanced accessibility features
BEFORE
2025-12-13.20-00-48.mov
AFTER
2025-12-13.20-01-20.mov
Summary by CodeRabbit
Style
New Features
✏️ Tip: You can customize this high-level summary in your review settings.