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

Fix columns block style on the frontend #7128

Merged
merged 1 commit into from
Jun 4, 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
15 changes: 15 additions & 0 deletions core-blocks/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@
margin-right: $block-side-ui-padding;
}
}

.wp-block-columns {
display: block;

.editor-inner-blocks {
display: grid;
grid-auto-flow: dense;
}

@for $i from 2 through 6 {
&.has-#{ $i }-columns .editor-inner-blocks {
grid-auto-columns: #{ 100% / $i };
}
}
}
9 changes: 3 additions & 6 deletions core-blocks/columns/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.wp-block-columns {

.editor-inner-blocks {
display: grid;
grid-auto-flow: dense;
}
display: grid;
grid-auto-flow: dense;

@for $i from 2 through 6 {
&.has-#{ $i }-columns .editor-inner-blocks {
&.has-#{ $i }-columns {
Copy link
Member

Choose a reason for hiding this comment

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

This is a base stylesheet, meaning that in the editor, we have styles for both .has-x-columns and .has-x-columns .editor-inner-blocks to apply the grid-auto-columns. Will there be issues from this?

Copy link
Member Author

@jorgefilipecosta jorgefilipecosta Jun 4, 2018

Choose a reason for hiding this comment

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

I don't think we have a problem because the styles in the editor will be applied to .wp-block-columns and we set it to display block so my expectation is that grid styles are simply ignored.

Copy link
Member

@aduth aduth Jun 4, 2018

Choose a reason for hiding this comment

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

Makes me wonder a bit about nested nested blocks, Columns > Columns, where .editor-inner-blocks descendent could match multiple nodes. Probably outside the scope of this.

Copy link
Member Author

@jorgefilipecosta jorgefilipecosta Jun 4, 2018

Choose a reason for hiding this comment

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

I tested a little bit and it looks like it works even in nested columns. I think because this style &.has-#{ $i }-columns { that is .wp-block-columns.has-2-columns does not uses the hierarchy it just selects elements with both classes .wp-block-columns and .has-2-columns. If the styles of the editor were applied on the front we would have a problem but in this case, I think we are safe.

grid-auto-columns: #{ 100% / $i };
}
}
Expand Down