mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Rename z-index layers var and update function
This commit is contained in:
@@ -93,12 +93,16 @@ $to-colossal: $from-colossal - 1 !default;
|
||||
// Z-indexes
|
||||
// =============================================================================
|
||||
|
||||
$layers: (
|
||||
$z-indexes: (
|
||||
"goku": 9000,
|
||||
"loader" : 500,
|
||||
"modal" : 300,
|
||||
"header" : 200,
|
||||
"dropdown" : 100,
|
||||
"transition": 500,
|
||||
"toast": 400,
|
||||
"popover": 300,
|
||||
"modal": 250,
|
||||
"sheet": 200,
|
||||
"fixed": 150,
|
||||
"sticky": 100,
|
||||
"dropdown": 50,
|
||||
"default": 1,
|
||||
"limbo": -999
|
||||
);
|
||||
|
||||
@@ -54,20 +54,29 @@
|
||||
@return ($size / $base) * 1rem;
|
||||
}
|
||||
|
||||
// A function helper to avoid having to type `map-get($layers, ...)`
|
||||
// Retrieves the z-index from the {@see $layers master list}.
|
||||
//
|
||||
// @link on http://css-tricks.com/handling-z-index/
|
||||
// @param {string} $layer The name of the z-index
|
||||
// @param {number} $var The modifier if needed
|
||||
// @return {number} The corresponding z-index based on the $layers var
|
||||
//
|
||||
// @param {string} $layer The name of the z-index.
|
||||
// @param {number} $modifier A positive or negative modifier to apply
|
||||
// to the returned z-index value.
|
||||
// @throw Error if the $layer does not exist.
|
||||
// @throw Warning if the $modifier might overlap another master z-index.
|
||||
// @return {number} The computed z-index of $layer and $modifier.
|
||||
|
||||
@function z($layer, $var: 0) {
|
||||
@function z($layer, $modifier: 0) {
|
||||
@if not map-has-key($layers, $layer) {
|
||||
@error "No z-index found in $layers map for `#{$layer}`. Property omitted.";
|
||||
@error "Unknown master z-index layer: #{$layer}";
|
||||
}
|
||||
|
||||
$value: map-get($layers, $layer);
|
||||
@return $value + $var;
|
||||
@if ($modifier >= 50 or $modifier <= -50) {
|
||||
@warn "Modifier may overlap the another master z-index layer: #{$modifier}";
|
||||
}
|
||||
|
||||
$index: map-get($z-indexes, $layer);
|
||||
|
||||
@return $index + $modifier;
|
||||
}
|
||||
|
||||
// Converts a number to a percentage.
|
||||
|
||||
Reference in New Issue
Block a user