Skip to content

Instantly share code, notes, and snippets.

@gruppjo
Created April 30, 2020 16:55
Show Gist options
  • Select an option

  • Save gruppjo/b114bb191db9874d74d0d8b94b8c34e3 to your computer and use it in GitHub Desktop.

Select an option

Save gruppjo/b114bb191db9874d74d0d8b94b8c34e3 to your computer and use it in GitHub Desktop.

Revisions

  1. gruppjo created this gist Apr 30, 2020.
    35 changes: 35 additions & 0 deletions _structure.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    /* 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;
    }