-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Global Styles Sidebar: adjust icon vertical alignment with labels #39982
Conversation
Size Change: +70 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
This topic was discussed in #36653, and at the time it was decided to keep the lower-level Given what was discussed and agreed, I suggest we create such a component in a more "local" environment (for example, just for the Global Styles sidebar, or maybe in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are clean and make sense to me 👍 I only had a few minor comments, please consider them non-blocking!
margin-top: $grid-unit * 0.25; | ||
margin-bottom: $grid-unit * 0.25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, but I find that a "flexed wrapper div set to 24px height" captures the intent better. Or at least a wrapper div with vertical padding, rather than margins on ColorIndicator
itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'm going to close this conversation as I've decided to adopt an approach based on your suggestion in this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually went for this approach in the end, and added a ColorIndicatorWrapper
component which is basically a Flex
component with a fixed height of 24px
…Indicator` usages
dcca723
to
d33b9a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:chefs-kiss:
What?
This PR adjusts the vertical alignment between icons and labels in the Global Styles sidebar, as flagged in #38934.
HStack
,Flex
andItemGroup
, in case some of the anti-patterns described below are used.Why?
This is in order to follow the design specs highlighted in #38934
How?
After inspecting the layout of icons and labels, I noticed that the browser was always adding, under each icon, a few px of white space — this was due to the fact that the icons are an inline-block element within a block element, and therefore that white space was automatically added by the browser. Notice how the icon's wrapper element has a computed height of
27px
, instead of the expected24px
:This is a "classic" CSS layout problem (one hacky way to fix it, for example, is to set the
font-size
of the parent container to0
). Instead, I spent some more time in order to come up with a better fix:FlexItem
/FlexBlock
wrappers aroundIcon
components (FlexItem
/FlexBlock
havedisplay: block
, and were not really being of any use. By removing them, the new parent element of the icon becomes thedisplay: flex
parent, which automatically ignores the white space that previously was causing the misalignment)display: flex
parents, I had to apply those styles to theZStack
component to add that same fix the color palette screen (I will merge the changes toZStack
separately, but for now I've kept those changes within this PR for ease of understanding)4px
shorter with respect to all other items. This is because<ColorIndicator />
has a size of20px
, while the rest of the icons have a size of24px
. To make up for this, I've decided to apply a2px
top and bottom margin around the<ColorIndicator />
s, but we could also look into adding the possibility for<ColorIndicator />
to have a size of24px
instead (this needs design feedback)Testing Instructions
Screenshots or screencast
Example of the changes on the root screen: