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 a reaction block #1070

Merged
merged 56 commits into from
Dec 17, 2024
Merged

Add a reaction block #1070

merged 56 commits into from
Dec 17, 2024

Conversation

mattwiebe
Copy link
Contributor

@mattwiebe mattwiebe commented Dec 10, 2024

This will add a block to display Likes and Reposts in a single block.

Fixes #1057

Proposed changes:

  • Adds a Reactions block
  • It automatically gets hooked to be placed after the post content block
  • Enable reactions by default!

A (not quite up to date) video of it in action:

Screen.Recording.2024-12-11.at.22.24.36.mov

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

With this PR active, view a post on the frontend that already has a number of Likes and Reposts. The reactions block should be inserted directly after the post content:

Screenshot 2024-12-12 at 16 04 57

The block is automatically added via a block hook. It should be opted in, and can be disabled in the Single Post template in the Site Editor: (also note the dummy content in the Editor)

Screenshot 2024-12-12 at 16 06 31

Every row of icons, if there are too many to fit the width, should limit the number of avatars shown so that none are cut off.

Screenshot 2024-12-12 at 16 15 35

Avatars and names are shown if you click on the n reposts (or likes) label to the right of the avatars:

Screenshot 2024-12-12 at 16 17 04

On a post with no likes or reposts, nothing will be shown, not even the title.

The title ("Fediverse reactions" by default) is editable.

@github-actions github-actions bot added [Focus] Editor Changes to the ActivityPub experience in the block editor [Status] In Progress labels Dec 10, 2024
@pfefferle
Copy link
Member

Awesome!! 🎉

Maybe one first little feedback: Maybe we should have a line break after the label (and use it more as a headline) so that the icon lists are all aligned?

@mattwiebe mattwiebe force-pushed the add/like-and-boost-blocks branch from a7f99a3 to 95af3b1 Compare December 11, 2024 13:54
@mattwiebe
Copy link
Contributor Author

Maybe one first little feedback: Maybe we should have a line break after the label (and use it more as a headline) so that the icon lists are all aligned?

They should definitely be aligned! I'd prefer to keep them on a single line, maybe responsively moving to separate lines on smaller screens. Or I guess we could give some layout options, but that could be a future iteration. 🤔

@jeherve
Copy link
Member

jeherve commented Dec 12, 2024

Nice!

I believe this would fix #235 as well?

@pfefferle
Copy link
Member

@mattwiebe what about icons at the beginning of each line https://wordpress.github.io/gutenberg/?path=/docs/icons-icon--docs ???

  • reusableBlock for reposts
  • and the heart you are already using for like

We could use the icon attribute for that. Either store the @wordpress/icons key or an SVG?

@mattwiebe mattwiebe force-pushed the add/like-and-boost-blocks branch from 6c6f6f2 to 85b7e44 Compare December 12, 2024 18:38
@mattwiebe mattwiebe force-pushed the add/like-and-boost-blocks branch from 85b7e44 to 6202b41 Compare December 12, 2024 18:38
@mattwiebe mattwiebe marked this pull request as ready for review December 12, 2024 21:14
@pfefferle
Copy link
Member

Is it possible to use the comment type registry instead of hardcoding to the two types? So that it is easier to add new types, either in the plugin or an external one?

@pfefferle
Copy link
Member

Does not have to be in the first iteration!

@obenland
Copy link
Member

obenland commented Dec 16, 2024

Remaining Tasks

  • Limit Reaction Setting to non-block themes.
  • Per-post setting should be for both, global setting only for non-block themes.
  • Add a link to Site Editor for block themes in Settings.
  • Tone down hover animation.

@obenland obenland linked an issue Dec 16, 2024 that may be closed by this pull request
@mattwiebe
Copy link
Contributor Author

@Automattic/fediverse Ready to test some more, I think everything should be addressed!

Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are failing

public static function is_reactions_enabled( $post_id = 0 ) {
// Check global setting first - if disabled globally, return false.
if ( ! self::is_reactions_globally_enabled() ) {
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still prevent, that the block will load outside of the post.

@obenland
Copy link
Member

It looks like aab821d broke the unit test that checked whether reactions are enabled for an individual post while they are deactivated globally.
Is that something we don't want to support?

@pfefferle
Copy link
Member

pfefferle commented Dec 17, 2024

If we want to have a setting that deactivates the feature globally then we need to have a different setting to add/remove the reactions to the post, these two should not be implicit!

@mattwiebe
Copy link
Contributor Author

We've removed support for auto-appending the Reactions block to classic themes. Those users can either insert the block manually, or edit their PHP templates to output the block like:

do_blocks( '<!-- wp:activitypub/reactions {"title":"Fediverse Reactions"} /-->' );

We may revisit this, but it was getting too complex and blocking shipping

@obenland obenland requested a review from pfefferle December 17, 2024 19:02
@mattwiebe mattwiebe self-assigned this Dec 17, 2024
@mattwiebe mattwiebe merged commit 77ae436 into trunk Dec 17, 2024
24 checks passed
@mattwiebe mattwiebe deleted the add/like-and-boost-blocks branch December 17, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post settings [Block] Reactions [Feature] Reactions [Focus] Editor Changes to the ActivityPub experience in the block editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template blocks for Likes and Reposts: display them on the frontend Show likes from fediverse
4 participants