// Checks if instance exists in selector familiy tree, falls back from current selector // ------------------------------------------------------------------------------- // @dependence `selector_string()` // @dependence `string-to-list()` // @dependence `list-to-string()` // @dependence `get-value()` // @dependence `exists()` // @dependence `remove()` // ------------------------------------------------------------------------------- // @param $key [Breakpoint] : breakpoint key to search for matching instance // ------------------------------------------------------------------------------- // @return [Selectors] | false @function family-instance-exists($key: get-value(settings, default)) { $selector-string: selector_string(); $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, " ") { // If true, return the maching 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; }