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

Spacer variable refactor #661

Merged
merged 5 commits into from
Jan 25, 2019
Merged

Spacer variable refactor #661

merged 5 commits into from
Jan 25, 2019

Conversation

shawnbot
Copy link
Contributor

@shawnbot shawnbot commented Jan 24, 2019

This refactors our spacer variables so that the $spacer-{1-6} variables are the "source of truth", and $spacers just lists those values. This was awkward before with $spacer-1: nth($spacers, 1), and primer-marketing-support does it this way, so consistency++.

There's also a new variable, $spacer-map, which dramatically simplifies looping over the spacing scale:

// before, ugh
@for $i from 1 through length($spacers) {
  $size: nth($spacers, $i); // sm, md, lg, xl	
  $scale: $i - 1;  // 0, 1, 2, 3, 4, 5, 6
  .p-#{$scale} { padding: $size !important; }
}

// after, yay
@each $scale, $size in $spacer-map {
  .p-#{$scale} { padding: $size !important; }
}

Marketing spacer values ($spacer-{7..12}) also have !default now so they can be overridden.

This should not be a breaking change because the old variables still exist and their values are the same.

This refactors our spacer variables so that $spacer-n variables are the
"source of truth", $spacers is a list of the $spacer-n values, and the
new $spacer-map variable makes it easier to loop over the spacing scale
with:

@each $scale, $size in $spacer-map { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant