Sha256: 7ffaa9bdbe7efcb268693aa24b57ccca58c7876cfc95e4066d448bb92c69d55f
Contents?: true
Size: 1.87 KB
Versions: 5
Compression:
Stored size: 1.87 KB
Contents
// Checks if instance exists in selector familiy tree, falls back from current selector // ------------------------------------------------------------------------------- // @param $key [string] : breakpoint key to search for matching instance // @param $syntax [string | null] : searches for instance using passed syntax // ------------------------------------------------------------------------------- // @return matching instance | false @function get-family-instance($key: get-value("settings", "default"), $syntax: $flint__support-syntax) { $selector-string: selector_string(); // Check for syntax support, try to find instance using it @if $syntax { $selector-list: use-syntax($selector-string); $length: length($selector-list); // Loop through transformed selectors @for $i from 1 through $length { // Check last selector in list @if exists($flint__instances, "#{last($selector-list)}::#{$key}") { // Return the matching instance key @return "#{last($selector-list)}::#{$key}"; } @else { // Else, remove the last selector and loop again $selector-list: remove($selector-list, last($selector-list)); } } // Search for a parent instance normally @return get-family-instance($key, null); } @else { $selector-list: string-to-list($selector-string); $length: length($selector-list); // Loop through length of list of selectors @for $i from 1 through $length { // Make sure that we're not counting the current selector string @if exists($flint__instances, "#{list-to-string($selector-list, " ")}::#{$key}") and $selector-string != list-to-string($selector-list, " ") { // Return the matching instance key @return "#{list-to-string($selector-list, " ")}::#{$key}"; } @else { // Else, remove the last selector and loop again $selector-list: remove($selector-list, last($selector-list)); } } @return false; } }
Version data entries
5 entries across 5 versions & 1 rubygems