Skip to content

Commit

Permalink
add ability to reset margin bottoms to zero by passing a key value in…
Browse files Browse the repository at this point in the history
…to the map
  • Loading branch information
kyleshevlin committed Jun 3, 2015
1 parent 8e9f0dd commit d6aa462
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
33 changes: 25 additions & 8 deletions lib/_shevy_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$_base-line-height: map-get($_shevy-current-map, 'base-line-height');
$_base-spacing: $_base-font-size * $_base-line-height;
$_font-scale-length: length(map-get($_shevy-current-map, 'base-font-scale'));
$_margin_bottom_bool: map-get($_shevy-current-map, 'margin-bottom');

@for $i from 1 through $_font-scale-length {
h#{$i} {
Expand Down Expand Up @@ -53,12 +54,16 @@
}

// Margin-bottom
@if $_base-font-unit == 'px' or $_base-font-unit == 'rem' {
margin-bottom: $_base-spacing;
} @else if $_base-font-unit == 'em' {
margin-bottom: $_base-spacing / get-font-scale-value($i, $_shevy-current-map);
@if $_margin-bottom-bool {
@if $_base-font-unit == 'px' or $_base-font-unit == 'rem' {
margin-bottom: $_base-spacing;
} @else if $_base-font-unit == 'em' {
margin-bottom: $_base-spacing / get-font-scale-value($i, $_shevy-current-map);
} @else {
@warn "Sorry, but that's an unsupported unit of measure.";
}
} @else {
@warn "Sorry, but that's an unsupported unit of measure.";
margin-bottom: 0;
}
}
}
Expand All @@ -76,8 +81,8 @@
$_base-line-height: map-get($_shevy-current-map, 'base-line-height');
$_base-spacing: $_base-font-size * $_base-line-height;
$_font-scale-length: length(map-get($_shevy-current-map, 'base-font-scale'));

$_paragraph-scale: map-get($_shevy-current-map, 'paragraph-scale');
$_margin_bottom_bool: map-get($_shevy-current-map, 'margin-bottom');

@if $_paragraph-scale == false {
$_paragraph-scale: get-font-scale-value($_font-scale-length, $_shevy-current-map);
Expand All @@ -89,14 +94,26 @@
// We use the last supplied font-size in the current map
font-size: $_base-font-size * $_paragraph-scale;

// Line Height
@if $_base-font-unit == 'px' or $_base-font-unit == 'rem' {
line-height: $_base-spacing;
margin-bottom: $_base-spacing;
} @else if $_base-font-unit == 'em' {
line-height: $_base-spacing / get-font-scale-value($_font-scale-length, $_shevy-current-map);
margin-bottom: $_base-spacing / get-font-scale-value($_font-scale-length, $_shevy-current-map);
} @else {
@warn "Sorry, but that's an unsupported unit of measure.";
}

// Margin Bottom
@if $_margin-bottom-bool {
@if $_base-font-unit == 'px' or $_base-font-unit == 'rem' {
margin-bottom: $_base-spacing;
} @else if $_base-font-unit == 'em' {
margin-bottom: $_base-spacing / get-font-scale-value($_font-scale-length, $_shevy-current-map);
} @else {
@warn "Sorry, but that's an unsupported unit of measure.";
}
} @else {
margin-bottom: 0;
}
}
}
3 changes: 2 additions & 1 deletion lib/_shevy_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ $shevy-defaults: (
base-font-size: 1em,
base-line-height: 1.5,
base-font-scale: (3, 2.5, 2, 1.5, 1.25, 1),
paragraph-scale: false
paragraph-scale: false,
margin-bottom: true
);

// Empty $shevy set as default in case one is not supplied by user
Expand Down

0 comments on commit d6aa462

Please sign in to comment.