Feat:adds theme color customization/为 WebUI 仪表板添加了主题颜色自定义功能#7640
Open
LovieCode wants to merge 3 commits intoAstrBotDevs:masterfrom
Open
Feat:adds theme color customization/为 WebUI 仪表板添加了主题颜色自定义功能#7640LovieCode wants to merge 3 commits intoAstrBotDevs:masterfrom
LovieCode wants to merge 3 commits intoAstrBotDevs:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The native
<input type="color">controls currently have no explicit labels or ARIA attributes and rely on visual proximity to the Vuetify text fields; consider associating them viaaria-labelledbyor wrapping them in a labeled container to keep the color picker accessible to screen readers. - The localStorage keys (
'themePrimary','themeSecondary','themeInfo') and the default/preset color values are duplicated across multiple functions; extracting them into a small config object or constants would make future changes less error‑prone and keep the theme logic more maintainable.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The native `<input type="color">` controls currently have no explicit labels or ARIA attributes and rely on visual proximity to the Vuetify text fields; consider associating them via `aria-labelledby` or wrapping them in a labeled container to keep the color picker accessible to screen readers.
- The localStorage keys (`'themePrimary'`, `'themeSecondary'`, `'themeInfo'`) and the default/preset color values are duplicated across multiple functions; extracting them into a small config object or constants would make future changes less error‑prone and keep the theme logic more maintainable.
## Individual Comments
### Comment 1
<location path="dashboard/src/views/Settings.vue" line_range="252-260" />
<code_context>
+ { name: 'Zinc', primary: '#52525B', secondary: '#52525B', info: '#71717A' },
+];
+
+const applyPreset = (preset) => {
+ primaryColor.value = preset.primary;
+ secondaryColor.value = preset.secondary;
+ infoColor.value = preset.info;
+ localStorage.setItem('themePrimary', preset.primary);
+ localStorage.setItem('themeSecondary', preset.secondary);
+ localStorage.setItem('themeInfo', preset.info);
+ applyThemeColors(preset.primary, preset.secondary, preset.info);
+};
</code_context>
<issue_to_address>
**suggestion:** Preset application duplicates side effects already handled by watchers.
Since the watchers for `primaryColor`, `secondaryColor`, and `infoColor` already persist to `localStorage` and call `applyThemeColors`, the explicit `localStorage.setItem` calls and direct `applyThemeColors` call here are redundant and add unnecessary writes/calls. Consider having `applyPreset` only update the three refs and let the watchers handle the side effects.
```suggestion
const applyPreset = (preset) => {
primaryColor.value = preset.primary;
secondaryColor.value = preset.secondary;
infoColor.value = preset.info;
};
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements theme color customization, adding an info color and several presets across the English, Russian, and Chinese locales. The UI in Settings.vue was updated with color pickers and preset buttons. Feedback identifies redundant logic in applyPreset and resetThemeColors where manual storage and theme updates overlap with existing watchers. There is also a suggestion to avoid overwriting dark color variants to maintain UI depth and contrast.
faf411f to
0068960
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds theme color customization to the WebUI dashboard, allowing users to choose from 8 preset color themes and customize primary, secondary, and info colors. Changes apply immediately and persist in browser local storage.
此 PR 为 WebUI 仪表板添加了主题颜色自定义功能,用户可以从 8 种预设配色方案中选择,或自定义主色、辅助色和信息色。修改后立即生效,并保存在浏览器本地。
Modifications / 改动点
dashboard/src/views/Settings.vue- Added theme color customization UI with 8 preset color swatches and color pickers for primary, secondary, and info colorsdashboard/src/theme/DarkTheme.ts- Updated dark theme color configurationdashboard/src/theme/LightTheme.ts- Updated light theme color configurationdashboard/src/i18n/locales/zh-CN/features/settings.json- Added Chinese i18n strings for theme customizationdashboard/src/i18n/locales/en-US/features/settings.json- Added English i18n strings for theme customizationdashboard/src/i18n/locales/ru-RU/features/settings.json- Added Russian i18n strings for theme customizationThis is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了"验证步骤"和"运行截图"。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Add theme color customization to the WebUI dashboard settings, including support for per-user primary/secondary/info colors and preset palettes, with changes applied live and persisted in local storage.
New Features:
Enhancements: