Skip to content

Commit

Permalink
Block Library: Flatten width calculation of gallery columns (#20690)
Browse files Browse the repository at this point in the history
* Block Library: Flatten width calculation of gallery columns

* Block Library: Gallery: Split gutter by number of columns
  • Loading branch information
aduth authored Mar 9, 2020
1 parent b11bc56 commit 1612deb
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
// On mobile and responsive viewports, we allow only 1 or 2 columns at the most.
& .blocks-gallery-image,
& .blocks-gallery-item {
width: calc((100% - #{ $grid-unit-20 }) / 2);
width: calc(50% - #{ $grid-unit-20 });

&:nth-of-type(even) {
margin-right: 0;
Expand All @@ -102,15 +102,8 @@
@for $i from 3 through 8 {
&.columns-#{ $i } .blocks-gallery-image,
&.columns-#{ $i } .blocks-gallery-item {
width: calc((100% - #{ $grid-unit-20 } * #{ $i - 1 }) / #{ $i });
margin-right: 16px;

// Rules inside this query are only run by Microsoft Edge.
// Edge miscalculates `calc`, so we have to add some buffer.
// See also https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15637241/
@supports (-ms-ime-align:auto) {
width: calc((100% - #{ $grid-unit-20 } * #{ $i - 1 }) / #{ $i } - 1px);
}
width: calc(#{ 100% / $i } - #{ $grid-unit-20 * ( $i - 1 ) / $i });
margin-right: $grid-unit-20;
}
}

Expand Down

0 comments on commit 1612deb

Please sign in to comment.