Sha256: e352041d074f3b290f9c48ae51de102246ea3030fa43b9887b7cc8bac65fa9ee

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

// 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;
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flint-gs-1.0.2 stylesheets/flint/functions/lib/_family-instance-exists.scss
flint-gs-1.0.1 stylesheets/flint/functions/lib/_family-instance-exists.scss
flint-gs-1.0.0 stylesheets/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.7 stylesheets/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.6 stylesheets/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.5 sass/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.4 sass/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.3 sass/flint/functions/lib/_family-instance-exists.scss
flint-gs-0.1.2 sass/flint/functions/lib/_family-instance-exists.scss