Skip to content

Instantly share code, notes, and snippets.

@superfine
Forked from stowball/_usage.scss
Last active January 8, 2018 13:46
Show Gist options
  • Save superfine/802b84e236e8ab2e6b251f74ecbc4bd6 to your computer and use it in GitHub Desktop.
Save superfine/802b84e236e8ab2e6b251f74ecbc4bd6 to your computer and use it in GitHub Desktop.
Recursive z-index management
$z-indexes: (
main: (
above-inherit: (),
nested: (
low,
middle,
high
),
tooltip: ()
),
header: (),
toaster: ()
);
.main {
z-index: z(main);
}
.nested {
z-index: z(main, nested);
}
.high {
z-index: z(main, nested, high);
}
@function z-index($keys) {
$map: $z-indexes;
$found-index: null;
@each $key in $keys {
@if (type-of($map) == "map") {
$found-index: index(map-keys($map), $key);
$map: map-get($map, $key);
}
@else {
$found-index: index($map, $key);
}
}
@return $found-index;
}
@function z($keys...) {
@return z-index($keys);
}
@superfine
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment