-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Terms Query block patterns #71528
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 Terms Query block patterns #71528
Conversation
This reverts commit a52096b.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Need to fix some tests, apparently |
| <!-- wp:buttons --> | ||
| <div class="wp-block-buttons"> | ||
| <!-- wp:button {"metadata":{"bindings":{"url":{"source":"core/term-data","args":{"key":"link"}}}},"className":"is-style-fill"} --> | ||
| <div class="wp-block-button is-style-fill"><a class="wp-block-button__link wp-element-button">View posts</a></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to translate text like this
| <div class="wp-block-group"> | ||
| <!-- wp:buttons {"layout":{"type":"flex","verticalAlignment":"center"}} --> | ||
| <div class="wp-block-buttons"> | ||
| <!-- wp:button {"metadata":{"bindings":{"url":{"source":"core/term-data","args":{"key":"link"}},"text":{"source":"core/term-data","args":{"key":"name"}}}},"className":"is-style-outline","style":{"spacing":{"padding":{"left":"0","right":"0","top":"0","bottom":"0"}},"border":{"color":"#00000000","radius":{"topLeft":"0px","topRight":"0px","bottomLeft":"0px","bottomRight":"0px"}}}} --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to avoid as much of this styling as we can. Colors won't work on all themes, we should allow the attern to inherit whatever the theme provides. I would also avoid using button variations like outline (the other pattern has an is-style-fill class too that we can probably remove too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, you're totally right. Since we don't have a compatible Term Title block there's no great way to provide a list of links unless they're all buttons. I could recreate the original pattern with paragraphs but there would be no links... Either way you're right that this isn't great and needs to be changed.
| <!-- wp:term-template {"style":{"spacing":{"blockGap":"var:preset|spacing|20"}},"layout":{"type":"flex","orientation":"horizontal","justifyContent":"left","flexWrap":"wrap"}} --> | ||
| <!-- wp:buttons --> | ||
| <div class="wp-block-buttons"> | ||
| <!-- wp:button {"metadata":{"bindings":{"url":{"source":"core/term-data","args":{"key":"link"}},"text":{"source":"core/term-data","args":{"key":"name"}}}},"className":"is-style-outline","style":{"spacing":{"padding":{"left":"var:preset|spacing|30","right":"var:preset|spacing|30","top":"var:preset|spacing|20","bottom":"var:preset|spacing|20"}}},"fontSize":"small"} --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here with the font size, I tested in a theme where this looks really strange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I was referencing some of the core query patterns and noticed the use of a few font size slugs but perhaps we should just use pixel values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmmh, I don't think pixel values are better. Maybe we need design input here, but we either remove this type of opinionated styling altogether and leave it to the theme or use the preset values for both texts (the term name and the count number) so they are related to one another. As a last resort we could go for em values if we really had to before going for pixels
| */ | ||
| import { Path, SVG } from '@wordpress/components'; | ||
|
|
||
| export const link = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these from? if we add them to the library we need to support them forever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're from me, meant to mimic the style of the icons used in the query block variation picker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, these need to be approved by designers before we land them then /cc @jameskoster @fcoveram
| <!-- /wp:button --> | ||
| </div> | ||
| <!-- /wp:buttons --> | ||
| <!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"core/term-data","args":{"key":"count"}}}},"fontSize":"medium"} --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol well as @MaggieCabrera pointed out we probably shouldn't be using font size slugs anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is the same issue that @MaggieCabrera mentioned here. I think it looks so strange because the wrong font size slug is being pulled through, but I'm not sure why. It's probably best to just remove the font size entirely and let the block use the default paragraph size.
|
@MaggieCabrera @mikachan Thanks for taking a look. I've pushed some updates that should address unnecessary styles in patterns, translating text, and some issues with |
| </SVG> | ||
| ); | ||
|
|
||
| export const imageTitleLink = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like imageTitleLink and imageTitleDescriptionLink are not used. Should we remove these until we need them?
| * @param {IHasNameAndId[]} entities The entities to extract of helper object. | ||
| * @return {QueryEntitiesInfo} The object with the entities information. | ||
| */ | ||
| export const getEntitiesInfo = ( entities ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this utils file copied from the Query Loop block? I can't see where many of these functions are used for the Terms Query and Term Template blocks.
These functions don't seem to be used: getEntitiesInfo, getValueFromObjectPath, mapToIHasNameAndId, useAllowedControls, isControlAllowed, useTaxonomies, useAllowedTaxonomies, isTaxonomyAllowed, useUnsupportedBlocks.
And then perhaps these could be extracted to a shared util file rather than dupicated: isControlAllowed, usePatterns, useUnsupportedBlocks
That should leave four new functions that are using the Terms Query blocks: useAllowedControls, getTransformedBlocksFromPattern, useBlockNameForPatterns, useScopedBlockVariations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikachan Well that's embarrassing. It was initially copied from the query block and then customized for the plugin I built, then copied over to this PR without cleaning it up. I'll remove the unused functions and look for ways to extract shared utils. I've been hesitant to touch the query block code, I'm assuming packages/block-library/utils/ is the right place for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries 😄 That sounds good.
Yes, I understand being hesitant to touch the Query block code, especially as this will currently be merged into a much larger PR, which makes it more difficult to isolate these changes. Maybe we could leave the shared utils for a follow-up PR, and just duplicate those functions for the time-being.
|
@mikachan No worries, will do. |


What?
Addresses differences between the Query block's pattern and variation picker and the Terms Query block.
This PR removes variations from the term-template block, adds variations more similar to the query block to the terms-query block, and includes an example pattern that can be chosen.
Why?
This was discussed in the main PR as one of the issues to address before merging the terms-query block.
How?
Testing Instructions
Testing Instructions for Keyboard
All UI patterns are copied from the query block and should work the same
Screenshots or screencast
Additional Screenshots:
I am open to any feedback, and in particular am looking for thoughts about default patterns and variations.