-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 visible labels to BlockPatternPicker pattern selection buttons #19789
Conversation
6a89114
to
263cbe9
Compare
I would appreciate some help from designers. I have trouble doing it myself, mostly because of the fact that in the mock-ups the label is outside of the button. Ideally, both the icon and label should be wrapped with the Button component. It should also account for the longer labels. |
Size Change: +143 B (0%) Total Size: 864 kB
ℹ️ View Unchanged
|
Haiii @gziolo ! After playing around with it for a while, I think the better UI may be to provide shorter labels underneath the buttons (rather than the long labels): To ensure screen readers have context, I've added the long labels as I think making the label clickable would be ideal. However, I think it may be quite involved to restyle the wrapper button, and simulate a fake button within (to allow for both Button + Label to be clickable). Alternatively! I think perhaps these may be better if they were (Totally can be done later) Anywhoo! Let me know if my pushed fixes are okay! |
Looks good! It'll need a rebase with G2, but worked well regardless. Thanks for jumping into this @ItsJonQ. |
a1b6b69
to
40feb92
Compare
e1d8bd8
to
5ece310
Compare
@ItsJonQ thank you for all your help. I like the approach you took 👍 |
5ece310
to
66bc158
Compare
@@ -46,8 +47,14 @@ function BlockVariationPicker( { | |||
iconSize={ 48 } | |||
onClick={ () => onSelect( variation ) } | |||
className="block-editor-block-variation-picker__variation" | |||
label={ variation.title } | |||
label={ variation.description || variation.title } |
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.
description
is optional, so we should fallback to title
when not provided.
See:
gutenberg/packages/blocks/src/api/registration.js
Lines 67 to 87 in 7906556
/** | |
* An object describing a variation defined for the block type. | |
* | |
* @typedef {Object} WPBlockVariation | |
* | |
* @property {string} name The unique and machine-readable name. | |
* @property {string} title A human-readable variation title. | |
* @property {string} [description] A detailed variation description. | |
* @property {WPIcon} [icon] An icon helping to visualize the variation. | |
* @property {boolean} [isDefault] Indicates whether the current variation is | |
* the default one. Defaults to `false`. | |
* @property {Object} [attributes] Values which override block attributes. | |
* @property {Array[]} [innerBlocks] Initial configuration of nested blocks. | |
* @property {Object} [example] Example provides structured data for | |
* the block preview. You can set to | |
* `undefined` to disable the preview shown | |
* for the block type. | |
* @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation | |
* is applicable. When not provided, it | |
* assumes all available scopes. | |
*/ |
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 didn't test but code-wise, this looks good to me. I'll leave the final call for designers.
Let's process with this PR as is, we can always iterate later. |
Fixes #18737.
Description
I'm testing reusing the existing label of the pattern as the actual label rendered. In that case, we probably would have to improve copies for the columns block.
How has this been tested?
Screenshots
It needs more love on the CSS side of things:
Types of changes
Checklist: