Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Commit 5c9e6c0

Browse files
committed
Merge branch 'allow-shorthand-margin-padding-values'
2 parents 62f67cd + 09deafc commit 5c9e6c0

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fa-css-utilities",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "CSS utilities for using and managing FreeAgent design properties consistently",
55
"repository": {
66
"type": "git",

utilities/_margin.scss

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,30 @@
99
/**
1010
* Example usage:
1111
* `@include margin(default);`
12+
* `@include margin(default large);`
13+
* `@include padding(default large x-large xx-small);`
14+
* `@include margin(x-large small, !important);`
1215
* `@include margin-left(large);`
1316
* `@include margin-bottom(xx-large, !important);`
1417
*/
1518

16-
@mixin margin($value, $important: null) {
17-
margin: map-get($spacing-values, $value) $important;
19+
/**
20+
* This mixin allows us to use shorthand values for the `margin` property.
21+
*
22+
* The mixin runs through our spacing values, given in the first argument, then
23+
* creates another list of the mappings of those spacing values, which it then
24+
* feeds to the `margin` property.
25+
*/
26+
27+
@mixin margin($values, $important: null) {
28+
$valueList: ();
29+
30+
@for $i from 1 through length($values) {
31+
$value: map-get($spacing-values, nth($values, $i));
32+
$valueList: append($valueList, $value, space);
33+
}
34+
35+
margin: $valueList $important;
1836
}
1937

2038
@mixin margin-bottom($value, $important: null) {

utilities/_padding.scss

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,30 @@
99
/**
1010
* Example usage:
1111
* `@include padding(default);`
12+
* `@include padding(default large);`
13+
* `@include padding(default large x-large xx-small);`
14+
* `@include padding(x-large small, !important);`
1215
* `@include padding-left(large);`
1316
* `@include padding-bottom(xx-large, !important);`
1417
*/
1518

16-
@mixin padding($value, $important: null) {
17-
padding: map-get($spacing-values, $value) $important;
19+
/**
20+
* This mixin allows us to use shorthand values for the `padding` property.
21+
*
22+
* The mixin runs through our spacing values, given in the first argument, then
23+
* creates another list of the mappings of those spacing values, which it then
24+
* feeds to the `padding` property.
25+
*/
26+
27+
@mixin padding($values, $important: null) {
28+
$valueList: ();
29+
30+
@for $i from 1 through length($values) {
31+
$value: map-get($spacing-values, nth($values, $i));
32+
$valueList: append($valueList, $value, space);
33+
}
34+
35+
padding: $valueList $important;
1836
}
1937

2038
@mixin padding-bottom($value, $important: null) {

0 commit comments

Comments
 (0)