-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Terms List block: Add Categories-specific variation #65434
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { category as icon } from '@wordpress/icons'; | ||
|
||
const variations = [ | ||
{ | ||
name: 'terms', | ||
title: __( 'Terms List' ), | ||
icon, | ||
attributes: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! TIL 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the name for the property should be phrased differently, but the intent is to have a simple way to change the default version of the block in the UI through the variation, instead of using WP filters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// We need to set an attribute here that will be set when inserting the block. | ||
// We cannot leave this empty, as that would be interpreted as the default value, | ||
// which is `category` -- for which we're defining a distinct variation below, | ||
// for backwards compatibility reasons. | ||
// The logical fallback is thus the only other built-in and public taxonomy: Tags. | ||
taxonomy: 'post_tag', | ||
}, | ||
isActive: ( blockAttributes ) => | ||
// This variation is used for any taxonomy other than `category`. | ||
blockAttributes.taxonomy !== 'category', | ||
}, | ||
{ | ||
name: 'categories', | ||
title: __( 'Categories List' ), | ||
description: __( 'Display a list of all categories.' ), | ||
icon, | ||
attributes: { | ||
taxonomy: 'category', | ||
}, | ||
isActive: [ 'taxonomy' ], | ||
}, | ||
]; | ||
|
||
export default variations; |
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.
What is the risk if the `category is listed here? When switching a choice a different block variation would get selected but otherwise it should remain seamless for the user.
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.
Yeah, @fabiankaegy also suggested that over here. I'll quote my reply here for convenience:
I'm open to revisiting this. It's something I'd like to get feedback from designers on, though.
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.
I've tentatively applied this change in 9f70db6. We can revert, depending on the feedback we get.
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.
I've updated the screencast in the PR description accordingly.
Here's the previous one (with Categories removed from the dropdown)