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

Block Library: Columns: Fix equal column growth for unassigned-width columns #20169

Merged
merged 4 commits into from
Feb 11, 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
28 changes: 20 additions & 8 deletions packages/block-library/src/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,32 @@
// Responsiveness: Show at most one columns on mobile.
flex-basis: 100%;

// Between mobile and large viewports, allow 2 columns.
@include break-small() {
flex-basis: calc(50% - (#{$grid-size-large}));
flex-grow: 0;
margin-left: 0;
margin-right: 0;
}

// At large viewports, show all columns horizontally.
@include break-medium() {
// Available space should be divided equally amongst columns
// without an assigned width. This is achieved by assigning a
// flex basis that is consistent (equal), would not cause the
// sum total of column widths to exceed 100%, and which would
// cede to a column with an assigned width. The `flex-grow`
// allows columns to maximally and equally occupy space
// remaining after subtracting the space occupied by columns
// with explicit widths (if any exist).
flex-basis: 0;
flex-grow: 1;
flex-basis: auto;

// Beyond mobile, allow columns. Columns with an explicitly-
// assigned width should maintain their `flex-basis` width and
// not grow. All other blocks should automatically inherit the
// `flex-grow` to occupy the available space.
// Columns with an explicitly-assigned width should maintain
// their `flex-basis` width and not grow.
&[data-has-explicit-width] {
flex-grow: 0;
}

margin-left: 0;
margin-right: 0;
}

// Add space between columns. Themes can customize this if they wish to work differently.
Expand Down
27 changes: 19 additions & 8 deletions packages/block-library/src/columns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@
word-break: break-word; // For back-compat.
overflow-wrap: break-word; // New standard.

// Between mobile and large viewports, allow 2 columns.
@include break-small() {

// Beyond mobile, allow columns. Columns with an explicitly-assigned
// width should maintain their `flex-basis` width and not grow. All
// other blocks should automatically inherit the `flex-grow` to occupy
// the available space.
&[style] {
flex-grow: 0;
}
flex-basis: calc(50% - #{$grid-size-large});
flex-grow: 0;

// Add space between the multiple columns. Themes can customize this if they wish to work differently.
// Only apply this beyond the mobile breakpoint, as there's only a single column on mobile.
Expand All @@ -47,7 +42,23 @@
}
}

// At large viewports, show all columns horizontally.
@include break-medium() {
// Available space should be divided equally amongst columns without an
// assigned width. This is achieved by assigning a flex basis that is
// consistent (equal), would not cause the sum total of column widths to
// exceed 100%, and which would cede to a column with an assigned width.
// The `flex-grow` allows columns to maximally and equally occupy space
// remaining after subtracting the space occupied by columns with
// explicit widths (if any exist).
flex-basis: 0;
flex-grow: 1;

// Columns with an explicitly-assigned width should maintain their
// `flex-basis` width and not grow.
&[style] {
flex-grow: 0;
}

// When columns are in a single row, add space before all except the first.
&:not(:first-child) {
Expand Down