Last active
May 30, 2017 02:14
-
-
Save benjamincharity/0e6f121fad1bfa65508d5b7523163e3d to your computer and use it in GitHub Desktop.
Determine z-index based off of a list. This allows new items to be added without needing a refactor.
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
$z-layers: ( | |
"header", | |
"menu", | |
"menu-trigger", | |
); | |
///////////////////////////////////////////// | |
// | |
// Determine the correct z-index | |
// | |
@function z($name) { | |
@if index($z-layers, $name) { | |
@return (length($z-layers) - index($z-layers, $name)) + 1; | |
} @else { | |
@warn 'There is no item "#{$name}" in this list; choose one of: #{$z-layers}'; | |
@return null; | |
} | |
} | |
// Use | |
.foo { | |
z-index: z('header'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment