feat(Avatar): add Avatar.Group and Avatar.Indicator#245
Open
johnleider wants to merge 12 commits into
Open
Conversation
Adds a headless group container that collapses to a +N indicator under either count-based (max) or opt-in width-responsive truncation. Mirrors the Button.Group precedent: a flat sub-component owning its own context, with Avatar.Root optionally injecting the group via createContext null fallback. createOverflow is wired inside a useToggleScope so the ResizeObserver path is pay-for-what-you-use.
Avatar.Group's responsive mode never fed createOverflow any width data, so capacity collapsed to 0 and every avatar got hidden the moment the container was measured. Avatar.Root now measures its own offsetWidth into group.itemWidth (uniform mode), and the responsive docs example passes :gap="-8" to account for the negative overlap. Also tightens the ticket type contract: disabled is wrapped with toRef at the register site to match the declared Readonly<Ref<boolean>>, the private isHidden field is computed locally in AvatarRoot instead of post-mutating onto the ticket, and the group's slot prop renames count to total so it doesn't collide with the indicator's hidden-count slot.
…zero it Every Avatar.Root was writing offsetWidth into the shared itemWidth ref. When the responsive truncation hid later avatars via v-show, their offsetWidth dropped to 0 and the next ResizeObserver tick zeroed itemWidth, which made createOverflow.capacity revert to Infinity and unhide every avatar — a measure/hide/unmeasure feedback loop. Only the index 0 ticket now measures, and writes are skipped when offsetWidth is 0. The unmount reset is similarly guarded so a mid-list unmount can't clobber the value.
Bump the responsive demo to 30 avatars so width-based truncation is visible at typical container sizes. Skip the negative marginInlineStart on the first child of each group so it no longer hangs off the left edge. Center the non-responsive examples in the example pane.
Replace the three contrived basic/max/responsive examples with a single team-roster panel that ships the kind of UI Avatar.Group is actually for: a labelled members row that fills its container, collapses into a +N chip with a hover-list of the truncated members, and pairs every avatar with a name/role tooltip. Data lives in a separate module so the component file stays focused on composition and ARIA. The page picks up an ## Examples heading to match the canonical docs structure. The basic Image+Fallback example is centered in its pane for visual consistency.
|
commit: |
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.
Summary
Avatar.GroupandAvatar.Indicatorto the existingAvatarcompound. Mirrors theButton.Groupprecedent: a flat sub-component owning its own context, withAvatar.Rootoptionally injecting the group viacreateContext's null fallback.min(max, capacityFromWidth)):max— count-based cap. No observers, no overhead. Disabled avatars are exempt and always render.priority="start" | "end"controls which side keeps avatars.responsive— opt-in width-based truncation. WrapscreateOverflowinsideuseToggleScopeso the ResizeObserver path is pay-for-what-you-use.Avatar.Root(the first ticket only) feedsitemWidth;Avatar.Indicatorself-measures and feedsreserved.Avatar.Indicatorexposescountandhiddenon its slot. Renders nothing outside a group or when the group is not overflowing.Avatar.Rootbehavior is fully backward-compatible: new props (value,disabled,groupNamespace) default to safe no-ops, new slot props (isHidden,index) default tofalse/0, new data attrs only render inside a group.role="group"+ label/labelledby/describedby; hidden avatars carryaria-hidden="true"so screen readers only announce the indicator's count; indicator carriesaria-live="polite"and a localizedaria-labelviaAvatar.indicatorLabel.Docs
## Examplessection with a single realistic team-roster panel (members data in a separate module, hover tooltips on every avatar, and a hover-list of truncated names on the+Nchip viaAvatar.Indicator'shiddenslot prop).