-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Use a light wrapper for the image block #20576
Conversation
Size Change: +140 B (0%) Total Size: 865 kB
ℹ️ View Unchanged
|
ea57f4e
to
f96118d
Compare
I rebased this PR (force push). |
One small thing I notice is that the movers can't be accessed if the image is full width. That's probably because the data- attributes are no longer there and the position of the toolbar won't be adjusted. |
// Disable reason: Each block can be selected by clicking on it | ||
/* eslint-disable jsx-a11y/click-events-have-key-events */ | ||
return ( | ||
<> | ||
{ controls } | ||
<figure className={ classes }> | ||
<ImageSize src={ url } dirtynessTrigger={ align }> |
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.
Would be cool if we could rewrite this as a hook. Something to explore separately.
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.
Definitely, I actually did something like that a long time ago when I was playing with React hooks before their release #11161
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.
Awesome!
return ( | ||
<> | ||
{ getInspectorControls( | ||
imageWidth, | ||
imageHeight | ||
) } | ||
<div style={ { width, height } }> | ||
<ResizableBox |
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.
Same here, I have a feeling that this could be rewritten as a hook in the future. :)
3fdf2a6
to
3eb1b64
Compare
&[data-align="wide"] { | ||
&[data-align="wide"], | ||
&.alignfull, | ||
&.alignwide { |
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.
Hm, ideally this should be provided by the theme, no? I mean, ideally we shouldn't do any special handling for these classes.
@@ -554,10 +556,6 @@ | |||
margin-left: - $block-toolbar-height - $border-width; | |||
} | |||
|
|||
.block-editor-block-contextual-toolbar[data-align="full"], | |||
.block-editor-block-list__breadcrumb[data-align="full"] { | |||
margin-left: 0; |
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 is this removed? This ensures that the movers are visible for "full" alignment.
|
||
&[data-align="full"] > .block-editor-block-list__insertion-point { | ||
left: 0; | ||
right: 0; |
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.
Makes sense, this looks like a dead CSS rule to me.
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. I just think this CSS rule should be restored: https://github.com/WordPress/gutenberg/pull/20576/files#r387703250
Co-Authored-By: Zebulan Stanphill <zebulanstanphill@protonmail.com>
7910228
to
e7b0466
Compare
The biggest challenge here is alignments, and the approach I took is to try to match the frontend as closely as possible. In the frontend, for left, right and centered images, there's an extra "div" that is added as a wrapper.
The frontend also relies on
align*
classNames to style the alignments while the backend used to rely ondata-*
attributes. This consolidates on the classNames.So this PR is most likely to set a precedent to be followed in terms of alignment and something that might extend to all the other blocks.
Note
The focus style when the image is floated is kind of broken but it's not specific to this PR.
Testing