-
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
TextControl: remove margin overrides and add new opt-in prop (pt 2/2) #47158
Conversation
Size Change: -584 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
justify="flex-end" | ||
> | ||
<FlexItem> | ||
<VStack spacing="5"> |
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.
Added VStack with spacing to be consistent with other modals, as the spacing between the input and button wasn't the same as other modals in the site editor.
className="edit-site-create-template-part-modal__area-base-control" | ||
> | ||
<RadioGroup | ||
<VStack spacing="4"> |
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 personally think that the new spacing looks more centered, but I could be wrong. I can add CSS to make it like trunk if others prefer.
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 to me 👍
|
||
.edit-site-create-template-part-modal__area-base-control .components-base-control__label { | ||
margin: $grid-unit-20 0 $grid-unit-10; | ||
cursor: auto; |
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.
Is there a reason why we'd use a text cursor here?
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.
Wow this is interesting, I've never noticed it before. The standard WordPress forms.css adds a cursor: pointer
to all label
s:
I'm guessing the intent was to add an affordance that the labels are clickable. But unfortunately that is not always true, as is in this case (and some others, e.g. <progress>
). So that's probably why they explicitly overrode the cursor: pointer
here.
cc @ciampo FYI
@@ -1,18 +1,16 @@ | |||
.block-editor-date-format-picker { |
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.
We can add CSS to make it the same as trunk, but there is a 20px space so we'd either have to use 16px, 24px, or possibly a grid unit subtracted by another in order to get 20px if we're okay to not use a single grid unit.
display: flex; | ||
place-content: space-between; | ||
margin-top: $grid-unit-40; | ||
margin-top: $grid-unit-20; |
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.
Curious about when we should use a Spacer component instead of a margin like in this instance, but it seems like it could be debatable. :)
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.
Far enough! The reasoning here was to get closer to matching trunk. If the narrow gap is okay, I'd rather remove the margin altogether. Or add Spacer unless that's also weird to have a gap and Spacer. But then I know you'd like to avoid Spacer in general! 😅
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.
Thanks for clarifying! I missed this comment earlier but my latest commit covers this now.
@@ -44,6 +44,7 @@ const Template: ComponentStory< typeof Placeholder > = ( args ) => { | |||
<Placeholder { ...args }> | |||
<div> | |||
<TextControl | |||
__nextHasNoMarginBottom |
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.
Adding to stories, as we did with Disabled in a related PR. The spacing is also similar to what we did with the legacy widget in the SelectControl PR,
Flaky tests detected in ac7ba5d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4002185476
|
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 call to split the PRs!
It's nice to clean up all this CSS, but it's also nice to see the kinds of common UI patterns in the Gutenberg app. I think it will help inform our API design decisions.
.block-editor-date-format-picker__custom-format-select-control { | ||
&.components-base-control { | ||
margin-bottom: 0; | ||
} | ||
} |
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.
It looks the BaseControl here is used merely for its implicit 8px margin-bottom properties (which is exactly the thing we're deprecating 😄). I think we can remove the BaseControl altogether and just wrap the CustomSelectControl and TextControl in a VStack.
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.
Great find! I'll keep an eye out for stuff like this in the future
.block-library-video-tracks-editor__single-track-editor-track-title, | ||
.block-library-video-tracks-editor__single-track-editor-source-language { | ||
flex: 1; |
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.
This looks like a use case for Grid
rather than HStack
, since we know we want two equal-width columns.
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.
Awesome! I should have known there was a Grid component out there :) Thanks!
display: flex; | ||
place-content: space-between; | ||
margin-top: $grid-unit-40; | ||
margin-top: $grid-unit-20; |
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.
<div className="block-library-video-tracks-editor__single-track-editor"> | ||
<VStack | ||
className="block-library-video-tracks-editor__single-track-editor" | ||
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.
One thing I noticed is that spacing=3
makes it a little hard to tell that the help text is associated with the items on top. It does seem like an insufficient amount of whitespace when help text is involved. I'll leave it up to you, but this might be a good time to switch this to the new grid spacing guidance, which would be spacing=4
.
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 agree! And nice, I love consistent spacing; sooo glad to see there are guidelines! 😍
|
||
.edit-site-create-template-part-modal__area-base-control .components-base-control__label { | ||
margin: $grid-unit-20 0 $grid-unit-10; | ||
cursor: auto; |
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.
Wow this is interesting, I've never noticed it before. The standard WordPress forms.css adds a cursor: pointer
to all label
s:
I'm guessing the intent was to add an affordance that the labels are clickable. But unfortunately that is not always true, as is in this case (and some others, e.g. <progress>
). So that's probably why they explicitly overrode the cursor: pointer
here.
cc @ciampo FYI
className="edit-site-create-template-part-modal__area-base-control" | ||
> | ||
<RadioGroup | ||
<VStack spacing="4"> |
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 to me 👍
07cd8e6
to
74e2a4a
Compare
@mirka, just to note, I also included the file I originally intended to include it in this PR due to some minor visual changes, but I ended up with it matching trunk. I just remembered that I needed to move it to part 1, but I merged that already. However, in the spirit of part 2, it would be possible to remove most of the CSS (this has |
…inor visual changes
749debf
to
ac7ba5d
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.
Great cleanup! 🔥 🧹
Always good to see more 🔴 than 🟢 in the diff! Thank you @brookewp for working on this! |
Part 2/2
What?
Added new opt-in prop
__nextHasNoMarginBottom
for usages ofTextControl
in the Gutenberg codebase and removed margin overrides.This is part of #47157 but was separated due to small visual changes to each of the blocks/components in this PR.
Why?
These changes will result in less CSS used in favour of components.
Part of this project: #38730
The tl;dr is
BaseControl
has amargin-bottom
which makes it difficult to reuse and results in inconsistent use.How?
By removing margin overrides in the CSS and adding the prop
__nextHasNoMarginBottom
. As well as addingVStack
andHStack
(and sometimes replacingFlex
with those) to remove additional CSS.Additional Notes
packages/block-library/src/post-comment/edit.js
has been deprecated. I looked at it in the editor, and it looks a bit broken as it is:Adding the prop won't affect it by much, it shifts slightly down a pixel (similar to the legacy widget in the SelectControl PR, which we updated without adding additional overrides), so I added it here to be consistent.
Testing Instructions
Rather than verifying if the changes look the same as trunk, we'll need to make sure that these minor visual changes are okay or if we need to add CSS overrides to match perfectly to trunk.
Block Editor testing steps:
HierarchicalTermSelector
gutenberg/packages/editor/src/components/post-taxonomies/hierarchical-term-selector.js
Line 40 in f7052d3
NonDefaultControls (DateFormatPicker)
Before
After
ImageURLInputUI
Before
After
SingleTrackEditor
Before
After
SocialLinkEdit
Before
After
Site Editor testing steps:
CreateTemplatePartModal
Before
After
TitleModal
Before
After
Storybook testing steps:
Placeholder
npm run storybook:dev
Before
After