Extract mixin to add a gap to a flexbox layout

This way we remove duplication and it'll be easier to add better support
for RTL languages.

In a few years this might not be necessary since support for the `gap`
property in a flexbox layout will improve. At the time of writing,
however, only 86.5% of the browsers support it [1].

[1] https://caniuse.com/flexbox-gap
This commit is contained in:
Javi Martín
2021-08-21 23:18:51 +02:00
parent 4a42804a7d
commit 4fea839c54
9 changed files with 18 additions and 41 deletions

View File

@@ -1,13 +1,10 @@
.admin .machine-learning-settings { .admin .machine-learning-settings {
.settings-management { .settings-management {
$gap: rem-calc(map-get($grid-column-gutter, medium)); @include flex-with-gap;
display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-left: -$gap;
> * { > * {
margin-left: $gap;
flex-basis: calc((#{rem-calc(720)} - 100%) * 999); flex-basis: calc((#{rem-calc(720)} - 100%) * 999);
flex-grow: 1; flex-grow: 1;
} }

View File

@@ -1,13 +1,8 @@
.admin .poll-questions-filter { .admin .poll-questions-filter {
$gap: 0.5em; $gap: 0.5em;
@include flex-with-gap($gap);
align-items: flex-end; align-items: flex-end;
display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-left: -$gap;
> * {
margin-left: $gap;
}
[type="submit"] { [type="submit"] {
@include regular-button; @include regular-button;

View File

@@ -1,10 +1,7 @@
.admin .table-actions { .admin .table-actions {
@include flex-with-gap(1.6em);
align-items: flex-start; align-items: flex-start;
display: flex; padding: 0 0.5em;
> :not(:first-child) {
margin-left: rem-calc(10);
}
a, a,
button { button {
@@ -13,7 +10,6 @@
flex-direction: column; flex-direction: column;
font-size: 0.9em; font-size: 0.9em;
line-height: $global-lineheight; line-height: $global-lineheight;
margin-right: 1em;
text-align: center; text-align: center;
&:hover, &:hover,

View File

@@ -2,14 +2,8 @@
margin-bottom: $line-height / 2; margin-bottom: $line-height / 2;
@include breakpoint(medium) { @include breakpoint(medium) {
$gap: 1em; @include flex-with-gap(1em);
align-items: flex-end; align-items: flex-end;
display: flex;
margin-left: -$gap;
> * {
margin-left: $gap;
}
} }
select { select {

View File

@@ -2,10 +2,9 @@
$spacing: $line-height / 2; $spacing: $line-height / 2;
.headings-list { .headings-list {
display: flex; @include flex-with-gap($spacing);
flex-wrap: wrap; flex-wrap: wrap;
list-style: none; list-style: none;
margin-left: -$spacing;
} }
.heading { .heading {
@@ -14,7 +13,6 @@
border-radius: rem-calc(6); border-radius: rem-calc(6);
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
margin-bottom: $line-height / 2; margin-bottom: $line-height / 2;
margin-left: $spacing;
margin-top: $line-height / 4; margin-top: $line-height / 4;
padding: $line-height / 2; padding: $line-height / 2;
position: relative; position: relative;

View File

@@ -179,12 +179,9 @@
margin-top: $line-height; margin-top: $line-height;
@include breakpoint(medium) { @include breakpoint(medium) {
$gap: rem-calc(map-get($grid-column-gutter, "medium")); @include flex-with-gap;
display: flex;
margin-left: -$gap;
> * { > * {
margin-left: $gap;
width: 50%; width: 50%;
} }

View File

@@ -57,14 +57,8 @@
} }
ul { ul {
$gap: 0.75em; @include flex-with-gap(0.75em);
display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-left: -$gap;
> * {
margin-left: $gap;
}
li::after { li::after {
content: none; content: none;

View File

@@ -23,6 +23,15 @@
} }
} }
@mixin flex-with-gap($gap: rem-calc(map-get($grid-column-gutter, medium))) {
display: flex;
margin-left: -$gap;
> * {
margin-left: $gap;
}
}
@mixin full-width-cover($adjust-margin: true, $adjust-padding: false) { @mixin full-width-cover($adjust-margin: true, $adjust-padding: false) {
$global-padding: rem-calc(map-get($grid-column-gutter, medium)) / 2; $global-padding: rem-calc(map-get($grid-column-gutter, medium)) / 2;
bottom: 0; bottom: 0;

View File

@@ -1,8 +1,6 @@
.feeds-participation { .feeds-participation {
$gap: rem-calc(map-get($grid-column-gutter, medium)); @include flex-with-gap;
display: flex;
flex-wrap: wrap; flex-wrap: wrap;
margin-left: -$gap;
.feed-proposals { .feed-proposals {
flex-basis: rem-calc(480); flex-basis: rem-calc(480);
@@ -17,7 +15,6 @@
.feed-proposals, .feed-proposals,
.feed-debates { .feed-debates {
display: flex; display: flex;
margin-left: $gap;
margin-top: $line-height; margin-top: $line-height;
flex-direction: column; flex-direction: column;