Skip to content
This repository was archived by the owner on Mar 13, 2019. It is now read-only.

Commit 8dab612

Browse files
author
Luke Harrison
committed
Made margin and padding utilities consistent
1 parent 8d46aa2 commit 8dab612

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

07 - utilities/_utilities.margins.scss

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,118 @@ Generates standard and responsive variants using spacing map located in settings
99
responsive breakpoints located in settings.breakpoints.
1010
*/
1111

12+
13+
// MARGIN
14+
//--------------------------------------------------------------------------------------------------------------------------------------
15+
16+
// Example: u-margin-small
17+
@each $sp-name, $sp-value in $spacing {
18+
.u-margin-#{$sp-name} {
19+
margin:rem($sp-value) !important;
20+
}
21+
}
22+
23+
// Changes margin when breakpoint is hit
24+
// Example: u-margin-small@md
25+
@each $bp-name, $bp-value in $breakpoints {
26+
@include bp(#{$bp-name}) {
27+
@each $sp-name, $sp-value in $spacing {
28+
.u-margin-#{$sp-name}\@#{$bp-name} {
29+
margin:rem($sp-value) !important;
30+
}
31+
}
32+
}
33+
}
34+
35+
// Changes margin until breakpoint is hit
36+
// Example: u-margin-small@max-md
37+
@each $bp-name, $bp-value in $breakpoints {
38+
@include bpMax(#{$bp-name}) {
39+
@each $sp-name, $sp-value in $spacing {
40+
.u-margin-#{$sp-name}\@max-#{$bp-name} {
41+
margin:rem($sp-value) !important;
42+
}
43+
}
44+
}
45+
}
46+
47+
48+
// MARGIN HORIZONTAL
49+
//--------------------------------------------------------------------------------------------------------------------------------------
50+
51+
// Example: u-margin-horizontal-small
52+
@each $sp-name, $sp-value in $spacing {
53+
.u-margin-horizontal-#{$sp-name} {
54+
margin-left:rem($sp-value) !important;
55+
margin-right:rem($sp-value) !important;
56+
}
57+
}
58+
59+
// Changes margin-horizontal when breakpoint is hit
60+
// Example: u-margin-horizontal-small@md
61+
@each $bp-name, $bp-value in $breakpoints {
62+
@include bp(#{$bp-name}) {
63+
@each $sp-name, $sp-value in $spacing {
64+
.u-margin-horizontal-#{$sp-name}\@#{$bp-name} {
65+
margin-left:rem($sp-value) !important;
66+
margin-right:rem($sp-value) !important;
67+
}
68+
}
69+
}
70+
}
71+
72+
// Changes margin-horizontal until breakpoint is hit
73+
// Example: u-margin-horizontal-small@max-md
74+
@each $bp-name, $bp-value in $breakpoints {
75+
@include bpMax(#{$bp-name}) {
76+
@each $sp-name, $sp-value in $spacing {
77+
.u-margin-horizontal-#{$sp-name}\@max-#{$bp-name} {
78+
margin-left:rem($sp-value) !important;
79+
margin-right:rem($sp-value) !important;
80+
}
81+
}
82+
}
83+
}
84+
85+
86+
// MARGIN VERTICAL
87+
//--------------------------------------------------------------------------------------------------------------------------------------
88+
89+
// Example: u-margin-vertical-small
90+
@each $sp-name, $sp-value in $spacing {
91+
.u-margin-vertical-#{$sp-name} {
92+
margin-top:rem($sp-value) !important;
93+
margin-bottom:rem($sp-value) !important;
94+
}
95+
}
96+
97+
// Changes margin-vertical when breakpoint is hit
98+
// Example: u-margin-vertical-small@md
99+
@each $bp-name, $bp-value in $breakpoints {
100+
@include bp(#{$bp-name}) {
101+
@each $sp-name, $sp-value in $spacing {
102+
.u-margin-vertical-#{$sp-name}\@#{$bp-name} {
103+
margin-top:rem($sp-value) !important;
104+
margin-bottom:rem($sp-value) !important;
105+
}
106+
}
107+
}
108+
}
109+
110+
// Changes margin-vertical until breakpoint is hit
111+
// Example: u-margin-vertical-small@max-md
112+
@each $bp-name, $bp-value in $breakpoints {
113+
@include bpMax(#{$bp-name}) {
114+
@each $sp-name, $sp-value in $spacing {
115+
.u-margin-vertical-#{$sp-name}\@max-#{$bp-name} {
116+
margin-top:rem($sp-value) !important;
117+
margin-bottom:rem($sp-value) !important;
118+
}
119+
}
120+
}
121+
}
122+
123+
12124
// MARGIN TOP
13125
//--------------------------------------------------------------------------------------------------------------------------------------
14126

0 commit comments

Comments
 (0)