Button: Fix incorrect padding with text and right icon#71464
Button: Fix incorrect padding with text and right icon#71464aduth merged 6 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @epeicher! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
aduth
left a comment
There was a problem hiding this comment.
I wondered if there might be a way to style this without an additional class†, but I think this is a simple solution consistent with the existing style arrangement for left icon + text. LGTM 👍
† The original styles prior to #50277 targeted svg elements, so technically we could do something like .button:has(svg:last-child) { ... }, but targeting svg broadly doesn't feel like it provides as much guarantees as here with icon and icon positioning.
|
It looks like the failing Unit Tests are true failures pointing to some snapshots that need to be updated. Can you update those? |
Thanks @aduth for the review! I agree with this, it is a simple solution consistent with the existing code, and targeting
Thanks for letting me know! I didn't realise of that, I have updated the snapshots by running |
|
Thanks for the updates! I had to fight a bit with some merge conflicts and flakey tests after adding a changelog note, but finally got this merged today 😄 |
What?
Closes #60734
This PR fixes the right padding when the button has text and an icon positioned on the right. This is required to compensate the extra padding that the icon adds. This is already working for the icon positioned on the left, but the right position of the icon was not taken into account.
Why?
Because when the button has text and an icon positioned on the right, there is more padding on the right of the button than on the left.
How?
Adding an additional
cssclass namedhas-icon-rightthat is only added when the icon is positioned on the right. That class will apply the correct padding in thecssfile.Testing Instructions
npm run storybook:devControlstab on the bottom, find theiconprop and select an icon, e.g.wordpressiconPositionprop below, selectright?path=/story/components-button--primary&args=icon:wordpress;iconPosition:rightTesting Instructions for Keyboard
Screenshots or screencast