feat(Avatar): add deterministic auto color - #6810
Conversation
commit: |
📝 WalkthroughWalkthroughThe Avatar component now supports Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/runtime/components/Avatar.vueParsing error: Unexpected token ) src/theme/avatar-group.tsParsing error: Unexpected token { src/theme/avatar.tsParsing error: Unexpected token {
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.
🧹 Nitpick comments (1)
test/components/Avatar.spec.ts (1)
42-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the remaining fallback paths.
The tests cover
altwithoutsrcand explicit style precedence. Add cases fortext,UAvatarGroupcolor inheritance, and a failedsrc. These paths are part of the new behavior and would detect regressions inuseAvatarGrouppropagation andonErrorfallback handling.🤖 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 `@test/components/Avatar.spec.ts` around lines 42 - 63, Add tests covering the remaining Avatar fallback paths alongside the existing auto-color cases: verify color generation from text, color inheritance when Avatar is rendered inside UAvatarGroup, and fallback behavior after the image src fails via onError. Reuse the established mounting and assertion patterns, and ensure the tests detect both useAvatarGroup propagation and failed-src fallback behavior.
🤖 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.
Nitpick comments:
In `@test/components/Avatar.spec.ts`:
- Around line 42-63: Add tests covering the remaining Avatar fallback paths
alongside the existing auto-color cases: verify color generation from text,
color inheritance when Avatar is rendered inside UAvatarGroup, and fallback
behavior after the image src fails via onError. Reuse the established mounting
and assertion patterns, and ensure the tests detect both useAvatarGroup
propagation and failed-src fallback behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bfd42021-ff9f-4a36-a497-9b7bb4243116
⛔ Files ignored due to path filters (4)
test/components/__snapshots__/Avatar-vue.spec.ts.snapis excluded by!**/*.snaptest/components/__snapshots__/Avatar.spec.ts.snapis excluded by!**/*.snaptest/components/__snapshots__/AvatarGroup-vue.spec.ts.snapis excluded by!**/*.snaptest/components/__snapshots__/AvatarGroup.spec.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (5)
docs/content/docs/2.components/avatar.mdsrc/runtime/components/Avatar.vuesrc/theme/avatar-group.tssrc/theme/avatar.tstest/components/Avatar.spec.ts
🔗 Linked issue
Resolves #6808
❓ Type of change
📚 Description
Add an opt-in
color="auto"option toUAvatar.When enabled, the avatar background color is deterministically generated from the
textoraltprop using an HSL hue derived from the characters of the avatar identity.The generated color:
UAvatarGroupDocumentation, component tests, and snapshots have been updated accordingly.
📝 Checklist