Skip to content

Set a default icon margin for buttons with icon and text.#12901

Merged
afercia merged 1 commit intomasterfrom
update/icon-button-icon-text-margin
Jan 9, 2019
Merged

Set a default icon margin for buttons with icon and text.#12901
afercia merged 1 commit intomasterfrom
update/icon-button-icon-text-margin

Conversation

@afercia
Copy link
Copy Markdown
Contributor

@afercia afercia commented Dec 15, 2018

Description

This small PR seeks to improve the IconButton component by making sure there's some spacing between the button's icon and text.

  • removes the CSS rule :not:only-child as it doesn't work with text nodes (it was also missing the parenthesis)
  • adds a CSS selector modifier when the IconButton has visible text and uses that to set a margin

Notes:

  • other components that reuse the IconButton set their own CSS rules to have a margin, for example: the Revisions link, the buttons in the More menu, and the buttons in the Block menu. Now that there's a default margin, maybe all those ad-hoc rules could be removed
  • I've kept the original 4px margin but I've seen the other cases mentioned above use a 5px value, not sure which is the one to use

/Cc @jasmussen

Example screenshot before:

screenshot 2018-12-15 at 11 03 43

After:

screenshot 2018-12-15 at 12 20 23

Fixes #12900

@gziolo gziolo added [Type] Bug An existing feature does not function as intended Needs Design Feedback Needs general design feedback. labels Dec 16, 2018
@gziolo gziolo requested a review from jasmussen December 16, 2018 20:05
@jasmussen
Copy link
Copy Markdown
Contributor

This seems good to me, and in my testing doesn't break anything anywhere else. Nice work!

@gziolo can you sanity check the code changes? It seems good to me on the face of it. 👍 👍

Copy link
Copy Markdown
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Code 👍

@gziolo gziolo added this to the 4.8 milestone Dec 17, 2018
@gziolo gziolo removed the Needs Design Feedback Needs general design feedback. label Dec 17, 2018
@afercia
Copy link
Copy Markdown
Contributor Author

afercia commented Dec 17, 2018

Thanks. Please do feel free to push the green button (I don't have merge powers).

@youknowriad youknowriad modified the milestones: 4.8, 4.9 Dec 19, 2018
@afercia afercia force-pushed the update/icon-button-icon-text-margin branch from 4ad4b32 to abd4982 Compare January 2, 2019 09:57
@afercia
Copy link
Copy Markdown
Contributor Author

afercia commented Jan 9, 2019

Everything is green and it's already milestoned for 4.9. Merging.

@afercia afercia merged commit 14374e5 into master Jan 9, 2019
@afercia afercia deleted the update/icon-button-icon-text-margin branch January 9, 2019 14:52
jasmussen pushed a commit that referenced this pull request Feb 8, 2019
In #12901, a small margin was introduced to the IconButton component when text was present. This caused an issue with block icons, scaling them down when they shouldn't be. A 20x20px icon should show as 20x20, and a 24x24px icon should show as 24x24px.

The additional margin was applied even when the IconButton didn't actually have text. It simply needed `children`, and in the case of the Switcher, it has a dropdown arrow. Combined with the fixed width of the switcher, that meant a 24x24 icon would be rendered as 20x24.

This PR adds a length check so if your IconButton includes more than 2 letters, it's considered to have a text label. This fixes the issue. But as you can tell, maybe it's not the best way to check whether there's text or not. Suggestions most welcome.
jasmussen pushed a commit that referenced this pull request Feb 12, 2019
In #12901, a small margin was introduced to the IconButton component when text was present. This caused an issue with block icons, scaling them down when they shouldn't be. A 20x20px icon should show as 20x20, and a 24x24px icon should show as 24x24px.

The additional margin was applied even when the IconButton didn't actually have text. It simply needed `children`, and in the case of the Switcher, it has a dropdown arrow. Combined with the fixed width of the switcher, that meant a 24x24 icon would be rendered as 20x24.

This PR adds a length check so if your IconButton includes more than 2 letters, it's considered to have a text label. This fixes the issue. But as you can tell, maybe it's not the best way to check whether there's text or not. Suggestions most welcome.
gziolo pushed a commit that referenced this pull request Feb 13, 2019
* Fix icon size regression in Switcher

In #12901, a small margin was introduced to the IconButton component when text was present. This caused an issue with block icons, scaling them down when they shouldn't be. A 20x20px icon should show as 20x20, and a 24x24px icon should show as 24x24px.

The additional margin was applied even when the IconButton didn't actually have text. It simply needed `children`, and in the case of the Switcher, it has a dropdown arrow. Combined with the fixed width of the switcher, that meant a 24x24 icon would be rendered as 20x24.

This PR adds a length check so if your IconButton includes more than 2 letters, it's considered to have a text label. This fixes the issue. But as you can tell, maybe it's not the best way to check whether there's text or not. Suggestions most welcome.

* Address feedback.

Props @aduth for essentially writing this PR.
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
* Fix icon size regression in Switcher

In #12901, a small margin was introduced to the IconButton component when text was present. This caused an issue with block icons, scaling them down when they shouldn't be. A 20x20px icon should show as 20x20, and a 24x24px icon should show as 24x24px.

The additional margin was applied even when the IconButton didn't actually have text. It simply needed `children`, and in the case of the Switcher, it has a dropdown arrow. Combined with the fixed width of the switcher, that meant a 24x24 icon would be rendered as 20x24.

This PR adds a length check so if your IconButton includes more than 2 letters, it's considered to have a text label. This fixes the issue. But as you can tell, maybe it's not the best way to check whether there's text or not. Suggestions most welcome.

* Address feedback.

Props @aduth for essentially writing this PR.
youknowriad pushed a commit that referenced this pull request Mar 6, 2019
* Fix icon size regression in Switcher

In #12901, a small margin was introduced to the IconButton component when text was present. This caused an issue with block icons, scaling them down when they shouldn't be. A 20x20px icon should show as 20x20, and a 24x24px icon should show as 24x24px.

The additional margin was applied even when the IconButton didn't actually have text. It simply needed `children`, and in the case of the Switcher, it has a dropdown arrow. Combined with the fixed width of the switcher, that meant a 24x24 icon would be rendered as 20x24.

This PR adds a length check so if your IconButton includes more than 2 letters, it's considered to have a text label. This fixes the issue. But as you can tell, maybe it's not the best way to check whether there's text or not. Suggestions most welcome.

* Address feedback.

Props @aduth for essentially writing this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants