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: Added Colour support #66419

Merged
merged 11 commits into from
Jan 7, 2025
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, color (background, gradients, link, text), interactivity (clientNavigation), typography (fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform), ~~html~~
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow

## Search
Expand Down
21 changes: 21 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,27 @@
"html": false,
"interactivity": {
"clientNavigation": true
},
"color": {
"background": true,
"text": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
"fontFamily": true,
"fontWeight": true,
"fontStyle": true,
"textTransform": true,
"letterSpacing": true,
"textDecoration": true,
"__experimentalSkipSerialization": [ "textDecoration" ],
"__experimentalDefaultControls": {
"fontSize": true,
"textDecoration": true
}
}
},
"editorStyle": "wp-block-rss-editor",
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/rss/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {

const blockProps = useBlockProps();

const textDecoration = attributes.style?.typography?.textDecoration;
const label = __( 'RSS URL' );

if ( isEditing ) {
Expand Down Expand Up @@ -190,6 +191,11 @@ export default function RSSEdit( { attributes, setAttributes } ) {
<ServerSideRender
block="core/rss"
attributes={ attributes }
className={
textDecoration
? 'has-text-decoration-' + textDecoration
: textDecoration
}
/>
</Disabled>
</div>
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/rss/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
if ( $attributes['displayExcerpt'] ) {
$classnames[] = 'has-excerpts';
}
// Manually add block support text decoration as CSS class.
$text_decoration = $attributes['style']['typography']['textDecoration'] ?? null;
$text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );
$classnames[] = $text_decoration ? $text_decoration_class : '';

Check warning on line 107 in packages/block-library/src/rss/index.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space
benazeer-ben marked this conversation as resolved.
Show resolved Hide resolved

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );

Expand Down
35 changes: 35 additions & 0 deletions packages/block-library/src/rss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
}
}

// The following rules provide class based application of user selected text
// decoration via block supports.
&.has-text-decoration-underline li.wp-block-rss__item a {
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved
text-decoration: underline;

&:focus,
&:active {
text-decoration: underline;
}
}

&.has-text-decoration-line-through li.wp-block-rss__item a {
text-decoration: line-through;

&:focus,
&:active {
text-decoration: line-through;
}
}

&.has-text-decoration-none li.wp-block-rss__item a {
text-decoration: none;

&:focus,
&:active {
text-decoration: none;
}
}

& :where(a),
& :where(a:focus),
& :where(a:active) {
text-decoration: none;
}
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved

@include break-small {
@for $i from 2 through 6 {
&.columns-#{ $i } li {
Expand Down
Loading