Skip to content

Instantly share code, notes, and snippets.

@gruppjo
Created April 30, 2020 16:55
Show Gist options
  • Save gruppjo/b114bb191db9874d74d0d8b94b8c34e3 to your computer and use it in GitHub Desktop.
Save gruppjo/b114bb191db9874d74d0d8b94b8c34e3 to your computer and use it in GitHub Desktop.
[scss-setup]: _structure.scss
/* 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