-
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
Fixed background grey of the Shortcode block placeholder screen #14719
Conversation
It would also make sense to add support for dark themes to be even more consistent with the placeholder component: .is-dark-theme & {
background: $light-opacity-light-200;
} |
a595461
to
1c67d6c
Compare
@gziolo Can you review this for me? I had made some changes, then noticed some conflicts with changes you had made earlier. I rebased and force pushed this bad boy, and want to make sure I did it all right. If we're good, can I get your approval? |
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.
Can you review this for me? I had made some changes, then noticed some conflicts with changes you had made earlier. I rebased and force pushed this bad boy, and want to make sure I did it all right. If we're good, can I get your approval?
All good 👍 There are more changes coming to all core blocks. We need those refactorings to validate all the assumptions made in RFC (#13693).
@@ -10,8 +10,8 @@ const ShortcodeEdit = ( { attributes, setAttributes, instanceId } ) => { | |||
const inputId = `blocks-shortcode-input-${ instanceId }`; | |||
|
|||
return ( | |||
<div className="wp-block-shortcode"> | |||
<label htmlFor={ inputId }> | |||
<div className="wp-block-shortcode components-placeholder"> |
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.
@jasmussen - can you advice how it could be coded differently? In general, we assume that class names are local to the component which define them. In this case, it's wp.components.Placeholder
which uses components-placeholder
. While it seems to be very convenient to use an existing class, it doesn't scale well as we learned down the road.
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 this is an interesting question.
I would say there are two ways to go.
- Keep the shortcode block as its own thing. But then we remove the placeholder classes and duplicate the CSS rules necessary for them to look the same.
- Rewrite/potentially redesign the shortcode to actually use the placeholder component.
2 is a bigger task, and I have no strong opinions on which one is the right way to go. What do you think?
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.
Well, I'm seeing that components-placeholder*
classes are used in several places for other core blocks as well :(
@youknowriad or @aduth - what would be the best way moving forward to tackle it? We definitely need to clean it up.
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 a placeholder component? What does it mean? Does it make sense as a separate component?
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.
One of the main issues with duplicating the class like this is maintainability. If someone wants to refactor the placeholder styles, they'd generally expect only the <Placeholder>
component to be affected, but in this case other components can be affected in an unexpected way.
What is a placeholder component?
In the context of a block, it seems like it's the UI that's displayed when the proper wysiwyg part of a block can't be shown. Outside of the context of a block, I'm not really sure. The word 'placeholder' generally implies a stopgap that will eventually be replaced, but I'm not sure how that applies to other user interfaces that @wordpress/components
might be used in.
A couple of other options might be:
- Extend
Placeholder
to support other layouts, like the horizontal layout shown here - Extract the container of the placeholder into a separate component (
PlaceholderCard
?) and use that.
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.
Looks good.
We should open a follow-up issue where we cover the part about reusing class names from existing components.
…Press#14719) * Changed the background grey of the shortcode block to match all the other placeholder setup screens on other blocks. Fixes WordPress#14718 * Restyled shortcode block to match placeholder block styling. * Rebased and force pushed to catch up with changes made to this file since @gziolo made some changes.
I wonder if this is related to these changes here #15032 |
Sorry I missed this until now. I agree this shouldn't be done this way, and was part of the reason for #14556 in more strongly asserting that the class name should never be used outside its own component.
I would much rather have seen the styles duplicated, or to make some separate component which encompasses what it is we're trying to do with this padded gray container. But to me, the "padded gray container" is what the Placeholder component is trying to be. Whether it supports the desired use-case, it either (a) should be made to or (b) the desired use-case should be changed to align to what the Placeholder is meant to be used for. Is it not enough to do something like: <Placeholder
icon="shortcode"
label={ __( 'Shortcode' ) }
>
<PlainText /* ... */ />
</Placeholder> |
Description
Changed the background grey of the shortcode block to match all the other placeholder setup screens on other blocks. Fixes #14718
How has this been tested?
Tested locally.
Before
After
Types of changes
Changed the variable used for the background grey.
Checklist: