Skip to content

Conversation

@jonrohan
Copy link
Member

@jonrohan jonrohan commented Apr 3, 2025

Changelog

New

Changed

Removed

Remove the CSS modules feature flag from the AvatarStack component

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

This shouldn't have any visual effect in production, the only thing to watch for is integration testing with the CI

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Apr 3, 2025

🦋 Changeset detected

Latest commit: 9095d07

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions github-actions bot added the staff Author is a staff member label Apr 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Apr 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 104.28 KB (-0.62% 🔽)
packages/react/dist/browser.umd.js 104.71 KB (-0.63% 🔽)

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/371265

@github-actions github-actions bot temporarily deployed to storybook-preview-5871 April 3, 2025 19:32 Inactive
@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Apr 3, 2025
@jonrohan jonrohan marked this pull request as ready for review April 3, 2025 19:45
@jonrohan jonrohan requested a review from a team as a code owner April 3, 2025 19:45
@jonrohan jonrohan requested a review from francinelucca April 3, 2025 19:45
@jonrohan jonrohan enabled auto-merge April 3, 2025 19:45
Comment on lines -21 to -180
type StyledAvatarStackWrapperProps = {
count?: number
} & SxProp

const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'

const AvatarStackWrapper = toggleStyledComponent(
CSS_MODULES_FEATURE_FLAG,
'span',
styled.span<StyledAvatarStackWrapperProps>`
--avatar-border-width: 1px;
--overlap-size: calc(var(--avatar-stack-size) * 0.55);
--overlap-size-avatar-three-plus: calc(var(--avatar-stack-size) * 0.85);
--mask-size: calc(100% + (var(--avatar-border-width) * 2));
--mask-start: -1;
--opacity-step: 15%;
display: flex;
position: relative;
height: var(--avatar-stack-size);
min-width: var(--avatar-stack-size);
isolation: isolate;
.pc-AvatarStackBody {
display: flex;
position: absolute;
${getGlobalFocusStyles('1px')}
}
.pc-AvatarItem {
--avatar-size: var(--avatar-stack-size);
flex-shrink: 0;
height: var(--avatar-stack-size);
width: var(--avatar-stack-size);
position: relative;
overflow: hidden;
display: flex;
transition:
margin 0.2s ease-in-out,
opacity 0.2s ease-in-out,
mask-position 0.2s ease-in-out,
mask-size 0.2s ease-in-out;
&:is(img) {
box-shadow: 0 0 0 var(--avatar-border-width)
${props => (props.count === 1 ? get('colors.avatar.border') : 'transparent')};
}
&:first-child {
margin-inline-start: 0;
}
&:nth-child(n + 2) {
margin-inline-start: calc(var(--overlap-size) * -1);
mask-image: radial-gradient(at 50% 50%, rgb(0, 0, 0) 70%, rgba(0, 0, 0, 0) 71%),
linear-gradient(rgb(0, 0, 0) 0 0);
mask-repeat: no-repeat, no-repeat;
mask-size:
var(--mask-size) var(--mask-size),
auto;
mask-composite: exclude;
// HORIZONTAL POSITION CALC FORMULA EXPLAINED:
// width of the visible part of the avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
// multiply by -1 for left-aligned, 1 for right-aligned ➡️ var(--mask-start)
// subtract the avatar border width ➡️ var(--avatar-border-width)
mask-position:
calc((var(--avatar-stack-size) - var(--overlap-size)) * var(--mask-start) - var(--avatar-border-width)) center,
0 0;
// HACK: This padding fixes a weird rendering bug where a tiiiiny outline is visible at the edges of the element
padding: 0.1px;
}
&:nth-child(n + 3) {
--overlap-size: var(--overlap-size-avatar-three-plus);
opacity: calc(100% - 2 * var(--opacity-step));
}
&:nth-child(n + 4) {
opacity: calc(100% - 3 * var(--opacity-step));
}
&:nth-child(n + 5) {
opacity: calc(100% - 4 * var(--opacity-step));
}
&:nth-child(n + 6) {
opacity: 0;
visibility: hidden;
}
}
&.pc-AvatarStack--two {
// MIN-WIDTH CALC FORMULA EXPLAINED:
// avatar size ➡️ var(--avatar-stack-size)
// plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
min-width: calc(var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)));
}
&.pc-AvatarStack--three {
// MIN-WIDTH CALC FORMULA EXPLAINED:
// avatar size ➡️ var(--avatar-stack-size)
// plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
// plus the visible part of the 3rd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)
min-width: calc(
var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)) +
(var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus))
);
}
&.pc-AvatarStack--three-plus {
// MIN-WIDTH CALC FORMULA EXPLAINED:
// avatar size ➡️ var(--avatar-stack-size)
// plus the visible part of the 2nd avatar ➡️ var(--avatar-stack-size) - var(--overlap-size)
// plus the visible part of the 3rd AND 4th avatar ➡️ (var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 2
min-width: calc(
var(--avatar-stack-size) + (var(--avatar-stack-size) - var(--overlap-size)) +
(var(--avatar-stack-size) - var(--overlap-size-avatar-three-plus)) * 2
);
}
&.pc-AvatarStack--right {
--mask-start: 1;
direction: rtl;
}
.pc-AvatarStackBody:not(.pc-AvatarStack--disableExpand):hover,
.pc-AvatarStackBody:not(.pc-AvatarStack--disableExpand):focus-within {
width: auto;
.pc-AvatarItem {
// reset size of the mask to prevent unintentially clipping due to the additional size created by the border width
--mask-size: 100%;
margin-inline-start: ${get('space.1')};
opacity: 1;
visibility: visible;
// HORIZONTAL POSITION CALC FORMULA EXPLAINED:
// width of the full avatar ➡️ var(--avatar-stack-size)
// multiply by -1 for left-aligned, 1 for right-aligned ➡️ var(--mask-start)
mask-position:
calc(var(--avatar-stack-size) * var(--mask-start)) center,
0 0;
${getGlobalFocusStyles('1px')}
&:first-child {
margin-inline-start: 0;
}
}
}
.pc-AvatarStack--disableExpand {
position: relative;
}
${sx};
`,
)

const transformChildren = (children: React.ReactNode, enabled: boolean) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow! 😍

@jonrohan jonrohan added this pull request to the merge queue Apr 4, 2025
Merged via the queue into main with commit 5525ed2 Apr 4, 2025
70 of 72 checks passed
@jonrohan jonrohan deleted the remove_css_module_flag_avatarstack branch April 4, 2025 02:07
@primer primer bot mentioned this pull request Apr 4, 2025
@francinelucca
Copy link
Member

Womp, looks like this passed golden jobs but not some other tests, can you take a look? @jonrohan https://github.com/github/github/pull/371265 👀

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

jonrohan added a commit that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants