Skip to content

Commit

Permalink
Block Library: Columns: Fix equal column growth for unassigned-width …
Browse files Browse the repository at this point in the history
…columns
  • Loading branch information
aduth committed Feb 11, 2020
1 parent 7dda20a commit c1e2c3d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions packages/block-library/src/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,21 @@
// Responsiveness: Show at most one columns on mobile.
flex-basis: 100%;

// Beyond mobile, allow columns.
@include break-small() {
// 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-grow: 1;
flex-basis: auto;
flex-basis: 0;

// 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;
}
Expand Down
17 changes: 12 additions & 5 deletions packages/block-library/src/columns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@
word-break: break-word; // For back-compat.
overflow-wrap: break-word; // New standard.

// Beyond mobile, allow 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.
// 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 inherited `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;

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

0 comments on commit c1e2c3d

Please sign in to comment.