-
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
Fix the block preview padding in themes with custom backgrounds #17807
Conversation
My immediate thoughts about these changes are why we are not trying to deal with this through CSS properties, even adding a new element for this. It seems to add extra (and maybe unnecessary) complexity to the preview block. |
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.
The code does seem a bit convoluted with padding values injected there instead of separated out. But I understand the need. I messed around purely in CSS this weekend and couldn't get the preview to format correctly. Thanks for making this happen, @youknowriad. Looks good to merge.
Sure, The reason is that we scale the block relatively to the parent container and position it absolutely. That parent container is the container that applies the editor styles. Maybe we could add another intermediary div and rely on padding, but I wasn't sure about potential impacts of another div in the DOM tree there, so I endup computing the "padding" by altering the "left" and "top" values. |
Is Thanks for your answer, and please feel free to go ahead. Don't take this as a blocker. 🙇 |
yes :) |
We've had to deal with these kinds of issues previewing blocks. What we did was simply adding the I guess applying the padding to that element should work. |
yes, I can see how this can work in almost all themes but I'd personally prefer just one element to avoid potential theme conflicts. |
I think it will apply the same styles for each element again and again, where the CSS class is applied. Ok, I don't see how this could generate theme conflicts: <div className="editor-styles-wrapper">
<div className="editor-styles-wrapper">
<div className="editor-styles-wrapper custom-css">
Hi!
</div>
</div>
</div> .custom-css {
padding: 2px;
} |
@retrofox yes, thinking of things like multiple paddings, relative units... Granted that the changes are small especially if we reset things (like paddings, margins)... but there's still a chance of breakage because themes won't test against this when working on their editor styles. |
closes #17777
This PR removes the padding around the block preview from the help panel in the inserter and instead adds a
padding
prop to theBlockPreview
component in order to apply that padding inside the div affected by the editor styles.Testing instructions