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 has-link-color class to comment blocks #47376

Closed
wants to merge 1 commit into from

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Jan 24, 2023

What?

Adds the has-link-color class to the front of these blocks when a link color is chosen:

  • comment author name
  • comment content
  • comment date
  • comment edit link
  • comment reply link
  • comments pagination
  • post comments form
  • post comments link

Partial for #47233

Why?

The class is present in the editor but not on the front.

How?

This PR manually adds the has-link-color class through get_block_wrapper_attributes.

Testing Instructions

You can test this in any block theme with support for link colors.

  1. First you need to enable comment pagination in the admin area under Settings > Discussion.
  2. Then you need a post or page that has comments. One of the comments need to have a link in the content. Open this content in the block editor.
  3. Add a comments block and add link colors to the inner blocks, or use this sample code:
<!-- wp:comments -->
<div class="wp-block-comments"><!-- wp:comments-title /-->

<!-- wp:comment-template -->
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"width":"40px"} -->
<div class="wp-block-column" style="flex-basis:40px"><!-- wp:avatar {"size":40,"style":{"border":{"radius":"20px"}}} /--></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:comment-author-name {"style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-cyan-blue"}}}},"fontSize":"small"} /-->

<!-- wp:group {"style":{"spacing":{"margin":{"top":"0px","bottom":"0px"}}},"layout":{"type":"flex"}} -->
<div class="wp-block-group" style="margin-top:0px;margin-bottom:0px"><!-- wp:comment-date {"style":{"elements":{"link":{"color":{"text":"var:preset|color|luminous-vivid-amber"}}}},"fontSize":"small"} /-->

<!-- wp:comment-edit-link {"style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-green-cyan"}}}},"fontSize":"small"} /--></div>
<!-- /wp:group -->

<!-- wp:comment-content {"style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-purple"}}}}} /-->

<!-- wp:comment-reply-link {"style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-purple"}}}},"fontSize":"small"} /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:comment-template -->

<!-- wp:comments-pagination {"style":{"elements":{"link":{"color":{"text":"#00bedc"}}}}} -->
<!-- wp:comments-pagination-previous /-->

<!-- wp:comments-pagination-numbers /-->

<!-- wp:comments-pagination-next /-->
<!-- /wp:comments-pagination -->

<!-- wp:post-comments-form {"style":{"elements":{"link":{"color":{"text":"var:preset|color|luminous-vivid-orange"}}}}} /--></div>
<!-- /wp:comments -->
  1. Save and view the front. Confirm that the link color is still working and that the class name has-link-color is now added to the wrappers.

The post comments link can only be added in the site editor.
Open the site editor and add a query loop block with a post comments link block inside the post template:
or use this sample code:

<!-- wp:query {"queryId":0,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"displayLayout":{"type":"flex","columns":3},"align":"wide","layout":{"type":"constrained"}} -->
<div class="wp-block-query alignwide"><!-- wp:post-template {"align":"wide"} -->
<!-- wp:post-title {"isLink":true} /-->

<!-- wp:post-comments-link {"style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-purple"}}}},"backgroundColor":"pale-pink"} /-->
<!-- /wp:post-template --></div>
<!-- /wp:query -->
Save and view the front. Confirm that the link color is still working and that the class name has-link-color is added.

Testing Instructions for Keyboard

Screenshots or screencast

@aristath aristath self-requested a review January 24, 2023 08:00
@carolinan carolinan closed this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant