Last active
March 7, 2020 11:01
Revisions
-
agorilla revised this gist
Dec 19, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ /// Function to get next map item /// returns next map item or fallback value if map, key or next item does not exist /// Github Repo: https://github.com/elcheio/sass-map-get-next-prev /// Node Module: https://www.npmjs.com/package/sass-map-get-next-prev /// /// @author Simon Koch <[email protected]> /// -
agorilla revised this gist
Sep 23, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ /// Function to get next map item /// returns next map item or fallback value if map, key or next item does not exist /// https://github.com/elcheio/sass-map-get-next-prev /// /// @author Simon Koch <[email protected]> /// -
agorilla revised this gist
Sep 23, 2018 . 1 changed file with 51 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,80 +1,88 @@ /// Function to get next map item /// returns next map item or fallback value if map, key or next item does not exist /// /// @author Simon Koch <[email protected]> /// /// Licensed under the MIT license. /// /// @access public /// /// @param {Map} $map - Sass list map /// @param {String} $key - List map key /// @param {Boolean} $fallback (false) - Fallback value if map, key or previous item does not exist /// @param {String} $return (value) - Return value or key of previous list item /// @param {Boolean} $debug (false) - Debug option /// /// @example scss - Usage ///$map: ( /// s: 320px, /// m: 768px, /// ); /// /// .foo { /// width: map-get-next($map, s); /// } /// /// .bar { /// width: map-get-next($map, m, 1024px); /// } /// /// @example css - CSS output /// .foo { /// width: 768px; /// } /// /// .bar { /// width: 1024px; /// } @function map-get-next($map, $key, $fallback: false, $return: value) { // Check if map is valid @if type-of($map) == map { // Check if key exists in map @if map-has-key($map, $key) { // Init index counter variable $i: 0; // Init key index $key-index: false; // Traverse map for key @each $map-key, $map-value in $map { // Update index $i: $i + 1; // If map key found, set key index @if $map-key == $key { $key-index: $i; } // If next index return next value or key based on $return @if $i == $key-index + 1 { @if $return == key { @return $map-key; } @else { @return $map-value; } } // If last entry return false @if $i == length($map) { @return $fallback; } } @warn 'No next map item for key #{$key}'; @return $fallback; } @warn 'No valid key #{$key} in map'; @return $fallback; } @warn 'No valid map'; @return $fallback; } -
agorilla revised this gist
Jan 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ /// } /// /// .bar { /// width: map-get-next($map, b, auto); /// } /// /// @example css - CSS output -
agorilla renamed this gist
Jan 9, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
agorilla created this gist
Jan 9, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ /// Function to get next map item /// returns next map item or fallback value if map, key or next item does not exist /// /// @author Simon Koch /// /// @access public /// /// @param {Map} $map - Sass list map /// @param {String} $key - List map key /// @param {String} $fallback (false) - Fallback value if map, key or next item does not exist /// /// @example scss - Usage /// $map: ( /// a: 100px, /// b: 200px /// ); /// /// .foo { /// width: map-get-next($map, a); /// } /// /// .bar { /// width: map-get-next($map, b, auto); /// } /// /// @example css - CSS output /// .foo { /// width: 200px; /// } /// /// .bar { /// width: auto; /// } @function map-get-next($map, $key, $fallback: false) { // Check if map is valid @if type_of($map) == map { // Check if key exists in map @if map_has_key($map, $key) { // Init index counter variable $i: 0; // Init key index $key-index: false; // Traverse map for key @each $map-key, $map-value in $map { // Update index $i: $i + 1; // If map key found, set key index @if $map-key == $key { $key-index: $i; } // If next index return next value @if $i == $key-index + 1 { @return $map-value; } // If last entry return false @if $i == length($map) { @return $fallback; } } @warn 'No next map item for key #{$key}'; @return $fallback; } @warn 'No valid key #{$key} in map'; @return $fallback; } @warn 'No valid map'; @return $fallback; }