-
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
Latest Comments: Add border block support #66020
base: trunk
Are you sure you want to change the base?
Changes from all commits
8cf68af
8c2b7e1
62bebfb
0b1dd41
bfe764a
b447807
37cb235
28e29c6
72b3168
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Higher specificity - target list via wrapper. | ||
.wp-block-latest-comments .wp-block-latest-comments { | ||
// Remove spacing. Higher specificity required to | ||
// override default wp-block layout styles in the Post/Site editor. | ||
padding: 0; | ||
// These styles prevent duplicate borders in the Latest Comments block caused by | ||
// server-side rendering injecting additional styles in the editor. They ensure | ||
// consistent appearance in the editor while avoiding conflicts with frontend styles. | ||
border: none; | ||
border-radius: inherit; | ||
} | ||
|
||
// Reset margin for inner elements of the server-side rendered block | ||
// to avoid extra spacing introduced in the editor | ||
ol.wp-block-latest-comments { | ||
margin: 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.wp-block-latest-comments { | ||
// This block has customizable border, border-box makes that more predictable. | ||
box-sizing: border-box; | ||
} | ||
|
||
// Lower specificity - target list element. | ||
ol.wp-block-latest-comments { | ||
// Removes left spacing in Customizer Widgets screen. | ||
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. Should this style still be in the frontend styles? Its specificity is also higher than the style produced by global styles. (0-1-0). The only reason the global styles margins in the editor work is because the block is server-side rendered and the block's outer wrapper receiving the margins is then a In other words, when you moved the |
||
|
@@ -26,13 +31,6 @@ ol.wp-block-latest-comments { | |
} | ||
} | ||
|
||
// Higher specificity - target list via wrapper. | ||
.wp-block-latest-comments .wp-block-latest-comments { | ||
// Remove left spacing. Higher specificity required to | ||
// override default wp-block layout styles in the Post/Site editor. | ||
padding-left: 0; | ||
} | ||
|
||
.wp-block-latest-comments__comment { | ||
list-style: none; | ||
margin-bottom: 1em; | ||
|
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's a difference between the editor and frontend still when it comes to padding.
If no padding is specified in the editor, the frontend still uses the
padding-left
from the browser's user agent list styles.We probably need to make that consistent. For backwards compatibility though, I don't think we can just remove the user agent padding. Some themes might be relying on that padding.
I'm not sure if it is possible to make the editor display the user agent list padding-left, without perhaps changing the server side render's outer wrapper to be an
ol
instead of adiv
. That would then require massaging all those list styles on the outer wrapper again.If there's no good option there, perhaps we'll need to get design feedback on whether the user agent styles for the comments block could be safely reset on the frontend.
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 would prefer applying the
padding: 0
on the front over changing the wrapper, because it is a smaller change.And the markup in the editor is already pretty complex.
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.
For clarity, my suggestion was only to swap the wrapper from this block's server-side rendering to a list element instead of a div. Then apply any necessary reset styles. I don't think that makes the markup in the editor more complex.
The main goal for me is visual consistency for the user between the editor and frontend. I ultimately don't have a strong opinion on whether that's done by tweaking the block's editor rendering or the additional padding reset on the frontend. I am a bit wary of anything that could be a breaking change for frontend styles though.
As you note it is a small change so perhaps it is something that could be merged early in the release cycle and called out?