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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

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: 07f8bc9

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 103.32 KB (-0.02% 🔽)
packages/react/dist/browser.umd.js 103.72 KB (+0.05% 🔺)

@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!

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.

@mperrotti mperrotti changed the title Adds count prop to IconButton Corrects styling on Buttons that only have a count and icon Dec 18, 2024
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.

Comment on lines +511 to +521
&:where([data-has-count]):has([data-component='leadingVisual']):not(:has([data-component='text'])) {
padding-inline: var(--control-medium-paddingInline-condensed);

&:where([data-size='small']) {
padding-inline: var(--control-xsmall-paddingInline-condensed);
}

&:where([data-size='large']) {
padding-inline: var(--control-large-paddingInline-normal);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&:where([data-has-count]):has([data-component='leadingVisual']):not(:has([data-component='text'])) {
padding-inline: var(--control-medium-paddingInline-condensed);
&:where([data-size='small']) {
padding-inline: var(--control-xsmall-paddingInline-condensed);
}
&:where([data-size='large']) {
padding-inline: var(--control-large-paddingInline-normal);
}
}
&:where([data-has-count]):has([data-component='leadingVisual']):not(:has([data-component='text'])) {
/* stylelint-disable-next-line primer/spacing */
padding-inline: var(--control-medium-paddingInline-condensed);
&:where([data-size='small']) {
/* stylelint-disable-next-line primer/spacing */
padding-inline: var(--control-xsmall-paddingInline-condensed);
}
&:where([data-size='large']) {
/* stylelint-disable-next-line primer/spacing */
padding-inline: var(--control-large-paddingInline-normal);
}
}

I think this will work for lint but the formatting might be off

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?

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