/// @group grid
////
-/// Get a gutter size for a given breakpoint
-/// @param {Keyword} $breakpoint [small] - Breakpoint name.
-/// @param {Number|Map} $gutters [$grid-column-gutter] - Gutter map or single value to use. Responsive gutter settings by default.
-///
-/// @returns {Number} Gutter size.
-@function grid-column-gutter(
- $breakpoint: $-zf-zero-breakpoint,
- $gutters: $grid-column-gutter
-) {
- // If gutter is single value, return it
- @if type-of($gutters) == 'number' {
- @return $gutters;
- }
-
- // Else, return the corresponding responsive value
- @return -zf-get-bp-val($gutters, $breakpoint);
-}
-
/// Set the gutters on a column
/// @param {Number|Keyword} $gutter [auto]
/// Spacing between columns, accepts multiple values:
$gutter: auto,
$gutters: $grid-column-gutter
) {
- @if $gutter == auto and type-of($gutters) == 'map' {
- // "auto"
- @each $breakpoint, $value in $gutters {
- @include breakpoint($breakpoint) {
- @include grid-column-gutter($value);
- }
- }
- }
- @else {
- // breakpoint name
- @if type-of($gutter) == 'string' {
- $gutter: grid-column-gutter($gutter, $gutters);
- }
-
- // single value
- $padding: rem-calc($gutter) / 2;
+ @include -zf-breakpoint-value($gutter, $gutters) {
+ $padding: rem-calc($-zf-bp-value) / 2;
padding-right: $padding;
padding-left: $padding;
$margin: auto,
$margins: $grid-column-gutter
) {
- @if $margin == auto and type-of($margins) == 'map' {
- // "auto"
- @each $breakpoint, $value in $margins {
- @include breakpoint($breakpoint) {
- @include grid-column-margin($value);
- }
- }
- } @else {
- // breakpoint name
- @if type-of($margin) == 'string' {
- $margin: grid-column-gutter($margin, $margins);
- }
-
- // single value
- $margin-bottom: rem-calc($margin);
+ @include -zf-breakpoint-value($margin, $margins) {
+ $margin-bottom: rem-calc($-zf-bp-value);
margin-bottom: $margin-bottom;
-
+
> :last-child {
margin-bottom: 0;
}
}
}
+/// Get a value in a map for a given breakpoint name
+/// @param {Keyword} $bp-name [small] - Breakpoint name.
+/// @param {Number|Map} $bp-values-map - Map of breakpoints and values or single value to use.
+///
+/// @returns {Number} Breakpoint-related value from `$bp-values-map`.
+@function -zf-breakpoint-value(
+ $bp-name: $-zf-zero-breakpoint,
+ $bp-values-map: null
+) {
+ // If the map is a single value, return it
+ @if type-of($bp-values-map) == 'number' {
+ @return $bp-values-map;
+ }
+
+ // Else, return the corresponding breakpoint value
+ @return -zf-get-bp-val($bp-values-map, $bp-name);
+}
+
// Legacy breakpoint variables
// These will be removed in 6.3
$small-up: null;
}
}
}
+
+/// Generate the content passed to the mixin with a value `$-zf-bp-value` related to a breakpoint, depending on the `$name` parameter.
+/// @param {Number|Keyword} $name [auto]
+/// The $name parameter accepts multiple values:
+/// - A single value will be directly passed as `$-zf-bp-value` to the mixin content.
+/// - A breakpoint name will make `$-zf-bp-value` the corresponding value in `$map`.
+/// - "auto" will generate the mixin content for each breakpoint in `$map` with the corresponding value as `$-zf-bp-value`.
+/// @param {Number|Map} $map - Map of breakpoints and values or single value to use.
+@mixin -zf-breakpoint-value(
+ $name: auto,
+ $map: null
+) {
+ @if $name == auto and type-of($map) == 'map' {
+ // "auto"
+ @each $k, $v in $map {
+ @include breakpoint($k) {
+ @include -zf-breakpoint-value($v, $map) {
+ @content;
+ }
+ }
+ }
+ }
+ @else {
+ // breakpoint name
+ @if type-of($name) == 'string' {
+ $name: -zf-breakpoint-value($name, $map);
+ }
+
+ // breakpoint value
+ $-zf-bp-value: $name !global;
+ @content;
+ }
+}