Skip to content

Commit d9fa3ac

Browse files
benazeer-benbenazeer-benramonjdaaronrobertshawshail-mehta
authored
RSS: Border & Spacing support (#66411)
* RSS block border support * Added block and spacing support for RSS block * Doc Build * Lint js fix * Lint js fix * Feed back changes * Review changes * Update packages/block-library/src/rss/editor.scss Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Update packages/block-library/src/rss/style.scss Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Eslint fix & Format change --------- Co-authored-by: benazeer1909 <91200605+benazeerhassan1909@users.noreply.github.com> Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Unlinked contributors: benazeerhassan1909. Co-authored-by: benazeer-ben <benazeer@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: shail-mehta <shailu25@git.wordpress.org>
1 parent 4dadd50 commit d9fa3ac

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

docs/reference-guides/core-blocks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres
811811

812812
- **Name:** core/rss
813813
- **Category:** widgets
814-
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), ~~html~~
814+
- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), ~~html~~
815815
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow
816816

817817
## Search

packages/block-library/src/rss/block.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@
4747
"interactivity": {
4848
"clientNavigation": true
4949
},
50+
"__experimentalBorder": {
51+
"radius": true,
52+
"color": true,
53+
"width": true,
54+
"style": true
55+
},
56+
"spacing": {
57+
"margin": true,
58+
"padding": true,
59+
"__experimentalDefaultControls": {
60+
"padding": false,
61+
"margin": false
62+
}
63+
},
5064
"color": {
5165
"background": true,
5266
"text": true,

packages/block-library/src/rss/edit.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ export default function RSSEdit( { attributes, setAttributes } ) {
119119
},
120120
];
121121

122+
/*
123+
* This function merges the existing attributes with additional style properties.
124+
* The `border` and `spacing` properties are set to `undefined` to ensure that
125+
* these styles are reset and not applied on the server side.
126+
*/
127+
const serverSideAttributes = {
128+
...attributes,
129+
style: {
130+
...attributes?.style,
131+
border: undefined,
132+
spacing: undefined,
133+
},
134+
};
122135
return (
123136
<>
124137
<BlockControls>
@@ -190,7 +203,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
190203
<Disabled>
191204
<ServerSideRender
192205
block="core/rss"
193-
attributes={ attributes }
206+
attributes={ serverSideAttributes }
194207
/>
195208
</Disabled>
196209
</div>

packages/block-library/src/rss/editor.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@
55
.wp-block-rss__placeholder-form .wp-block-rss__placeholder-input {
66
flex: 1 1 auto;
77
}
8+
// Reset all styles when skipping block supports while server-side rendering.
9+
// This prevents issues such as duplicate padding, borders etc.
10+
.wp-block-rss .wp-block-rss {
11+
all: inherit;
12+
margin: 0;
13+
padding: 0;
14+
}

packages/block-library/src/rss/style.scss

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
ul.wp-block-rss { // The ul is needed for specificity to override the reset styles in the editor.
2-
list-style: none;
3-
padding: 0;
4-
5-
// 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
6-
&.wp-block-rss {
7-
box-sizing: border-box;
8-
}
92

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

2416
li {
2517
margin: 0 1em 1em 0;
@@ -41,3 +33,9 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
4133
display: block;
4234
font-size: 0.8125em;
4335
}
36+
.wp-block-rss {
37+
// This block has customizable padding, border-box makes that more predictable.
38+
box-sizing: border-box;
39+
list-style: none;
40+
padding: 0;
41+
}

0 commit comments

Comments
 (0)