Skip to content

Corrects styling on Buttons that only have a count and icon - #5448

Merged
mperrotti merged 19 commits into
mainfrom
mp/iconbutton-count
Dec 19, 2024
Merged

Corrects styling on Buttons that only have a count and icon#5448
mperrotti merged 19 commits into
mainfrom
mp/iconbutton-count

Conversation

@mperrotti

@mperrottimperrotti commented Dec 16, 2024

Copy link
Copy Markdown
Contributor

Closeshttps://github.com/github/primer/issues/4501

Screenshot 2024-12-18 at 4 06 40 PM

Changelog

New

  • corrects padding on <Button> where there is only an icon and a counter label to closer align with <IconButton> sizing

Changed

Nothing

Removed

Nothing

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

Confirm that this change doesn't cause any regressions with existing IconButton behavior.

Merge checklist

@mperrotti
mperrotti requested a review from a team as a code ownerDecember 16, 2024 21:13
@changeset-bot

changeset-botBot commented Dec 16, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dbfbadb

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-actions

Copy link
Copy Markdown
Contributor

Uh oh! @mperrotti, the image you shared is missing helpful alt text. Check your pull request body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@github-actions

Copy link
Copy Markdown
Contributor

👋 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-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Dec 16, 2024
@mperrottimperrotti added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 16, 2024
@github-actions

github-actionsBot commented Dec 16, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js104.65 KB (+0.11% 🔺)
packages/react/dist/browser.umd.js104.99 KB (+0.02% 🔺)

@primer
primerBot requested a review from a team as a code ownerDecember 16, 2024 21:24
@primer
primerBot requested a review from tbenningDecember 16, 2024 21:24
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 16, 2024
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5448 December 16, 2024 21:26 Inactive
langermank
langermank previously requested changes Dec 16, 2024

@langermanklangermank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed on Slack and summarizing my thoughts here!

I would suggest putting this logic in Button to avoid adding a wrapper span inside IconButton. In order to utilize Button's layout wrapper .ButtonContent we're adding it to IconButton which feels like its adding unnecessary complexity given that this already exists in Button 😄

I would suggest...

  • Add a data-attribute to ButtonBase when count is true data-has-count for example
  • Add a CSS selector &:where([data-has-count]) and check if .Label is not there (not has?)
  • Remove padding if has count is true, .Label is not present. You could also check that a leading visual is present but I'm not sure that's necessary

If this doesn't work out I would feel better about that span being conditional in IconButton!

Comment threadpackages/react/src/Button/ButtonBase.module.css
export const TrailingCounterWithNoText = () => {
return <Button leadingVisual={CommentIcon} count={3} />
}
export const TrailingCounterWithNoText = () => <Button leadingVisual={CommentIcon} count={3} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add an aria-label or a Tooltip to this example?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Hmmm I'm torn on this. I'd prefer not to encourage tooltips, but it's common to use them for icon-only buttons.

Maybe add a second example in the same story?

@langermank
langermank dismissed their stale reviewDecember 18, 2024 21:40

Feedback addressed

@langermank

Copy link
Copy Markdown
Contributor

You'll need to remove the snapshots that were added, and if you want add a new VRT test for the feature story 👍

@mperrottimperrotti added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 18, 2024
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 18, 2024
@langermanklangermank added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 19, 2024

@langermanklangermank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀

@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Dec 19, 2024
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5448 December 19, 2024 18:36 Inactive
@mperrotti
mperrotti added this pull request to the merge queueDec 19, 2024
Merged via the queue into main with commit 00600f7Dec 19, 2024
@mperrotti
mperrotti deleted the mp/iconbutton-count branch December 19, 2024 18:51
@primerprimerBot mentioned this pull request Dec 19, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@mperrotti@langermank