Skip to content

Instantly share code, notes, and snippets.

@jackw
Created September 15, 2015 14:05
Show Gist options
  • Save jackw/c1ac24de6e34a45d87fe to your computer and use it in GitHub Desktop.
Save jackw/c1ac24de6e34a45d87fe to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div id="ORB_BUTTONELEMENT">
<input id="btnSubmit" type="submit" value="Continue" class="ORB_BUTTON">
</div>
// ----
// libsass (v3.2.5)
// ----
$zindex-array: (
'content-overlay',
'main-nav',
'header',
'modal',
'whatever',
'footer'
);
@function stack($needle: 'content-overlay', $haystack: $zindex-array) {
// create shorthand to reset item.
@if $needle == 'default' {
@return auto;
}
// create a shorthand to force item to top of stack.
@if $needle == 'force' {
@return length($haystack);
}
// check for stack item and return index or error.
@if index($haystack, $needle) {
@return index($haystack, $needle);
} @else {
@warn "`#{inspect($haystack)}` doesn't seem to have a key named `#{inspect($needle)}` setting z-index to 0.";
@return 0;
}
};
.selector {
z-index: stack('footer');
}
.some-other-selector {
z-index: stack('sausage');
}
.modal {
z-index: stack('force');
}
.whatever {
z-index: stack('default');
}
// If we wanted to do something like create a component...
$modal-stack: ('cloak', 'window', 'title');
.modal {
z-index: stack('modal');
.cloak {
z-index: stack('cloak', $modal-stack);
}
}
.selector {
z-index: 6;
}
.some-other-selector {
z-index: 0;
}
.modal {
z-index: 6;
}
.whatever {
z-index: auto;
}
.modal {
z-index: 4;
}
.modal .cloak {
z-index: 1;
}
<div id="ORB_BUTTONELEMENT">
<input id="btnSubmit" type="submit" value="Continue" class="ORB_BUTTON">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment