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

Post terms: Add prefix & suffix #40559

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

dsas
Copy link
Contributor

@dsas dsas commented Apr 22, 2022

What?

Allowing an optional prefix and suffix to be added to the Post Categories and Post Tags

Why?

A common pattern in themes is to display categories and tags prepended with a text. This is the case for all default themes, including TwentyTwentyOne.

image

Fixes #29909

How?

  • Add prefix and suffix attributes to the post-terms block.
  • Allow these attributes to be set inside the block editor via a RichText component

Testing Instructions

  1. Open a Post or page
  2. Insert a Post Tags or Post Categories block
  3. Click the placeholder and start typing
  4. Press Publish
  5. Look at the site on the frontend

Screenshots or screencast

image

Screen.Capture.on.2022-04-22.at.21-22-18.mp4

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 22, 2022
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @dsas! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@dsas dsas force-pushed the add/presuffix-for-post-terms branch from 498beb4 to d7a8080 Compare April 22, 2022 20:15
Add prefix and suffix attributes to the post-terms block. These
attributes are displayed inside the block div, immediately before and
after the list. The attributes can be edited as rich text inside the
block editor.

Fixes #29909
@dsas dsas force-pushed the add/presuffix-for-post-terms branch from d7a8080 to b031694 Compare April 22, 2022 20:25
@dsas dsas marked this pull request as ready for review April 23, 2022 08:49
@amustaque97 amustaque97 added [Type] Enhancement A suggestion for improvement. [Block] Categories Affects the Categories Block [Block] Post Tags Affects the Post Tags Block labels Apr 24, 2022
@amustaque97 amustaque97 self-requested a review April 24, 2022 18:07
@carolinan
Copy link
Contributor

carolinan commented Apr 25, 2022

Editing the placeholders works well in my test, the toolbar options also work and the text displays as expected on the front.

Are these terms, prefix and suffix, common enough to be understood by most users?

In my opinion, to allow theme developers to style the prefix and suffix, the markup in the editor and front needs to match and the class names wp-block-post-terms__suffix and wp-block-post-terms__prefix should be used both in the editor and the front.
I think that extensibility will be important, even though it means adding two more spans.

@carolinan carolinan added the [Block] Post Terms Affects the Post Terms Block label Apr 25, 2022
If the prefix or suffix attributes are provided, wrap them in spans with
a classname.

See #40559
@dsas
Copy link
Contributor Author

dsas commented Apr 25, 2022

@carolinan thanks for the review, I've made the span change as suggested.

I think 'prefix' and 'suffix' are common enough, but as a native English speaking developer, perhaps I'm not the best person to answer! I don't think there is a simple alternative to 'prefix' and 'suffix' that's as recognisable. Perhaps 'preface' rather than prefix, but I'm not sure that's much clearer really. I'll continue to think about it, but if anyone has any suggestions, they're very welcome.

@amustaque97 amustaque97 merged commit 62767b0 into WordPress:trunk Apr 29, 2022
amustaque97 pushed a commit that referenced this pull request Apr 29, 2022
If the prefix or suffix attributes are provided, wrap them in spans with
a classname.

See #40559
@Mamaduka
Copy link
Member

Mamaduka commented May 1, 2022

Hi, @amustaque97

What method are you using to merge merging the PRs? Commits from this branch merged into trunk without squashing them into one.

It's not a big deal, I just wanted to check if this was an issue on the GitHub side.

@amustaque97
Copy link
Member

Hi, @amustaque97

What method are you using to merge merging the PRs? Commits from this branch merged into trunk without squashing them into one.

It's not a big deal, I just wanted to check if this was an issue on the GitHub side.

Hi @Mamaduka 👋 , yeah I choose the other option without squashing them into one. I have noticed this behaviour for others, I can see it working correctly but in my case it somehow makes a single commit while merge.

Next time, I will record my screen and then probably we can discuss.

@Mamaduka
Copy link
Member

Mamaduka commented May 1, 2022

@amustaque97, it's supposed to make a single commit on merge. So I would recommend always using the "Squash and merge" option.

CleanShot 2022-05-01 at 18 16 55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Categories Affects the Categories Block [Block] Post Tags Affects the Post Tags Block [Block] Post Terms Affects the Post Terms Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Category and tag blocks: Add option to prepend text
4 participants