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

Try: Improve columns block #11620

Merged
merged 2 commits into from
Nov 9, 2018
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
3 changes: 3 additions & 0 deletions assets/stylesheets/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ $z-layers: (
// Active pill button
".components-button.is-button {:focus or .is-primary}": 1,

// Reusable blocks UI, needs to be above sibling inserter.
".editor-block-list__layout .reusable-block-edit-panel": 7,

// The draggable element should show up above the entire UI
".components-draggable__clone": 1000000000,

Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/block/edit-panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
font-size: $default-font-size;
position: relative;
top: -$block-padding;
margin: 0 (-$block-padding) (-$block-padding) (-$block-padding);
margin: 0 (-$block-padding);
padding: $grid-size $block-padding;
position: relative;
z-index: z-index(".editor-block-list__layout .reusable-block-edit-panel");

// Show a smaller padding when nested.
.editor-block-list__layout & {
Expand Down
28 changes: 17 additions & 11 deletions packages/block-library/src/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
}
}

// This block has flex container children. Flex container margins do not collapse: https://www.w3.org/TR/css-flexbox-1/#flex-containers.
// Therefore, let's at least not add any additional margins here.
// The goal is for the editor to look more like the front-end.
.editor-block-list__layout .editor-block-list__block[data-type="core/columns"] > .editor-block-list__block-edit,
.editor-block-list__layout .editor-block-list__block[data-type="core/column"] > .editor-block-list__block-edit {
margin-top: 0;
margin-bottom: 0;
}

.wp-block-columns {
display: block;

Expand All @@ -55,8 +46,13 @@
// The Column block is a child of the Columns block and is mostly a passthrough container.
// Therefore it shouldn't add additional paddings and margins, so we reset these, and compensate for margins.
// @todo In the future, if a passthrough feature lands, it would be good to apply these rules to such an element in a more generic way.
margin-top: -$block-padding;
margin-bottom: -$block-padding;
margin-top: -$block-padding - $block-padding;
margin-bottom: -$block-padding - $block-padding;

> .editor-block-list__block-edit {
margin-top: 0;
margin-bottom: 0;
}

// On mobile, only a single column is shown, so match adjacent block paddings.
padding-left: 0;
Expand Down Expand Up @@ -130,3 +126,13 @@
}
}
}

// In absence of making the individual columns resizable, we prevent them from being clickable.
// This makes them less fiddly. This will be revisited as the interface is refined.
.wp-block-columns [data-type="core/column"] {
pointer-events: none;
}

:not(.components-disabled) > .wp-block-columns > .editor-inner-blocks > .editor-block-list__layout > [data-type="core/column"] > .editor-block-list__block-edit > .editor-inner-blocks {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a selector :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Have to be careful with the pointer events! I look forward to when we have a more official passthrough method.

pointer-events: all;
}
5 changes: 5 additions & 0 deletions packages/components/src/disabled/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
bottom: 0;
left: 0;
}

// Also make nested blocks unselectable.
* {
pointer-events: none;
}
}
7 changes: 1 addition & 6 deletions packages/editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,9 @@
margin-right: -$block-padding;
}

// Adjust the spacing of the appender to match text blocks.
.editor-default-block-appender > .editor-default-block-appender__content {
margin-top: $block-padding * 2 + $block-spacing;
}

// Space every block, and the default appender, using margins.
// This allows margins to collapse, which gives a better representation of how it looks on the frontend.
> .editor-default-block-appender__content,
.editor-default-block-appender > .editor-default-block-appender__content,
> .editor-block-list__block > .editor-block-list__block-edit,
> .editor-block-list__layout > .editor-block-list__block > .editor-block-list__block-edit {
margin-top: $block-padding * 2 + $block-spacing;
Expand Down