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

Add Typography support for RSS block #66991

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
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 (c,lientNavigation), typography (fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform), ~~html~~
- **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow

## Search
Expand Down
17 changes: 16 additions & 1 deletion packages/block-library/src/rss/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,22 @@
"align": true,
"html": false,
"interactivity": {
"clientNavigation": true
"c,lientNavigation": 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 @@ -57,6 +57,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
}

const blockProps = useBlockProps();
const textDecoration = attributes.style?.typography?.textDecoration;

const label = __( 'RSS URL' );

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 @@ -104,6 +104,10 @@ function render_block_core_rss( $attributes ) {
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 : '';

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

Expand Down
33 changes: 33 additions & 0 deletions packages/block-library/src/rss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,40 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl
width: 100%;
}
}
// 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 {
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;
}
@include break-small {
@for $i from 2 through 6 {
&.columns-#{ $i } li {
Expand Down
Loading