Sha256: 0a6d274d1fb5e383f5319a7102edc6ee59c629e56694f43df342a89bd717c827
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
// Copyright (C) 2014 Babs Gösgens. Licensed under MIT; see LICENSE.txt // Content: // 1. Variables // smart-cache // 2. Mixins // smart-cache // 1. Variables /// /// This is where we collect the properties and their selectors /// /// @type {Map} /// $smart-cache: (); // 1. Functions /// /// Function smart-cache /// /// @example scss /// %inline-block { /// @include smart-cache(( /// display: inline-block /// )); /// } /// %no-padding { /// @include smart-cache(( /// padding: 0 /// )); /// } /// %no-margin { /// @include smart-cache(( /// margin: 0, /// )); /// } /// /// @todo This mixin is under construction and experimental - do not use yet /// /// @since 0.1 /// /// @param {Map} $properties - Map of CSS properties /// @mixin smart-cache($properties) { // Looping through all properties/values from map @each $property, $value in $declarations { // Get the stored values for the current property $stored-values: map-get($smart-cache, $property); // If the value doesn't exist in stored values @if not index($stored-values, $value) { // Add it $smart-cache: map-merge($smart-cache, ($property: append($stored-values or (), $value))) !global; // And create a placeholder at root level @at-root %#{$property}-#{length(map-get($smart-cache, $property))} { #{$property}: $value; } } // Extend the placeholder @extend %#{$property}-#{index(map-get($smart-cache, $property), $value)}; } }
Version data entries
4 entries across 4 versions & 1 rubygems