Created
October 20, 2015 13:50
-
-
Save gsambrotta/d80262459461236f7cfc to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
// utils/z-index/z-index.variables.scss | |
// ------------- | |
$z-layers: ( | |
"goku": 9001, | |
"shoryuken": 8000, | |
"modal": ( | |
"base": 500, | |
"close": 100, | |
"header": 50, | |
"footer": 10 | |
), | |
"default": 1, | |
"below": -1, | |
"bottomless-pit": -9000 | |
); | |
// utils/z-index/z-index.helpers.scss | |
// ------------- | |
@function map-has-nested-keys($map, $keys...) { | |
@each $key in $keys { | |
@if not map-has-key($map, $key) { | |
@return false; | |
} | |
$map: map-get($map, $key); | |
} | |
@return true; | |
} | |
@function map-deep-get($map, $keys...) { | |
@each $key in $keys { | |
$map: map-get($map, $key); | |
} | |
@return $map; | |
} | |
@function z($layers...) { | |
@if not map-has-nested-keys($z-layers, $layers...) { | |
@warn "No layer found for `#{inspect($layers...)}` in $z-layers map. Double check on z-index.variables."; | |
} | |
@return map-deep-get($z-layers, $layers...); | |
} | |
// Example of usage | |
// --------------- | |
// New stacking context | |
.modal { | |
position: absolute; | |
z-index: z("modal", "base"); | |
.close-button { | |
z-index: z("modal", "close"); | |
} | |
header { | |
z-index: z("modal", "header"); | |
} | |
footer { | |
z-index: z("modal", "footer"); | |
} | |
} |
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
.modal { | |
position: absolute; | |
z-index: 500; | |
} | |
.modal .close-button { | |
z-index: 100; | |
} | |
.modal header { | |
z-index: 50; | |
} | |
.modal footer { | |
z-index: 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment