summaryrefslogtreecommitdiff
path: root/_sass/common/classes/_grid.scss
blob: 655c254b95601fc1ad6cb49fdc510a5e5708aec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
$grid-columns: 12;

.grid-container {
  @include overflow(hidden);
}
.cell {
  min-width: 0;
}

@mixin make-cell($columns) {
  @if $columns == "auto" {
    @include flex(1 1 0);
    width: auto;
  } @else if $columns == "shrink" {
    @include flex(0 0 auto);
    width: auto;
  } @else if $columns == "stretch" {
    @include flex(1);
  } @else {
    @include flex(none);
    width: percentage($columns / $grid-columns);
  }
}

@mixin make-grid-cell($columns, $breakpoint) {
  @include media-breakpoint-up($breakpoint) {
    .cell--#{breakpoint-infix($breakpoint)}#{$columns} {
      @include make-cell($columns);
    }
  }
}

.grid {
  @include flexbox();
  @include flex-wrap(wrap);
  & > {
    @each $breakpoint in map-keys($responsive) {
      @for $i from 1 through $grid-columns {
        @include make-grid-cell($i, $breakpoint);
      }
      @include make-grid-cell("auto", $breakpoint);
      @include make-grid-cell("shrink", $breakpoint);
      @include make-grid-cell("stretch", $breakpoint);
    }
  }
}

.grid--reverse {
  flex-direction: row-reverse;
}

@mixin make-grid() {
  $types: ("p");
  $directions: ("x", "y", "");
  $spacers: (0, 1, 2, 3, 4, 5);

  @each $type in $types {
    @each $direction in $directions {
      @each $spacer in $spacers {
        @if $direction == "" {
          .grid--#{$type}-#{$spacer} {
            @include make-spacing("m", "", $spacer, true);
            .cell {
              @include make-spacing($type, "", $spacer);
            }
          }
        } @else {
          .grid--#{$type}#{$direction}-#{$spacer} {
            @include make-spacing("m", $direction, $spacer, true);
            .cell {
              @include make-spacing($type, $direction, $spacer);
            }
          }
        }
      }
    }
  }
}

@include make-grid();