UNPKG

5.5 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group prototype-spacing
7////
8
9/// Responsive breakpoints for spacing classes (margin and padding)
10/// @type Boolean
11$prototype-spacing-breakpoints: $global-prototype-breakpoints !default;
12
13/// Default number of spacers count (margin and padding)
14/// @type Number
15$prototype-spacers-count: 3 !default;
16
17/// Margin helper mixin, all the values are multiplied by `$global-margin` which by default is equal to `1rem`
18/// @param {Number} $top [null] - Margin Top
19/// @param {Number} $right [null] - Margin Right
20/// @param {Number} $bottom [null] - Margin Bottom
21/// @param {Number} $left [null] - Margin Left
22@mixin margin(
23 $top: null,
24 $right: null,
25 $bottom: null,
26 $left: null
27) {
28 @if $top != null {
29 margin-top: $top * $global-margin !important;
30 }
31 @if $right != null {
32 margin-right: $right * $global-margin !important;
33 }
34 @if $bottom != null {
35 margin-bottom: $bottom * $global-margin !important;
36 }
37 @if $left != null {
38 margin-left: $left * $global-margin !important;
39 }
40}
41
42/// Padding helper mixin, all the values are multiplied by `$global-padding` which by default is equal to `1rem`
43/// @param {Number} $top [null] - Padding Top
44/// @param {Number} $right [null] - Padding Right
45/// @param {Number} $bottom [null] - Padding Bottom
46/// @param {Number} $left [null] - Padding Left
47@mixin padding(
48 $top: null,
49 $right: null,
50 $bottom: null,
51 $left: null
52) {
53 @if $top != null {
54 padding-top: $top * $global-padding !important;
55 }
56 @if $right != null {
57 padding-right: $right * $global-padding !important;
58 }
59 @if $bottom != null {
60 padding-bottom: $bottom * $global-padding !important;
61 }
62 @if $left != null {
63 padding-left: $left * $global-padding !important;
64 }
65}
66
67@mixin foundation-prototype-spacing {
68 @for $spacer from 0 through $prototype-spacers-count {
69 // All Sides
70 .margin-#{$spacer} {
71 @include margin($spacer, $spacer, $spacer, $spacer);
72 }
73
74 .padding-#{$spacer} {
75 @include padding($spacer, $spacer, $spacer, $spacer);
76 }
77
78 // Top Side
79 .margin-top-#{$spacer} {
80 @include margin($spacer, null, null, null);
81 }
82
83 .padding-top-#{$spacer} {
84 @include padding($spacer, null, null, null);
85 }
86
87 // Right Side
88 .margin-right-#{$spacer} {
89 @include margin(null, $spacer, null, null);
90 }
91
92 .padding-right-#{$spacer} {
93 @include padding(null, $spacer, null, null);
94 }
95
96 // Bottom Side
97 .margin-bottom-#{$spacer} {
98 @include margin(null, null, $spacer, null);
99 }
100
101 .padding-bottom-#{$spacer} {
102 @include padding(null, null, $spacer, null);
103 }
104
105 // Left Side
106 .margin-left-#{$spacer} {
107 @include margin(null, null, null, $spacer);
108 }
109
110 .padding-left-#{$spacer} {
111 @include padding(null, null, null, $spacer);
112 }
113
114 // Horizontal Axes
115 .margin-horizontal-#{$spacer} {
116 @include margin(null, $spacer, null, $spacer);
117 }
118
119 .padding-horizontal-#{$spacer} {
120 @include padding(null, $spacer, null, $spacer);
121 }
122
123 // Vertical Axes
124 .margin-vertical-#{$spacer} {
125 @include margin($spacer, null, $spacer, null)
126 }
127
128 .padding-vertical-#{$spacer} {
129 @include padding($spacer, null, $spacer, null)
130 }
131
132 @if ($prototype-spacing-breakpoints) {
133 // Loop through Responsive Breakpoints
134 @each $size in $breakpoint-classes {
135 @include breakpoint($size) {
136 @if $size != $-zf-zero-breakpoint {
137 // All Sides
138 .#{$size}-margin-#{$spacer} {
139 @include margin($spacer, $spacer, $spacer, $spacer);
140 }
141
142 .#{$size}-padding-#{$spacer} {
143 @include padding($spacer, $spacer, $spacer, $spacer);
144 }
145
146 // Top Side
147 .#{$size}-margin-top-#{$spacer} {
148 @include margin($spacer, null, null, null);
149 }
150
151 .#{$size}-padding-top-#{$spacer} {
152 @include padding($spacer, null, null, null);
153 }
154
155 // Right Side
156 .#{$size}-margin-right-#{$spacer} {
157 @include margin(null, $spacer, null, null);
158 }
159
160 .#{$size}-padding-right-#{$spacer} {
161 @include padding(null, $spacer, null, null);
162 }
163
164 // Bottom Side
165 .#{$size}-margin-bottom-#{$spacer} {
166 @include margin(null, null, $spacer, null);
167 }
168
169 .#{$size}-padding-bottom-#{$spacer} {
170 @include padding(null, null, $spacer, null);
171 }
172
173 // Left Side
174 .#{$size}-margin-left-#{$spacer} {
175 @include margin(null, null, null, $spacer);
176 }
177
178 .#{$size}-padding-left-#{$spacer} {
179 @include padding(null, null, null, $spacer);
180 }
181
182 // Horizontal Axes
183 .#{$size}-margin-horizontal-#{$spacer} {
184 @include margin(null, $spacer, null, $spacer);
185 }
186
187 .#{$size}-padding-horizontal-#{$spacer} {
188 @include padding(null, $spacer, null, $spacer);
189 }
190
191 // Vertical Axes
192 .#{$size}-margin-vertical-#{$spacer} {
193 @include margin($spacer, null, $spacer, null)
194 }
195
196 .#{$size}-padding-vertical-#{$spacer} {
197 @include padding($spacer, null, $spacer, null)
198 }
199 }
200 }
201 }
202 }
203 }
204}