-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Migrate from TextControl to NumberControl to remove margin overrides #47160
Conversation
label={ __( 'Order' ) } | ||
value={ value } | ||
onChange={ setUpdatedOrder } | ||
size={ 6 } | ||
labelPosition="side" |
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.
Because NumberControl has an option for a side label, the label ends up being more centered than it does in trunk.
And these changes remove the need for a CSS file at all for this component.
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.
Nice one!
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.
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.
Oh, nice find! It's aligned in FireFox but I see this in Safari now. I'll update it and check a few browsers to double-check. 👍
.block-editor-image-size-control__height { | ||
margin-bottom: 0.5em; | ||
|
||
// Fix the text and placeholder text being misaligned in Safari |
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 removed CSS that was added three years ago for a Safari fix, but when testing Safari with the removed code, it looked the same as other browsers.
8a95452
to
c10cd1c
Compare
Size Change: -207 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Flaky tests detected in c10cd1c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3917819816
|
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.
Ooh, great idea to migrate to NumberControl!
packages/block-editor/src/components/image-size-control/index.js
Outdated
Show resolved
Hide resolved
<VStack className="block-editor-image-size-control" spacing="0"> | ||
<p>{ __( 'Image dimensions' ) }</p> | ||
|
||
<HStack align="baseline" spacing="3"> |
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.
What is the align baseline for?
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.
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.
So it isn't needed now that we dealt with the bottom margin problem?
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.
@mirka, can you clarify what you mean by 'it' in your question? I'm not sure I understand so I just wanted to confirm if I need to remove anything before merging. 🙂
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.
Ah sorry, I meant the align="baseline"
.
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.
No worries! It is needed, from what I can tell, so it doesn't end up looking like the screenshot above.
label={ __( 'Order' ) } | ||
value={ value } | ||
onChange={ setUpdatedOrder } | ||
size={ 6 } | ||
labelPosition="side" |
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.
Nice one!
label={ __( 'Order' ) } | ||
value={ value } | ||
onChange={ setUpdatedOrder } | ||
size={ 6 } | ||
labelPosition="side" |
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.
c10cd1c
to
25e09c9
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.
Looks good! 🚢
<VStack className="block-editor-image-size-control" spacing="0"> | ||
<p>{ __( 'Image dimensions' ) }</p> | ||
|
||
<HStack align="baseline" spacing="3"> |
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.
So it isn't needed now that we dealt with the bottom margin problem?
25e09c9
to
2ea705e
Compare
What?
Updated
TextControl
instances using type number toNumberControl
component.Why?
While working on this project to remove margin overrides, I thought it made more sense to use NumberControl which also helped with removing overrides.
How?
By adding NumberControl, HStack, and VStack and removing unnecessary CSS.
Testing Instructions
ImageSizeControl
Before
After
InlineUI
Before
After
PageAttributesOrder
Before
After