Created
April 30, 2020 16:55
-
-
Save gruppjo/b114bb191db9874d74d0d8b94b8c34e3 to your computer and use it in GitHub Desktop.
[scss-setup]: _structure.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* V1.1 based on Jonathan's Gist */ | |
/* https://gist.github.com/gruppjo/b5c6389b1ef71369e815c95cb1b33813 */ | |
// The z-index increases from top to bottom | |
$zLayers: ( | |
'Buffer1', | |
'Buffer2', | |
'HomeHeader', | |
'MainNavigation', | |
'Modal' | |
); | |
@function zIndex($layerName) { | |
@return z($layerName); | |
} | |
@function z($layerName, $searchIn: $zLayers, $layer: null) { | |
@for $i from 1 through length($searchIn) { | |
$currentElement: nth($searchIn, $i); | |
@if ($currentElement == $layerName) { | |
@if ($layer == null) { | |
$layer: index($searchIn, $layerName); | |
} | |
@return $layer; | |
} | |
} | |
@if ($searchIn == $zLayers) { | |
@error "No z-index found for #{$layerName}. Property omitted."; | |
} | |
@return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment