Skip to content

Implements Heading Customization for the Reactions Block #1657

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

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

vk17-starlord
Copy link

This PR introduces enhancements to the Reactions block, enabling users to customize the heading using Gutenberg's InnerBlocks. The updates provide flexibility and control over the heading display.

Key Features:

  • Editable Heading Text: Users can modify the text of the heading.
  • Changeable Heading Levels: Users can select heading levels (H1-H6) to suit their requirements.
  • Removable Heading: Provides the option to remove the heading entirely if desired.
  • Standard Gutenberg Styles: Integrates with standard Gutenberg heading styles for consistent design.

This implementation is inspired by Jetpack's Related Posts block and aims to provide a similar level of customization.

Fixes:

Proposed Changes:

  • Adds support for heading customization in the Reactions block.
  • Uses Gutenberg's InnerBlocks for flexibility and ease of customization.
  • Ensures compatibility with existing Gutenberg styling standards.

Changelog Entry:

Significance:

  • Minor

Type:

  • Added: New customization options for the Reactions block heading.

Implements heading customization for the Reactions block using InnerBlocks, allowing users to:
- Edit heading text
- Change heading level (H1-H6)
- Remove heading if desired
- Apply standard Gutenberg heading styles

Similar to Jetpack's Related Posts block implementation.

Fixes Automattic#1096
@github-actions github-actions bot added [Block] Reactions [Feature] Reactions [Focus] Editor Changes to the ActivityPub experience in the block editor OSS Citizen labels May 6, 2025
</div>
);
export function Reactions({
postId = null,
Copy link
Member

Choose a reason for hiding this comment

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

please use tabs instead of spaces.

@pfefferle
Copy link
Member

pfefferle commented May 6, 2025

Thanks for your contribution @vk17-starlord

Can you please use npm run build to run the build? It seems that your build script changed a lot of the untouched files, simply because of a different configuration.

@vk17-starlord
Copy link
Author

ok @pfefferle will implement those changes

@vk17-starlord
Copy link
Author

@pfefferle - when i run 'NPM RUN BUILD' it still generated build files for all blocks and other unnecessary files which I haven't touched

@vk17-starlord
Copy link
Author

@pfefferle - Have converted spaces to tabs using vscode shortcut please check formatting and logic once

@pfefferle
Copy link
Member

@vk17-starlord I just ran the npm script on your branch and it removed all the map files and minified the JS/CSS as it should. Have you stopped the npm run dev task before?

@vk17-starlord
Copy link
Author

@vk17-starlord I just ran the npm script on your branch and it removed all the map files and minified the JS/CSS as it should. Have you stopped the npm run dev task before?

Yes I had stopped NPM RUN DEV before running NPM RUN BUILD . The NPM RUN BUILD script is building all blocks which haven't been changed

@vk17-starlord
Copy link
Author

vk17-starlord commented May 6, 2025

I created a new branch and copied the reaction block code. Initially, VSCode showed only 3 file changes in the top-left source control panel:

image

However, after running npm run build, the number of changed files increased to 52:

image

@obenland
Copy link
Member

obenland commented May 6, 2025

The NPM RUN BUILD script is building all blocks which haven't been changed

That should be fine, it should just update the hashes. Please go ahead and just run npm run build and push the results. Thanks!

@vk17-starlord
Copy link
Author

vk17-starlord commented May 6, 2025

@obenland - have already pushed the code you can check it out and review

Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

This is pretty close. There are quite a few whitespace changes currently, would you mind reverting these to stay closer to WP coding standards?

setLoading(false);
})
.catch(() => setLoading(false));
}, [postId, providedReactions, namespace]);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we need to add namespace here? It should be constant.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I left some comments below.

@@ -18,12 +18,7 @@
}
}
},
"attributes": {
Copy link
Member

Choose a reason for hiding this comment

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

This seems problematic as it will create validation errors for existing users of the block, whenever they try to visualize the block in the site editor.
I would recommend implementing deprecation to avoid that.

Comment on lines +341 to +343
key={key}
items={group.items}
label={group.label}
Copy link
Member

Choose a reason for hiding this comment

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

Your editor doesn't seem to pick up the configuration from this project's .editorconfig file. Could you keep the spaces inside brackets and parenthesis in the file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Reactions [Feature] Reactions [Focus] Editor Changes to the ActivityPub experience in the block editor OSS Citizen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reactions Block: add option to customize and / or remove the heading
4 participants