-
Notifications
You must be signed in to change notification settings - Fork 1
fix(pds-avatar): add initials props #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for pine-design-system ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@coderabbitai review this pr |
|
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis change introduces a new optional 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libs/core/src/components/pds-avatar/stories/pds-avatar.stories.js (1)
20-30: Potential issue:nullvalue renders as string "null" in Lit templates.When
args.initialsisnull, the template interpolationinitials="${args.initials}"will render as the literal attributeinitials="null", which the component may interpret as the string "null" rather than a null value. This could cause "null" to display as initials text.Consider using Lit's
ifDefineddirective or a conditional to avoid passing null values:🐛 Suggested fix using ifDefined
+import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import imgFile from '../assets/demi_wilkinson.jpg'; const BaseTemplate = (args) => html`<pds-avatar alt="${args.alt}" badge="${args.badge}" dropdown="${args.dropdown}" component-id="${args.componentId}" image="${args.image}" - initials="${args.initials}" + initials="${ifDefined(args.initials)}" size="${args.size}" variant="${args.variant}" > </pds-avatar>`;Note: The same issue may exist for other nullable props like
altandimage. Consider applyingifDefinedconsistently across all nullable attributes.
🧹 Nitpick comments (2)
libs/core/src/components/pds-avatar/test/pds-avatar.spec.tsx (1)
188-239: LGTM - Test coverage for initials feature is solid.The tests appropriately cover:
- Basic initials rendering with SVG structure
- Image precedence over initials (correct priority behavior)
- Initials combined with badge functionality
The assertions verify both the DOM structure and CSS class application.
Consider adding edge case tests for:
- Empty string initials (
initials="")- Single character initials (
initials="J")- Long initials to verify no overflow issues
These can be deferred to a follow-up if needed.
libs/core/src/components/pds-avatar/pds-avatar.tsx (1)
122-128: Adddominant-baseline="central"to the text element for proper vertical centering.The
text-anchor: middleis already handled in SCSS, so the text is horizontally centered. However, vertical centering needsdominant-baseline="central"on the text element; the currenty="20"is a hardcoded approximation. Additionally, consider validating the initials length to prevent overflow if long strings are passed.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
libs/core/src/components.d.tslibs/core/src/components/pds-avatar/docs/pds-avatar.mdxlibs/core/src/components/pds-avatar/pds-avatar.scsslibs/core/src/components/pds-avatar/pds-avatar.tsxlibs/core/src/components/pds-avatar/readme.mdlibs/core/src/components/pds-avatar/stories/pds-avatar.stories.jslibs/core/src/components/pds-avatar/test/pds-avatar.spec.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
libs/core/src/components/pds-avatar/test/pds-avatar.spec.tsx (1)
libs/react/src/components/proxies.ts (1)
PdsAvatar(59-59)
🔇 Additional comments (8)
libs/core/src/components/pds-avatar/pds-avatar.scss (1)
64-77: LGTM - Initials styling is well-structured.The styling correctly uses design tokens for brand consistency and ensures the SVG fills the container. The
text-anchor: middlehandles horizontal centering appropriately.One optional consideration: adding
dominant-baseline: centralordominant-baseline: middleto thetextelement could improve vertical text alignment consistency across browsers, though the currenty="20"approach in the SVG works for the fixed viewBox.libs/core/src/components/pds-avatar/readme.md (1)
17-17: LGTM - Documentation properly reflects the new prop.The initials property is documented consistently with the existing properties table format.
libs/core/src/components/pds-avatar/docs/pds-avatar.mdx (1)
106-128: LGTM - Documentation examples are clear and comprehensive.The new sections follow the established documentation pattern, providing both React and Web Component examples with proper descriptions for each use case.
libs/core/src/components.d.ts (2)
129-133: LGTM - Type definitions correctly reflect the new prop.The autogenerated type definitions properly include the
initialsproperty in both theComponentsandLocalJSXnamespaces with consistent typing (string | null) and documentation.
2878-2882: Type definition mirrors Components namespace correctly.The LocalJSX namespace definition is consistent with the Components namespace, ensuring proper TypeScript support for both imperative and declarative usage patterns.
libs/core/src/components/pds-avatar/pds-avatar.tsx (2)
43-47: LGTM!The prop declaration follows the established pattern of other optional props in the component with consistent typing and default value.
136-143: LGTM!The class name logic follows the established pattern and correctly handles both empty string and null cases.
libs/core/src/components/pds-avatar/stories/pds-avatar.stories.js (1)
67-78: LGTM!Good story coverage demonstrating both standalone initials and the combination with badge. This provides clear documentation of the new feature.
pixelflips
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker but should maybe be a feat, but otherwise lgtm!
Description
Fixes DSS-71
Type of change
How Has This Been Tested?
Visit the Avatar page -> Initials
Test Configuration:
Checklist:
If not applicable, leave options unchecked.