Skip to content

feat(sidebar): add animated theme toggle button - #1722

Merged
zhangmo8 merged 3 commits into
devfrom
theme-toggle
Jun 1, 2026
Merged

feat(sidebar): add animated theme toggle button#1722
zhangmo8 merged 3 commits into
devfrom
theme-toggle

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator
68cc46c93f4a58d422bcc1b155764778_raw.mp4

Summary by CodeRabbit

  • New Features

    • Added a sidebar theme toggle to switch between Light, Dark, and System modes with animated icons.
    • Added theme-related translations across all supported languages.
  • Bug Fixes / Improvements

    • Improved theme switching to avoid unwanted transition flashes and respect reduced-motion preferences.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d64fa962-2dc9-4d64-8aae-39bb01b3310c

📥 Commits

Reviewing files that changed from the base of the PR and between 0aa639b and 68a9773.

📒 Files selected for processing (3)
  • src/renderer/src/App.vue
  • src/renderer/src/assets/style.css
  • src/renderer/src/lib/icons/line-md-theme.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/lib/icons/line-md-theme.json

📝 Walkthrough

Walkthrough

Adds a sidebar theme toggle that cycles theme modes, registers an animated line‑md icon collection, suppresses CSS transitions during theme swaps, and adds localized labels across multiple chat.json files.

Changes

Theme Toggle Feature

Layer / File(s) Summary
Icon infrastructure for theme transitions
src/renderer/src/lib/icons/line-md-theme.json, src/renderer/src/lib/iconLoader.ts
line-md-theme.json defines animated SVG transition icons. iconLoader.ts imports and registers the new collection in ensureIconsLoaded().
Theme toggle component with computed properties and styling
src/renderer/src/components/WindowSideBar.vue
Component imports useThemeStore, defines themeIcon and themeModeLabel computed props, renders a tooltip-wrapped toggle button that calls themeStore.cycleTheme(), and adds scoped CSS for icon layout and enter/leave animations (respects reduced-motion).
Appearance sync and transition suppression
src/renderer/src/App.vue, src/renderer/src/assets/style.css
syncAppearanceClasses temporarily adds .dc-theme-switching to root/body, forces a reflow, then removes it to avoid unwanted transitions; style.css adds .dc-theme-switching { transition: none !important; } for descendants and pseudo-elements.
Theme toggle translations across languages
src/renderer/src/i18n/{da-DK,de-DE,en-US,es-ES,fa-IR,fr-FR,he-IL,id-ID,it-IT,ja-JP,ko-KR,ms-MY,pl-PL,pt-BR,ru-RU,tr-TR,vi-VN,zh-CN,zh-HK,zh-TW}/chat.json
Added sidebar.themeToggle, sidebar.themeLight, sidebar.themeDark, and sidebar.themeSystem keys to localize the toggle label and mode options.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

🐰 A tiny toggle hops into view,

icons morphing from sun to moon anew,
many tongues now whisper light or dark,
transitions paused so changes leave no mark,
a rabbit cheers: “Click — let the theme pursue!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: adding an animated theme toggle button to the sidebar.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch theme-toggle

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/src/components/WindowSideBar.vue`:
- Around line 100-114: The theme toggle Button
(data-testid="window-sidebar-theme-toggle") is icon-only and missing an
accessible name; add an aria-label and title to that Button using the localized
label and current mode (e.g., combine t('chat.sidebar.themeToggle') and
themeModeLabel) so assistive tech can announce it; ensure the attributes are
kept in sync with the icon/state and reference the existing
themeStore.cycleTheme() click handler and themeIcon/themeModeLabel values when
building the label.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91646a43-d67f-41d0-b4aa-6813aafc6696

📥 Commits

Reviewing files that changed from the base of the PR and between 49fe691 and 0aa639b.

📒 Files selected for processing (23)
  • src/renderer/src/components/WindowSideBar.vue
  • src/renderer/src/i18n/da-DK/chat.json
  • src/renderer/src/i18n/de-DE/chat.json
  • src/renderer/src/i18n/en-US/chat.json
  • src/renderer/src/i18n/es-ES/chat.json
  • src/renderer/src/i18n/fa-IR/chat.json
  • src/renderer/src/i18n/fr-FR/chat.json
  • src/renderer/src/i18n/he-IL/chat.json
  • src/renderer/src/i18n/id-ID/chat.json
  • src/renderer/src/i18n/it-IT/chat.json
  • src/renderer/src/i18n/ja-JP/chat.json
  • src/renderer/src/i18n/ko-KR/chat.json
  • src/renderer/src/i18n/ms-MY/chat.json
  • src/renderer/src/i18n/pl-PL/chat.json
  • src/renderer/src/i18n/pt-BR/chat.json
  • src/renderer/src/i18n/ru-RU/chat.json
  • src/renderer/src/i18n/tr-TR/chat.json
  • src/renderer/src/i18n/vi-VN/chat.json
  • src/renderer/src/i18n/zh-CN/chat.json
  • src/renderer/src/i18n/zh-HK/chat.json
  • src/renderer/src/i18n/zh-TW/chat.json
  • src/renderer/src/lib/iconLoader.ts
  • src/renderer/src/lib/icons/line-md-theme.json

Comment on lines +100 to +114
<Button
data-testid="window-sidebar-theme-toggle"
class="flex items-center justify-center w-9 h-9 rounded-xl bg-transparent border-none hover:bg-white/30 dark:hover:bg-white/10 shadow-none"
@click="themeStore.cycleTheme()"
>
<span class="theme-icon-wrap">
<Transition name="theme-icon">
<Icon :key="themeIcon" :icon="themeIcon" class="theme-icon text-foreground/90" />
</Transition>
</span>
</Button>
</TooltipTrigger>
<TooltipContent side="right">
{{ t('chat.sidebar.themeToggle') }} · {{ themeModeLabel }}
</TooltipContent>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add an accessible name to the icon-only theme button.

The new toggle button is icon-only and currently lacks aria-label/title, so assistive tech gets an unlabeled control.

Suggested fix
             <Button
               data-testid="window-sidebar-theme-toggle"
+              :aria-label="`${t('chat.sidebar.themeToggle')} · ${themeModeLabel}`"
+              :title="`${t('chat.sidebar.themeToggle')} · ${themeModeLabel}`"
               class="flex items-center justify-center w-9 h-9 rounded-xl bg-transparent border-none hover:bg-white/30 dark:hover:bg-white/10 shadow-none"
               `@click`="themeStore.cycleTheme()"
             >
📝 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
<Button
data-testid="window-sidebar-theme-toggle"
class="flex items-center justify-center w-9 h-9 rounded-xl bg-transparent border-none hover:bg-white/30 dark:hover:bg-white/10 shadow-none"
@click="themeStore.cycleTheme()"
>
<span class="theme-icon-wrap">
<Transition name="theme-icon">
<Icon :key="themeIcon" :icon="themeIcon" class="theme-icon text-foreground/90" />
</Transition>
</span>
</Button>
</TooltipTrigger>
<TooltipContent side="right">
{{ t('chat.sidebar.themeToggle') }} · {{ themeModeLabel }}
</TooltipContent>
<Button
data-testid="window-sidebar-theme-toggle"
:aria-label="`${t('chat.sidebar.themeToggle')} · ${themeModeLabel}`"
:title="`${t('chat.sidebar.themeToggle')} · ${themeModeLabel}`"
class="flex items-center justify-center w-9 h-9 rounded-xl bg-transparent border-none hover:bg-white/30 dark:hover:bg-white/10 shadow-none"
`@click`="themeStore.cycleTheme()"
>
<span class="theme-icon-wrap">
<Transition name="theme-icon">
<Icon :key="themeIcon" :icon="themeIcon" class="theme-icon text-foreground/90" />
</Transition>
</span>
</Button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/src/components/WindowSideBar.vue` around lines 100 - 114, The
theme toggle Button (data-testid="window-sidebar-theme-toggle") is icon-only and
missing an accessible name; add an aria-label and title to that Button using the
localized label and current mode (e.g., combine t('chat.sidebar.themeToggle')
and themeModeLabel) so assistive tech can announce it; ensure the attributes are
kept in sync with the icon/state and reference the existing
themeStore.cycleTheme() click handler and themeIcon/themeModeLabel values when
building the label.

zhangmo8 added 2 commits June 1, 2026 16:22
切换主题时临时禁用所有过渡,避免上百个带 transition-colors
的元素同时触发 220ms 颜色过渡造成的重绘卡顿。过渡仅在切换
当帧禁用,下一帧恢复,不影响日常 hover 等交互。
@zhangmo8
zhangmo8 merged commit abfd6be into dev Jun 1, 2026
3 checks passed
@zhangmo8
zhangmo8 deleted the theme-toggle branch June 1, 2026 08:29
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.

1 participant