-
Notifications
You must be signed in to change notification settings - Fork 219
Attribute Filter block: Enable global style #5557
Conversation
…products-block into add/4965-product-title
Featured Category block: Add support for global style
…products-block into add/4965-featured-category
Attribute Filter block: enable global style #4965
Do you think it makes sense to add some comments about this hacky approach in the CSS? (maybe where I use |
Size Change: +1.45 kB (0%) Total Size: 812 kB
ℹ️ View Unchanged
|
…products-block into add/4965-attribute-filter
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.
Yes please do leave some comments about the hacky solution. Every time I see an !important
it'd be good to have the context on why it was added. 🙏
@@ -23,6 +23,7 @@ import './style.scss'; | |||
* @param {Object} props Incoming props for the component. | |||
* @param {string} props.attributeLabel Label for the attributes. | |||
* @param {string} props.className CSS class used. | |||
* @param {Object} props.style CSS style object used. |
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 about using CSSProperties
?
onChange: setOverlayColor, | ||
label: __( | ||
'Overlay Color', | ||
{ !! url && ( |
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 understand you want to cast this as a boolean, but I have to say I've always found the !!
confusing and I'm not sure there is any clearer advantage to just having url &&
. What are your thoughts?
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 just moved this code, I didn't edit it. I agree with you that it is not very clear this cast! I will change it!
*/ | ||
import Block from './block'; | ||
|
||
export const Edit = ( props: unknown ): JSX.Element => { |
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 haven't worked with blocks much, so forgive me for asking: isn't there a way to know this type at all?
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 haven't worked with blocks much, so forgive me for asking: isn't there a way to know this type at all?
Yes, we can try to type it, but without the right typeguards, there is the risk that the code will be less safe than now.
|
||
/** | ||
* Block content is rendered in PHP, not via save function. | ||
*/ | ||
save() { | ||
save: () => { |
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.
Why was this changed? Was this automatically done by Prettier? I find 13 instances of save() {
but only this one of save: () =>
, so perhaps the former is more in line with the repo conventions?
…products-block into add/4965-attribute-filter
…products-block into add/4965-attribute-filter
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.
Thanks for adding the comments!
This PR is blocked by #5542
This PR adds support for global style for the
Attribute Filter block
.Now, the user can edit the style for:
Note
Unfortunately at the current stage, global style API doesn't support the customization of the inner element instead of block wrapper, so this PR contains a hacky CSS for accomplishing the goal
WordPress/gutenberg#33255
WordPress/gutenberg#32417
#4965
Screenshots
Mode: Display List
without global style
with global style
Mode: Dropdown List
without global style
with global style
Testing
Manual Testing
Check out this branch:
WordPress 5.9
.Twenty Twenty-Two
theme.Attribute Filter block
to a post.Reset
button from the different sections.Styles
icon on the right-top corner.Attribute Filter block
is shown under theBlocks
section. Personalize again the block.Changelog