-
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
Reduce the specificity of block styles to simplify editor styles slightly #14407
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,17 @@ | |
} | ||
|
||
.wp-block-button { | ||
display: inline-block; | ||
margin-bottom: 0; | ||
position: relative; | ||
|
||
[contenteditable] { | ||
cursor: text; | ||
} | ||
|
||
// Don't let placeholder expand parent width. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this was applied to the button itself, it prevented the margin collapse. By moving it down here, the net result is the same: an empty button isn't 100% wide, but it looks the same in frontend and backend. |
||
.block-editor-rich-text { | ||
display: inline-block; | ||
} | ||
|
||
// Make placeholder text white unless custom colors or outline versions are chosen. | ||
&:not(.has-text-color):not(.is-style-outline) .block-editor-rich-text__editable[data-is-placeholder-visible="true"] + .block-editor-rich-text__editable { | ||
color: $white; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
.wp-block-html .block-editor-plain-text { | ||
font-family: $editor-html-font; | ||
color: $dark-gray-800; | ||
padding: 0.8em 1em; | ||
border: 1px solid $light-gray-500; | ||
border-radius: 4px; | ||
.wp-block-html { | ||
margin-bottom: $default-block-margin; | ||
|
||
/* Fonts smaller than 16px causes mobile safari to zoom. */ | ||
font-size: $mobile-text-min-font-size; | ||
@include break-small { | ||
font-size: $default-font-size; | ||
} | ||
.block-editor-plain-text { | ||
font-family: $editor-html-font; | ||
color: $dark-gray-800; | ||
padding: 0.8em 1em; | ||
border: 1px solid $light-gray-500; | ||
border-radius: 4px; | ||
|
||
/* Fonts smaller than 16px causes mobile safari to zoom. */ | ||
font-size: $mobile-text-min-font-size; | ||
@include break-small { | ||
font-size: $default-font-size; | ||
} | ||
|
||
&:focus { | ||
box-shadow: none; | ||
&:focus { | ||
box-shadow: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
.wp-block-quote { | ||
margin: 0; | ||
|
||
&__citation { | ||
font-size: $default-font-size; | ||
} | ||
.wp-block-quote__citation { | ||
font-size: $default-font-size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.block-library-spacer__resize-container.is-selected { | ||
background: $light-gray-200; | ||
} | ||
|
||
.block-library-spacer__resize-container { | ||
margin-bottom: $default-block-margin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't know if having the margins here is a bad thing. I do understand the reasoning behind moving them to the individual block to allow them to be overridden there. But were there really a lot of complaints about the margins not matching up with the front-end?
Like I've said before, I think a little variance is expected in the administrative UI. Enough space for controls to work is absolutely a good reason for this.
That said, I think the space could be reduced from
32px
.The element's margins will take over as long as they're greater than the
.block-editor-block-list__block-edit
margins.For example if a paragraph's
p
tag has amargin-bottom: 40px
, then that block will have40px
margin between it and the next block in the editor. If it hasmargin-bottom: 16px
, then it'll have the "fallback" margin from.block-editor-block-list__block-edit
of32px
.So the trick is to define the minimum required margin for a good editing experience and let theme styles go bigger but not smaller.
In my short experimenting
24px
seems to work well. (wish it was less, but it just isn't)24px
roughly equates to1.5rem
which is a common margin, I think, so that's good. I would avoidem
because of it's unpredictability.And @ellatrix has a good point. The top margin is a bit pointless. Only place it would be seen is on the
:first-child
, but amargin-bottom
on.editor-post-title
would accomplish the same.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.
Well, see feedback on this thread ;)
Edit: to clarify — it's not about complaints that the margins didn't match up to the front-end, it was about the selector being too specific and therefore hard for themes to override. Did not mean to be sarcastic or snide in that comment above, sorry if it came off that way.
The ultimate goal is for the editor to be able to look exactly like the frontend with minimal work by the theme editor. Every research we've conducted suggests that when there's a strong visual connection between the two, usability increases. I agree, a little variance is acceptable, but I also feel the more we can do to reduce this variance, the better. The difficult balance is to ensure a good editing experience for themes that do not style the editor.
To the rest of your feedback, very solid, thank you, and I agree with Ella too. Will take a stab at addressing both of your points.
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 tried to chagne the 32px to 24px. But it starts to affect the multi-select appearance.
32px:
24px:
What happens there is that every block has a footprint, and outside that footprint, the block borders are drawn. By default this block border is drawn 14px out, which means two blocks next to each other, both multi-selected, will have 14px + 14px of "selection rectangle" drawn around them. Which means if the margin between the two blocks was 28px, they would appear flush next to each other. At 32px there's 4px gap. At 24px, there's a 4px overlap which is what you're seeing in the second screenshot.
All that is to say: we can change that. There's a $block-padding variable that's trivial to change. If 24px is the magic number, we can set the block padding to 10 or 12px.
But this is a big visual change, and I would love to ship this PR before exploring such a change. Do you think we could explore such a margin and padding change separately?
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.
You've been busy today @jasmussen ! 😄
You're right. In my idealistic mind, themes shouldn't need to think about overriding anything and selectors like
.block-editor-block-list__block-edit
shouldn't ever be a part of a theme's vocabulary.We're lucky enough to have a lot of semantic HTML5 element wrappers on our blocks. These elements are often the first things to get styled in themes, old and new.
That's free backward compatibility if we can take advantage of it.
Definitely. I think setting the minimum spacing on this wrapping editor element will be key to making this work well. It will act as a safety net in case somebody is using a crazy Meyer type reset but it'll allow a themes vertical rhythm to shine through in most cases.
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 think this is probably a key insight. @kjellr suggested something slightly similar in a recent chat. In #14407 (comment) I tried a generic rule that didn't quite work out. But maybe this idea can inspire a better rule?