Skip to content

Commit

Permalink
Merge pull request foundation#11575 from ncoden/feat/dynamic-close-bu…
Browse files Browse the repository at this point in the history
…tton-sizes

feat: dynamically generate Close Button sizes from "$closebutton-size"
  • Loading branch information
ncoden committed Nov 13, 2018
2 parents f170b1c + 2e03ffc commit dfe9ae2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions scss/components/_close-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ $closebutton-position: right top !default;
/// @type Number
$closebutton-z-index: 10 !default;

/// Button size to use as default
/// @type String
/// @see $closebutton-size
/// @see $closebutton-offset-horizontal
/// @see $closebutton-offset-vertical
$closebutton-default-size: medium !default;

/// Right (or left) offset(s) for a close button.
/// @type Number|Map
$closebutton-offset-horizontal: (
Expand All @@ -28,7 +35,7 @@ $closebutton-offset-vertical: (
medium: 0.5rem,
) !default;

/// Default font size(s) of the close button.
/// Size(s) of the close button. Used to generate sizing modifiers.
/// @type Number|Map
$closebutton-size: (
small: 1.5em,
Expand Down Expand Up @@ -101,7 +108,20 @@ $closebutton-color-hover: $black !default;
.close-button {
@include close-button;

&.small { @include close-button-size(small) }
&, &.medium { @include close-button-size(medium) }
// Generate a placeholder and a class for each size
@each $name, $size in $closebutton-size {
@at-root {
%zf-close-button--#{$name} {
@include close-button-size($name);
}
}

&.#{$name} {
@extend %zf-close-button--#{$name};
}
}

// Use by default the placeholder of the default size
@extend %zf-close-button--#{$closebutton-default-size};
}
}

0 comments on commit dfe9ae2

Please sign in to comment.