summaryrefslogtreecommitdiffstats
path: root/assets/sass/@primer/css/utilities/margin.scss
blob: 2212e919bf031905ed53edfb3317c6caa57f35c0 (plain) (blame)
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
// Margin spacer utilities
// stylelint-disable block-opening-brace-space-before, declaration-colon-space-before, comment-empty-line-before

// Loop through the breakpoint values
@each $breakpoint, $variant in $responsive-variants {
  @include breakpoint($breakpoint) {
    // Loop through the spacer values
    @each $scale, $size in $spacer-map {
      /* Set a $size margin to all sides at $breakpoint */
      .m#{$variant}-#{$scale}  { margin: $size !important; }
      /* Set a $size margin on the top at $breakpoint */
      .mt#{$variant}-#{$scale} { margin-top: $size !important; }
      /* Set a $size margin on the right at $breakpoint */
      .mr#{$variant}-#{$scale} { margin-right: $size !important; }
      /* Set a $size margin on the bottom at $breakpoint */
      .mb#{$variant}-#{$scale} { margin-bottom: $size !important; }
      /* Set a $size margin on the left at $breakpoint */
      .ml#{$variant}-#{$scale} { margin-left: $size !important; }

      @if ($size != 0) {
        /* Set a negative $size margin on top at $breakpoint */
        .mt#{$variant}-n#{$scale} { margin-top   : -$size !important; }
        /* Set a negative $size margin on the right at $breakpoint */
        .mr#{$variant}-n#{$scale} { margin-right : -$size !important; }
        /* Set a negative $size margin on the bottom at $breakpoint */
        .mb#{$variant}-n#{$scale} { margin-bottom: -$size !important; }
        /* Set a negative $size margin on the left at $breakpoint */
        .ml#{$variant}-n#{$scale} { margin-left  : -$size !important; }
      }

      /* Set a $size margin on the left & right at $breakpoint */
      .mx#{$variant}-#{$scale} {
        margin-right: $size !important;
        margin-left: $size !important;
      }

      /* Set a $size margin on the top & bottom at $breakpoint */
      .my#{$variant}-#{$scale} {
        margin-top: $size !important;
        margin-bottom: $size !important;
      }
    }

    /* responsive horizontal auto margins */
    .mx#{$variant}-auto {
      margin-right: auto !important;
      margin-left: auto !important;
    }
  }
}