Skip to content
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 posts and latest comments: add spacing support #45110

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Display a list of your most recent comments. ([Source](https://github.com/WordPr

- **Name:** core/latest-comments
- **Category:** widgets
- **Supports:** align, ~~html~~
- **Supports:** align, spacing (margin, padding), ~~html~~
- **Attributes:** commentsToShow, displayAvatar, displayDate, displayExcerpt

## Latest Posts
Expand All @@ -329,7 +329,7 @@ Display a list of your most recent posts. ([Source](https://github.com/WordPress

- **Name:** core/latest-posts
- **Category:** widgets
- **Supports:** align, typography (fontSize, lineHeight), ~~html~~
- **Supports:** align, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** addLinkToFeaturedImage, categories, columns, displayAuthor, displayFeaturedImage, displayPostContent, displayPostContentRadio, displayPostDate, excerptLength, featuredImageAlign, featuredImageSizeHeight, featuredImageSizeSlug, featuredImageSizeWidth, order, orderBy, postLayout, postsToShow, selectedAuthor

## List
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/latest-comments/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
},
"supports": {
"align": true,
"html": false
"html": false,
"spacing": {
"margin": true,
"padding": true
}
},
"editorStyle": "wp-block-latest-comments-editor",
"style": "wp-block-latest-comments"
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/latest-comments/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
<ServerSideRender
block="core/latest-comments"
attributes={ attributes }
skipBlockSupportAttributes
// The preview uses the site's locale to make it more true to how
// the block appears on the frontend. Setting the locale
// explicitly prevents any middleware from setting it to 'user'.
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/latest-comments/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ol.wp-block-latest-comments {
// Due to low specificity this will be safely overriden
// by default wp-block layout styles in the Post/Site editor
margin-left: 0;

// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
}

// Higher specificity - target list via wrapper.
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/latest-posts/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
"supports": {
"align": true,
"html": false,
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/latest-posts/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.wp-block-latest-posts {
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;

&.alignleft {
/*rtl:ignore*/
margin-right: 2em;
Expand Down