-
Notifications
You must be signed in to change notification settings - Fork 464
feat(ui): add Avatar button composition #9378
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
base: main
Are you sure you want to change the base?
Changes from all commits
de3b097
f711e0e
2f721aa
3c92f74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import * as AvatarStories from './avatar.stories'; | |
|
|
||
| # Avatar | ||
|
|
||
| Avatar represents a user or entity as an image, falling back to a blank placeholder when the image is missing or fails to load. It is a compound component: `Avatar.Root` clips and sizes the box, `Avatar.Image` renders the picture once it loads, and `Avatar.Fallback` holds the space until then. | ||
| Avatar represents a user or entity as an image, falling back to a blank placeholder when the image is missing or fails to load. It is a compound component: `Avatar.Root` positions and sizes the box, `Avatar.Image` renders the picture once it loads, `Avatar.Fallback` holds the space until then, and `Avatar.Icon` adds an optional corner affordance. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift Use the required compound-component documentation archetype.
As per coding guidelines, “Compound Components pages must use the exact section order: 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| The fallback still takes children — initials, an icon — but never paints them, so an entity without a picture reads as an absent image rather than as two letters. They stay in the DOM, held in an `avatar-fallback-content` slot that is `visibility: hidden`: out of the page, the accessibility tree, and the tab order together, and overridable by a consumer who wants them back. | ||
|
|
||
|
|
@@ -37,10 +37,11 @@ import { Avatar } from '@clerk/ui/mosaic/components/avatar'; | |
|
|
||
| | Part | Slot (`.cl-*`) | Description | | ||
| | ----------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `Avatar.Root` | `cl-avatar` | Owns `shape` / `size`, clips its children to the shape. | | ||
| | `Avatar.Root` | `cl-avatar` | Owns `shape` / `size`, positioning, and polymorphic rendering. | | ||
| | `Avatar.Image` | `cl-avatar-image` | Renders an `<img>` once the source loads; renders nothing until then. | | ||
| | `Avatar.Fallback` | `cl-avatar-fallback` | Rendered while the image is pending or has failed. Carries `data-pending` while an image is still resolving. Optional `delayMs`. | | ||
| | — | `cl-avatar-fallback-content` | Wraps whatever `Avatar.Fallback` was handed, hidden. Override its `visibility` to paint initials or an icon. | | ||
| | `Avatar.Icon` | `cl-avatar-icon` | Renders an optional icon surface over the avatar corner. | | ||
|
|
||
| --- | ||
|
|
||
|
|
@@ -55,6 +56,15 @@ While an image is still resolving, the fallback carries `data-pending` and pulse | |
| storyModule={AvatarStories} | ||
| /> | ||
|
|
||
| ### Interactive | ||
|
|
||
| Use `render` to compose the avatar onto a button or another trigger without introducing a separate wrapper component. The `lg` avatar and button are both 48×48. | ||
|
|
||
| <Story | ||
| name='Interactive' | ||
| storyModule={AvatarStories} | ||
| /> | ||
|
|
||
| ### Fallback | ||
|
|
||
| Once the image fails, the pulse stops and the fallback settles into a plain fill. Nothing is on its way for an entity that has no picture, so its mark holds still rather than claiming to be loading one. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export { Avatar } from './avatar'; | ||
| export type { AvatarProps, AvatarImageProps, AvatarFallbackProps } from './avatar'; | ||
| export type { AvatarProps, AvatarImageProps, AvatarFallbackProps, AvatarIconProps } from './avatar'; |
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Add a release entry for
@clerk/ui.This PR adds public
Avatar.Root.render,Avatar.Icon, andAvatarIconProps. An empty Changeset will not create a package version or changelog entry for consumers. Add an@clerk/uiminor release entry with a concise summary.Based on learnings, empty Changesets are acceptable only when no published package requires release metadata. As per coding guidelines, “Use Changesets for version management and changelogs.”
🤖 Prompt for AI Agents
Sources: Coding guidelines, Learnings