Skip to content
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

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

Merged
merged 19 commits into from
Dec 19, 2024

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Dec 16, 2024

Closes https://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 owner December 16, 2024 21:13
Copy link

changeset-bot bot commented Dec 16, 2024

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

Copy link
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.

Copy link
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-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 Dec 16, 2024
Copy link
Contributor

github-actions bot commented Dec 16, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 104.65 KB (+0.11% 🔺)
packages/react/dist/browser.umd.js 104.99 KB (+0.02% 🔺)

@primer primer bot requested a review from a team as a code owner December 16, 2024 21:24
@primer primer bot requested a review from tbenning December 16, 2024 21:24
@primer primer bot temporarily deployed to github-pages December 16, 2024 21:26 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5448 December 16, 2024 21:26 Inactive
Copy link
Contributor

@langermank langermank left a comment

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!

@primer primer bot temporarily deployed to github-pages December 18, 2024 21:20 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5448 December 18, 2024 21:20 Inactive
export const TrailingCounterWithNoText = () => {
return <Button leadingVisual={CommentIcon} count={3} />
}
export const TrailingCounterWithNoText = () => <Button leadingVisual={CommentIcon} count={3} />
Copy link
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
Contributor Author

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 review December 18, 2024 21:40

Feedback addressed

@langermank
Copy link
Contributor

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

@mperrotti mperrotti requested a review from langermank December 18, 2024 22:27
Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

🚀

@mperrotti mperrotti enabled auto-merge December 19, 2024 18:36
@mperrotti mperrotti added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 00600f7 Dec 19, 2024
42 checks passed
@mperrotti mperrotti deleted the mp/iconbutton-count branch December 19, 2024 18:51
@primer primer bot mentioned this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This 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