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

[MOOSE-52] Terms Block #81

Merged
merged 22 commits into from
Sep 28, 2023
Merged

[MOOSE-52] Terms Block #81

merged 22 commits into from
Sep 28, 2023

Conversation

GeoffDusome
Copy link
Contributor

@GeoffDusome GeoffDusome commented Aug 4, 2023

What does this do/fix?

  • Adds Terms block
  • The Terms block will attempt to replace the Categories and Tags blocks we've been using in the past couple projects. These other blocks have been less than ideal for implementation, so I decided it was time for a new approach.
  • With my learnings about core/custom blocks recently I was able to implement attributes, and settings in order to be able to change server-side rendered markup on the FE.
  • This block has the same implementation as the other 3 blocks we've been working on, with the addition of attributes.
  • The block itself has some simple settings (http://p.tri.be/i/6Qvnk5) that allow it to grab the necessary information it needs (through attributes) in order to render the proper markup for displaying the terms.
  • A few notes on the attributes:
    • The taxonomyToUse attribute is currently pulling all available taxonomies. I think I could maybe edit this to pull only taxonomies that are attached to the current post type?
    • The onlyPrimaryTerm attribute determines if we should grab the full list of terms or only the "primary" term. If Yoast is enabled on the site and we're using the "Category" taxonomy, the code will look for the primary category as designated by Yoast, with a fallback to the first category in the list. If Yoast is not enabled, we just grab the first term in the list returned.
    • The hasLinks attribute determines if the terms should display as links or plain text
    • The termStyle attribute determines if the terms should display as basic text or as pill shaped "tags"
  • I won't go over the styles here, they are pretty straightforward.
  • Please see attached demo video to see it in action, I'd like to get some feedback on this block. I'm not expecting this to be a quick PR, just wanted to get an MVP out there.

For reference, the code that pulls the taxonomies looks like this:

const taxonomies = useSelect( ( select ) =>
	select( 'core' ).getTaxonomies( { per_page: -1 } )
);

There's not a whole lot of documentation on useSelect, so I'm just kinda going by what I'm finding online. I would assume getTaxonomies has more attributes than per_page but I'll have to look for them.

This PR closes #66

QA

Link to issue: https://moderntribe.atlassian.net/browse/MOOSE-52

Screenshots/video:

@GeoffDusome GeoffDusome changed the title [FEATURE] Terms Block [MOOSE-52] Terms Block Aug 8, 2023
Copy link
Contributor

@ChrisMKindred ChrisMKindred left a comment

Choose a reason for hiding this comment

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

I have a couple of quick comments but everything looks pretty good.

wp-content/themes/core/blocks/tribe/terms/index.js Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/render.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@dpellenwood dpellenwood 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 an excellent take on the block. A few changes & suggestions, if you'd be so kind.

wp-content/themes/core/blocks/tribe/terms/edit.js Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/render.php Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/render.php Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/style.pcss Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/style.pcss Outdated Show resolved Hide resolved
@GeoffDusome
Copy link
Contributor Author

GeoffDusome commented Sep 14, 2023

Closing in favor of moving the Terms block to Moose Resources: moderntribe/moose-resources#3

Open discussion items here have been moved to TODO list in the new PR.

New Moose PR has been opened to fix a few issues that cropped up: #105

@GeoffDusome GeoffDusome deleted the feature/terms-block branch September 14, 2023 18:51
@GeoffDusome GeoffDusome restored the feature/terms-block branch September 14, 2023 18:56
@GeoffDusome
Copy link
Contributor Author

Reopening to continue iterating within Moose.

@GeoffDusome GeoffDusome reopened this Sep 14, 2023
Copy link
Contributor

@ChrisMKindred ChrisMKindred left a comment

Choose a reason for hiding this comment

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

@GeoffDusome, I will put together a quick PR to look into the PHP in the template.

wp-content/themes/core/blocks/tribe/terms/render.php Outdated Show resolved Hide resolved
Copy link
Contributor

@ChrisMKindred ChrisMKindred left a comment

Choose a reason for hiding this comment

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

We should be good from the PHP side now.

Copy link
Collaborator

@dpellenwood dpellenwood left a comment

Choose a reason for hiding this comment

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

I followed up on a couple existing conversations. We're really close here, Geoff. Thanks for tackling this!

wp-content/themes/core/blocks/tribe/terms/index.js Outdated Show resolved Hide resolved
wp-content/themes/core/blocks/tribe/terms/style.pcss Outdated Show resolved Hide resolved
@GeoffDusome
Copy link
Contributor Author

@dpellenwood should be good for another look!

Copy link
Collaborator

@dpellenwood dpellenwood left a comment

Choose a reason for hiding this comment

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

:chefskiss: This is excellent. merge away!

@GeoffDusome GeoffDusome merged commit 4d4999c into main Sep 28, 2023
10 checks passed
@GeoffDusome GeoffDusome deleted the feature/terms-block branch September 28, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants