Fix/theme toggle button#126
Conversation
WalkthroughThis change replaces a dropdown-based theme selector with a single icon button that directly toggles between dark and light modes on click. The update removes the multi-step selection process and streamlines theme switching to a one-click interaction. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 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: 0
🧹 Nitpick comments (1)
src/routes/Theme.svelte (1)
13-28: LGTM! Toggle button implementation is clean and functional.The implementation successfully replaces the dropdown with a single-click toggle, preserving the Sun/Moon icon animations and maintaining keyboard accessibility through the Button component.
Optional: Enhance screen reader feedback.
Consider making the button state more explicit for screen reader users by dynamically updating the aria-label to reflect the action:
<Button variant="outline" size="icon" on:click={toggleTheme} - aria-label="Toggle theme" + aria-label={$mode === "dark" ? "Switch to light mode" : "Switch to dark mode"} >This provides clearer context about what will happen on click rather than just "Toggle theme".
Also, the
<span class="sr-only">is redundant whenaria-labelis present, as screen readers will announce the aria-label instead. You can safely remove it if desired.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/routes/Theme.svelte(1 hunks)
🔇 Additional comments (2)
src/routes/Theme.svelte (2)
1-6: LGTM! Imports are clean and appropriate.The imports correctly bring in the icon components, mode-watcher utilities, and Button component needed for the toggle implementation.
8-10: Verify the "system" mode toggle behavior.The toggle logic treats "system" mode the same as "light" mode (both switch to "dark"). This matches the PR description's stated behavior, but could be confusing if the user's system preference is already dark—clicking the button would appear to do nothing (system/dark visual → explicit dark).
Consider whether the first interaction from "system" should respect the current system preference rather than always defaulting to "dark", or clearly document this design decision.
Summary
This PR replaces the theme dropdown menu in the navigation bar with a one-click toggle button to improve usability and reduce interaction friction.
Problem
The previous theme switcher required multiple steps:
This was inefficient for a frequently used feature.
Solution
mode-watcherfor theme persistenceBehavior
Screenshots
Checklist
Closes #120
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.