-
Notifications
You must be signed in to change notification settings - Fork 535
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
Fix AvatarStack opacity for children without sx prop #1751
Conversation
.pc-AvatarItem elements need both opacity and z-index styles in order to display properly. Since children of AvatarStack are not guaranteed to have an sx prop, it can't reliably enforce these rules. Instead, AvatarStackWrapper can define the styles.
🦋 Changeset detectedLatest commit: abcc056 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 📦
|
@talune 👋 - Thanks for putting up this PR - looks great. Wanted to check something first. The storybook example appears to be incorrect, as the correct usage for Converting the |
Thanks, @rezrah! Yes, you're correct that the storybook example looks off because the child elements are In my team's case, we were correctly using I noticed the storybook bug while working on the above resolution, and decided to take a closer look. The storybook bug has the same root issue: I think it's a bit confusing to have the You're absolutely right that the styles render correctly if one uses |
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.
@talune - thanks for the background on this issue. I saw your fix here, glad it's been resolved.
We encourage using Avatar
over a native img
inside AvatarStack, so we'll fix up the Story so that it doesn't confuse others in future. Apologies for any confusion that caused you too.
With regards to the PR itself, I've tested it for visual regression too and it seems okay 👍 . Co-locating the styles seems sensible, but I can't reproduce the bug around Avatar
sx props being overridden, as it merges prop styles with z-index fine for me 🤔 . I do like how this makes the code and design logic easier to reason about though, and will therefore help us move this component to beta
faster, so thanks for this contribution.
Edit: PR was missing a changeset, which is required to merge and trigger a new npm release. I've added one for you just now, so please go ahead and merge this PR when you're happy to proceed.
Thank you for the extra context and for adding the changeset, @rezrah! I was prompted to first merge in |
What this changes
Resolves https://github.com/github/memex/issues/6311
This change adjusts how style rules are defined for
.pc-AvatarItem
so that children ofAvatarStack
display correctly regardless of if the child element has ansx
prop.Previously,
opacity
was defined inAvatarStackWrapper
, butz-index
was passed to the child'ssx
prop. If the child element didn't have thesx
prop, then avatars were stacked in reverse order, with the least opaque on top, as can be seen in the storybook example here.To resolve, I removed the
z-index
mapping fromtransformChildren
, and instead defined the appropriatez-index
explicitly in the same place asopacity
-- inAvatarStackWrapper
.Screenshots
Before:
After
https://user-images.githubusercontent.com/6740550/146618418-8a415298-666d-4ca4-a7d9-a1aa358701f5.mov
Merge checklist