// Calculate width // ------------------------------------------------------------------------------- // @param $key [string] : key for lookup // @param $span [number] : span value of element // @param $context [number] : context value of element // ------------------------------------------------------------------------------- // @return calculated value | false @function flint-calc-width($key, $span, $context: null) { $result: false; // Check to see if value has been cached @if map-has-key($flint__cached-values, "#{$key, $span, $context}::width") and $context != "auto" { @return map-get($flint__cached-values, "#{$key, $span, $context}::width"); } @if flint-get-value("settings", "grid") == "fluid" { @if $key == "container" or $span == "container" { $result: flint-fluid-width(flint-get-value($key, "breakpoint"), flint-get-value($key, "breakpoint")); } @else if $context == null { $result: flint-fluid-width((flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $span), flint-get-value($key, "breakpoint")); } @else { $result: flint-fluid-width((flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $span), ((flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $context))); } } @if flint-get-value("settings", "grid") == "fixed" { @if $key == "container" or $span == "container" { $result: flint-get-value($key, "breakpoint"); } @else { $result: flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $span; } } // Save result to cache @if $context != "auto" { $flint__cached-values: map-merge($flint__cached-values, ("#{$key, $span, $context}::width": $result)); } // Return result @return $result; }