Sha256: c3f2f751b17cdc666f7a6dffaaa1e4fcf231f6074364dbc083cd2084968e4fec

Contents?: true

Size: 985 Bytes

Versions: 9

Compression:

Stored size: 985 Bytes

Contents

// simple function to find the context of a nested percentage.
@function nested-context($contexts: null) {
  $contexts: if($contexts != null, $contexts, toolkit-get('nested context contexts'));

  // First level deep is always 100%
  $percentage: 100%;

  // Loop through each level
  @each $context in $contexts {
    // Invert the percentage to find context
    $percentage: percentage($percentage / $context);
  }
  // Return final percentage
  @return $percentage;
}

// mixin to make things easier
@mixin nested-context($contexts: null, $position: null) {
  $contexts: if($contexts != null, $contexts, toolkit-get('nested context contexts'));
  $position: if($position != null, $position, toolkit-get('nestex context position'));

  width: nested-context($contexts);
  @if $position == "center" {
    position: relative;
    left: 50%;
    margin-left: nested-context($contexts) * -.5;
  }
  @if $position == "right" {
    margin-left: nested-context($contexts) * -1 + 100%;
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
toolkit-2.0.0.alpha.10 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.9 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.8 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.7 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.6 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.5 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.4 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.3 stylesheets/toolkit/_nested-context.scss
toolkit-2.0.0.alpha.2 stylesheets/toolkit/_nested-context.scss