Skip to content

feat(navbar): replace 3-option theme menu with single-click circular toggle#172

Open
ankitkr104 wants to merge 2 commits intoStabilityNexus:mainfrom
ankitkr104:good-first-issue-171-navbar-theme-toggle
Open

feat(navbar): replace 3-option theme menu with single-click circular toggle#172
ankitkr104 wants to merge 2 commits intoStabilityNexus:mainfrom
ankitkr104:good-first-issue-171-navbar-theme-toggle

Conversation

@ankitkr104
Copy link
Copy Markdown

@ankitkr104 ankitkr104 commented Apr 9, 2026

Background
The theme control in the navbar previously used a 3-option dropdown (Light, Dark, System). The desired behavior is a one-step button that toggles theme directly on click, while still respecting system theme by default when no user preference exists.

Change Analysis

Based on the current implementation in src/routes/Theme.svelte:

Theme selection UI was simplified from dropdown to one-click toggle.
Theme switching now uses toggleMode instead of individual setMode or resetMode actions.
Button shape has been updated to circular via rounded-full.
Motion behavior is now click-triggered only:
A turning state is set on click.
Wrapper rotates 180 degrees with a 700ms transition.
Turning state resets via timeout after 700ms.
Accessibility text is preserved via Toggle theme sr-only label.

Addressed Issues:

Fixes #171

Recordings:

new.mp4

Additional Notes:

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features
    • Replaced the theme selector dropdown with a single toggle button for quicker theme switching
    • Added animated rotation feedback to the toggle for clearer visual confirmation of theme changes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Walkthrough

Replaced the 3-option dropdown theme selector in src/routes/Theme.svelte with a single clickable button that calls toggleMode(); introduced rotationDeg state incremented by 180° per click and a .theme-toggle-motion CSS rule for a 700ms rotation transition.

Changes

Cohort / File(s) Summary
Theme toggle UI
src/routes/Theme.svelte
Removed dropdown/menu and mode-watcher usages (resetMode/setMode) and related dropdown markup. Added a single Button that calls toggleMode() on click, introduced local rotationDeg (+=180° per toggle) bound to transform: rotate(...), and added .theme-toggle-motion CSS with a 700ms rotation transition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Typescript Lang

Poem

🐰
A tiny button gives a spin,
One gentle turn, the theme logs in.
No menus hide, no choices roam,
A hop, a click — the dark feels home.
Round and peaceful, 180° in vim.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the primary change: replacing a 3-option theme menu with a single-click circular toggle button, which is the main focus of the changeset in Theme.svelte.
Linked Issues check ✅ Passed The PR implementation meets all requirements from issue #171: replaced dropdown with circular button, implemented click-triggered toggle, added 700ms rotation animation, preserved system theme as default, and removed dropdown options.
Out of Scope Changes check ✅ Passed All changes in Theme.svelte are directly related to replacing the theme dropdown with a circular toggle. No extraneous modifications are present outside the specified objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/routes/Theme.svelte`:
- Around line 8-23: The current click rotation logic using isTurning and
turnTimeout in handleToggleClick is flaky; replace it with a cumulative numeric
rotation state (e.g., rotationAngle) that you increment by 180 on each click and
use that value for the element's transform, remove isTurning and turnTimeout and
any timeout-based reset logic, and update toggleMode calls to rely on the new
rotationAngle; also apply the same change for the other rotation bits referenced
(the occurrences around the other handlers at lines 26-27 and 43-52) so each
click deterministically produces a single slow 180deg rotation by animating to
the new cumulative angle.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 14528d45-65d4-4faa-834b-9c3d9e4c012e

📥 Commits

Reviewing files that changed from the base of the PR and between f759564 and 488b690.

📒 Files selected for processing (1)
  • src/routes/Theme.svelte

Comment thread src/routes/Theme.svelte Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/routes/Theme.svelte`:
- Around line 36-40: The .theme-toggle-motion class currently always applies a
700ms transform transition; add a prefers-reduced-motion fallback so users who
request reduced motion won't get the rotation animation. Update the CSS by
adding a `@media` (prefers-reduced-motion: reduce) rule that targets
.theme-toggle-motion and disables the transition (e.g., transition: none or
override to remove transform transitions) so the component respects user
accessibility settings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: da708dae-e6ae-4933-bafa-269bcca7daa8

📥 Commits

Reviewing files that changed from the base of the PR and between 488b690 and 06dadff.

📒 Files selected for processing (1)
  • src/routes/Theme.svelte

Comment thread src/routes/Theme.svelte
Comment on lines +36 to +40
<style>
.theme-toggle-motion {
display: inline-block;
transition: transform 700ms ease;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Add reduced-motion fallback for the rotation animation.

Consider disabling the transform transition when users request reduced motion.

♿ Suggested CSS refinement
 <style>
     .theme-toggle-motion {
         display: inline-block;
         transition: transform 700ms ease;
     }
+
+    `@media` (prefers-reduced-motion: reduce) {
+        .theme-toggle-motion {
+            transition: none;
+        }
+    }
 </style>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<style>
.theme-toggle-motion {
display: inline-block;
transition: transform 700ms ease;
}
<style>
.theme-toggle-motion {
display: inline-block;
transition: transform 700ms ease;
}
`@media` (prefers-reduced-motion: reduce) {
.theme-toggle-motion {
transition: none;
}
}
</style>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/Theme.svelte` around lines 36 - 40, The .theme-toggle-motion class
currently always applies a 700ms transform transition; add a
prefers-reduced-motion fallback so users who request reduced motion won't get
the rotation animation. Update the CSS by adding a `@media`
(prefers-reduced-motion: reduce) rule that targets .theme-toggle-motion and
disables the transition (e.g., transition: none or override to remove transform
transitions) so the component respects user accessibility settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GOOD FIRST ISSUE]: Navbar Theme Toggle: Replace 3-option menu with single-click circular toggle and click-only slow rotation

1 participant