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

RSS: Border & Spacing support #66411

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres

- **Name:** core/rss
- **Category:** widgets
- **Supports:** align, interactivity (clientNavigation), ~~html~~
- **Supports:** align, interactivity (clientNavigation), spacing (margin, padding), ~~html~~
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow

## Search
Expand Down
14 changes: 14 additions & 0 deletions packages/block-library/src/rss/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
"html": false,
"interactivity": {
"clientNavigation": true
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true
},
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"padding": false,
"margin": false
}
}
},
"editorStyle": "wp-block-rss-editor",
Expand Down
15 changes: 14 additions & 1 deletion packages/block-library/src/rss/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ export default function RSSEdit( { attributes, setAttributes } ) {
},
];

/*
* This function merges the existing attributes with additional style properties.
* The `border` and `spacing` properties are set to `undefined` to ensure that
* these styles are reset and not applied on the server side.
*/
const serverSideAttributes = {
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved
...attributes,
style: {
...attributes?.style,
border: undefined,
spacing: undefined,
},
};
return (
<>
<BlockControls>
Expand Down Expand Up @@ -189,7 +202,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
<Disabled>
<ServerSideRender
block="core/rss"
attributes={ attributes }
attributes={ serverSideAttributes }
/>
</Disabled>
</div>
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/rss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
.wp-block-rss__placeholder-form .wp-block-rss__placeholder-input {
flex: 1 1 auto;
}
// resetting all the various block support styles when skipping block supports in the server-side rendering
// to prevent the double-up of block support styles within the editor when server-side rendering
benazeer-ben marked this conversation as resolved.
Show resolved Hide resolved
.wp-block-rss .wp-block-rss {
all: inherit;
margin: 0;
padding: 0;
}
15 changes: 7 additions & 8 deletions packages/block-library/src/rss/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
ul.wp-block-rss { // The ul is needed for specificity to override the reset styles in the editor.
list-style: none;
padding: 0;

// This needs extra specificity due to the reset mixin on the parent: https://github.com/WordPress/gutenberg/blob/a250e9e5fe00dd5195624f96a3d924e7078951c3/packages/edit-post/src/style.scss#L54
&.wp-block-rss {
box-sizing: border-box;
}

&.alignleft {
/*rtl:ignore*/
Expand All @@ -19,7 +12,6 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
display: flex;
flex-wrap: wrap;
padding: 0;
list-style: none;

li {
margin: 0 1em 1em 0;
Expand All @@ -41,3 +33,10 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
display: block;
font-size: 0.8125em;
}
// This block has customizable padding, border-box makes that more predictable.
// This needs extra specificity due to the reset mixin on the parent: https://github.com/WordPress/gutenberg/blob/a250e9e5fe00dd5195624f96a3d924e7078951c3/packages/edit-post/src/style.scss#L54
.wp-block-rss {
box-sizing: border-box;
list-style: none;
padding: 0;
}
benazeer-ben marked this conversation as resolved.
Show resolved Hide resolved
Loading