Skip to content

refactor(Avatar): Refactor Avatar component to use CSS modules behind feature flag - #4885

Merged
jonrohan merged 13 commits into
mainfrom
css_modules_avatar
Sep 11, 2024
Merged

refactor(Avatar): Refactor Avatar component to use CSS modules behind feature flag#4885
jonrohan merged 13 commits into
mainfrom
css_modules_avatar

Conversation

@jonrohan

@jonrohanjonrohan commented Aug 26, 2024

Copy link
Copy Markdown
Member

Part of https://github.com/github/primer/issues/3877

Changelog

Changed

Converting Avatar component to use CSS modules behind the primer_react_css_modules_team feature flag

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

Tests updated for in and outside of feature flag.

Merge checklist

@changeset-bot

changeset-botBot commented Aug 26, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 46da581

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

This PR includes changesets to release 1 package
NameType
@primer/reactMinor

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-actionsgithub-actionsBot added the staff Author is a staff member label Aug 26, 2024
@github-actions

github-actionsBot commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js97.24 KB (+0.18% 🔺)
packages/react/dist/browser.umd.js97.62 KB (+0.16% 🔺)

@github-actions
github-actionsBottemporarily deployed to storybook-preview-4885 September 5, 2024 18:23 Inactive
@jonrohan
jonrohan marked this pull request as ready for review September 5, 2024 18:53
@jonrohan
jonrohan requested a review from a team as a code ownerSeptember 5, 2024 18:53
Comment on lines +68 to +75
for (const [key, value] of Object.entries(size)) {
// @ts-ignore - css property
cssSizeVars[`--avatarSize-${key}`] = `${value}px`
}
} else {
// @ts-ignore - css property
cssSizeVars['--avatarSize-regular'] = `${size}px`
}

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This is the biggest weirdness I was doing, trying to set CSS vars on the object if multiple sizes were passed in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense to me 👍 This is very similar to what we do for ResponsiveValue with data attributes (e.g. data-gap-narrow, data-gap-regular) and makes a lot of sense to do CSS Custom Properties for values like this.

@joshblackjoshblack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Just had a couple of questions and some feedback for the @ts-ignore if it's helpful 👍

Comment on lines +68 to +75
for (const [key, value] of Object.entries(size)) {
// @ts-ignore - css property
cssSizeVars[`--avatarSize-${key}`] = `${value}px`
}
} else {
// @ts-ignore - css property
cssSizeVars['--avatarSize-regular'] = `${size}px`
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense to me 👍 This is very similar to what we do for ResponsiveValue with data attributes (e.g. data-gap-narrow, data-gap-regular) and makes a lot of sense to do CSS Custom Properties for values like this.

Comment threadpackages/react/src/Avatar/Avatar.tsx Outdated
Comment threadpackages/react/src/Avatar/Avatar.tsx Outdated
@jonrohan
jonrohan added this pull request to the merge queueSep 11, 2024
@jonrohan
jonrohan removed this pull request from the merge queue due to a manual request Sep 11, 2024
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4885 September 11, 2024 17:32 Inactive
@jonrohan
jonrohan added this pull request to the merge queueSep 11, 2024
Merged via the queue into main with commit 373ce95Sep 11, 2024
@jonrohan
jonrohan deleted the css_modules_avatar branch September 11, 2024 17:57
@primerprimerBot mentioned this pull request Sep 11, 2024
@primerprimerBot mentioned this pull request Oct 18, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jonrohan@joshblack