Uh oh!
There was an error while loading. Please reload this page.
Allow customization of AvatarStack hover behavior and size - #3466
Conversation
🦋 Changeset detectedLatest commit: 356bf65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
| count?: number | ||
| } & SxProp | ||
| const findSmallestNumber = (numbers: number[]): number => { |
There was a problem hiding this comment.
Would Math.min(...numbers) work here? 🤔 Just an idea - not a blocker at all.
There was a problem hiding this comment.
Great suggestion! Soooo much easier.
There was a problem hiding this comment.
This is great @mperrotti 🎉
One thing that's missing in this PR is support for breakpoints.
Otherwise developers will have to get around this issue using:
<Boxsx={{display: ['block','block','none']}}><AvatarStacksize={26}/></Box><Boxsx={{display: ['none','none','block']}}><AvatarStacksize={20}/></Box>Instead of:
<AvatarStacksize={[20,20,24]}/>Without this support it will also make working with HTML grids hard because the Box is never removed from the DOM and will create an additional grid cell.
| export type AvatarStackProps = { | ||
| alignRight?: boolean | ||
| disableExpand?: boolean |
There was a problem hiding this comment.
Personal opinion, not strongly held: disableExpand is a double negative, which can feel confusing
What do you think about expand: boolean where default is true?
<AvatarStack/><AvatarStackexpand={false}/>There was a problem hiding this comment.
It feels strange to have to explicitly pass propName={false} because boolean props are normally evaluated as false if the prop is excluded.
If we didn't set expand to true by default, then <AvatarStack /> would be the same as <AvatarStack expand={false} />
There was a problem hiding this comment.
It feels strange to have to explicitly pass propName={false}
true true!
because boolean props are normally evaluated as false if the prop is excluded
not sure about that tho 😅
// default true<AvatarStack/>=<AvatarStackexpand/>=<AvatarStackexpand={true}/>// disabling default: <AvatarStackexpand={false}/>buuuut, also happy to go with what you feel strongly about
mperrotti
commented
Jul 6, 2023
@broccolinisoup and @maximedegreve - I have your suggestions implemented. This should be merge-able once I:
|
maximedegreve
commented
Jul 6, 2023
@mperrotti Oh no! |
mperrotti
commented
Jul 6, 2023
Haha thanks for sharing that @maximedegreve - I'll be fixing that while I make my other changes today. |
maximedegreve
commented
Jul 6, 2023
LGTM 🚀💪 |
Broader question, not a blocker for this PR: Are we adding any sort of |
broccolinisoup
left a comment
There was a problem hiding this comment.
Looks great! Just left a comment about the type stuff but feel free to ignore if it is not helpful.
🚀 🚀 🚀
| ) { | ||
| return <StyledAvatar ref={ref} alt={alt} size={size} square={square} {...rest} /> | ||
| const avatarSx = isResponsiveValue(size) | ||
| ? merge( |
There was a problem hiding this comment.
Sorry I missed your ping about the type stuff.
I think we could also do
merge<BetterSystemStyleObject>(...)
instead of typing each input as?
Also totally optional maybe for readability
constavatarSx=isResponsiveValue(size)
? getBreakpointDeclarations(size,'--avatar-size'askeyofReact.CSSProperties,value=>`${value||DEFAULT_AVATAR_SIZE}px`,)
: {'--avatar-size': `${size}px`}and then in the StyledAvatar
sx={merge<BetterSystemStyleObject>(avatarSx, sxProp)}
Just a suggestion - however you prefer.
There was a problem hiding this comment.
I think I remember there being an performance issue with passing merge() directly to to sx, so I'm going to keep it as-is. Definitely going to use a generic instead of as though. Great suggestion!
There was a problem hiding this comment.
Ohh I didn't know about the performance impact on using merge in sx! Thanks for letting me know!
mperrotti
commented
Jul 7, 2023
We do use |
mperrotti
commented
Jul 7, 2023
@dusave - I checked with a11y, and it looks like this is safe to keep enabled even when the user prefers reduced motion. |
…ct into mp/avatarstack-disable-expand

sizeprop toAvatarStacksizeprop to theAvatars that are direct children ofAvatarStackAvatarStackto render it's children at different sizes. The smallest size will always be picked.Closeshttps://github.com/github/primer/issues/2366
Screenshots
Kapture.2023-06-30.at.16.09.20.mp4
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.