Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up spacers a bit more #22125

Merged
merged 1 commit into from
Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/utilities/spacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Where *sides* is one of:
Where *size* is one of:

* `0` - for classes that eliminate the `margin` or `padding` by setting it to `0`
* `1` - (by default) for classes that set the `margin` or `padding` to `$spacer * .25` or `$spacer * .25`
* `2` - (by default) for classes that set the `margin` or `padding` to `$spacer * .5` or `$spacer * .5`
* `3` - (by default) for classes that set the `margin` or `padding` to `$spacer` or `$spacer`
* `4` - (by default) for classes that set the `margin` or `padding` to `$spacer * 1.5` or `$spacer * 1.5`
* `5` - (by default) for classes that set the `margin` or `padding` to `$spacer * 3` or `$spacer * 3`
* `1` - (by default) for classes that set the `margin` or `padding` to `$spacer * .25`
* `2` - (by default) for classes that set the `margin` or `padding` to `$spacer * .5`
* `3` - (by default) for classes that set the `margin` or `padding` to `$spacer`
* `4` - (by default) for classes that set the `margin` or `padding` to `$spacer * 1.5`
* `5` - (by default) for classes that set the `margin` or `padding` to `$spacer * 3`

(You can add more sizes by adding entries to the `$spacers` Sass map variable.)

Expand All @@ -62,7 +62,7 @@ Here are some representative examples of these classes:
}

.p-3 {
padding: $spacer $spacer !important;
padding: $spacer !important;
}
{% endhighlight %}

Expand Down
30 changes: 6 additions & 24 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,12 @@ $enable-print-styles: true !default;

$spacer: 1rem !default;
$spacers: (
0: (
x: 0,
y: 0
),
1: (
x: ($spacer * .25),
y: ($spacer * .25)
),
2: (
x: ($spacer * .5),
y: ($spacer * .5)
),
3: (
x: $spacer,
y: $spacer
),
4: (
x: ($spacer * 1.5),
y: ($spacer * 1.5)
),
5: (
x: ($spacer * 3),
y: ($spacer * 3)
)
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3)
) !default;

// This variable affects the `.h-*` and `.w-*` classes.
Expand Down
22 changes: 10 additions & 12 deletions scss/utilities/_spacing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);

@each $prop, $abbrev in (margin: m, padding: p) {
@each $size, $lengths in $spacers {
$length-x: map-get($lengths, x);
$length-y: map-get($lengths, y);
@each $size, $length in $spacers {

.#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length-y $length-x !important; }
.#{$abbrev}t#{$infix}-#{$size} { #{$prop}-top: $length-y !important; }
.#{$abbrev}r#{$infix}-#{$size} { #{$prop}-right: $length-x !important; }
.#{$abbrev}b#{$infix}-#{$size} { #{$prop}-bottom: $length-y !important; }
.#{$abbrev}l#{$infix}-#{$size} { #{$prop}-left: $length-x !important; }
.#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; }
.#{$abbrev}t#{$infix}-#{$size} { #{$prop}-top: $length !important; }
.#{$abbrev}r#{$infix}-#{$size} { #{$prop}-right: $length !important; }
.#{$abbrev}b#{$infix}-#{$size} { #{$prop}-bottom: $length !important; }
.#{$abbrev}l#{$infix}-#{$size} { #{$prop}-left: $length !important; }
.#{$abbrev}x#{$infix}-#{$size} {
#{$prop}-right: $length-x !important;
#{$prop}-left: $length-x !important;
#{$prop}-right: $length !important;
#{$prop}-left: $length !important;
}
.#{$abbrev}y#{$infix}-#{$size} {
#{$prop}-top: $length-y !important;
#{$prop}-bottom: $length-y !important;
#{$prop}-top: $length !important;
#{$prop}-bottom: $length !important;
}
}
}
Expand Down