Skip to content
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

Merged
merged 7 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/block-editor/src/components/block-list/block-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,19 @@ const BlockComponent = forwardRef(
}
);

const elements = [ 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul' ];
const elements = [
'p',
'div',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'ol',
'ul',
'figure',
];

const ExtendedBlockComponent = elements.reduce( ( acc, element ) => {
acc[ element ] = forwardRef( ( props, ref ) => {
Expand Down
52 changes: 30 additions & 22 deletions packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,27 @@
// Navigate mode & Focused wrapper.
// We're using a pseudo element to overflow placeholder borders
// and any border inside the block itself.
&:not([contenteditable]):focus::after {
position: absolute;
z-index: 1;
pointer-events: none;
content: "";
top: 0;
bottom: 0;
left: 0;
right: 0;
&:not([contenteditable]):focus {
outline: none;

// 2px outside.
box-shadow: 0 0 0 2px $blue-medium-focus;
border-radius: $radius-block-ui;
&::after {
position: absolute;
z-index: 1;
pointer-events: none;
content: "";
top: 0;
bottom: 0;
left: 0;
right: 0;

// Show a light color for dark themes.
.is-dark-theme & {
box-shadow: 0 0 0 2px $blue-medium-focus-dark;
// 2px outside.
box-shadow: 0 0 0 2px $blue-medium-focus;
border-radius: $radius-block-ui;

// Show a light color for dark themes.
.is-dark-theme & {
box-shadow: 0 0 0 2px $blue-medium-focus-dark;
}
}
}

Expand Down Expand Up @@ -243,6 +247,12 @@
cursor: default;
}

.alignleft,
.alignright {
// Without z-index, won't be clickable as "above" adjacent content.
z-index: z-index(".block-editor-block-list__block {core/image aligned left or right}");
}

// Alignments.
&[data-align="left"],
&[data-align="right"] {
Expand Down Expand Up @@ -278,12 +288,15 @@

// Wide and full-wide.
&[data-align="full"],
&[data-align="wide"] {
&[data-align="wide"],
&.alignfull,
&.alignwide {
Copy link
Member

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.

clear: both;
}

// Full-wide.
&[data-align="full"] {
&[data-align="full"],
&.alignfull {
margin-left: -$block-padding;
margin-right: -$block-padding;

Expand Down Expand Up @@ -388,11 +401,6 @@
left: $block-padding;
right: $block-padding;
}

&[data-align="full"] > .block-editor-block-list__insertion-point {
left: 0;
right: 0;
Copy link
Member

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.

}
}

.block-editor-block-list__block .block-editor-block-list__block-html-textarea {
Expand Down
Loading