////////////////////////////// // Deprecation Warnings for new Setting System ////////////////////////////// @function singularity-deprecation-warning() { $Singularity-Global-Vars: 'grids', 'gutters', 'gutter-styles', 'mobile-first', 'output', 'direction', 'include-border-box', 'include-clearfix'; @each $var in $Singularity-Global-Vars { @if global-variable-exists($var) { $Singularity-Warning-Output: "DEPRECATION: In order to remove global variable naming conflicts, Singularity's settings have been moved into the single `$singularity` variable."; @if $var == 'grids' or $var == 'gutters' or $var == 'gutter-styles' { $Singularity-Singleton-Var: str_slice($var, 1, -2); $Singularity-Warning-Output: $Singularity-Warning-Output + " Please replace all `$#{$var}` definitions, and all `add-#{$Singularity-Singleton-Var}()` calls to `@include add-#{$Singularity-Singleton-Var}()`"; } @else { // String Replace $Singularity-Replace-Index: -1; $Singularity-Replace-Holder: ''; $Singularity-Replace-Spaced: $var; @while $Singularity-Replace-Index != 0 { $Singularity-Replace-Index: str-index($Singularity-Replace-Spaced, '-'); @if $Singularity-Replace-Index != 0 { $Singularity-Replace-Holder: str-slice($Singularity-Replace-Spaced, 1, $Singularity-Replace-Index - 1) + ' '; $Singularity-Replace-Spaced: str-slice($Singularity-Replace-Spaced, $Singularity-Replace-Index + 1); $Singularity-Replace-Spaced: $Singularity-Replace-Holder + $Singularity-Replace-Spaced; $Singularity-Replace-Index: str-index($Singularity-Replace-Spaced, '-'); } } $Singularity-Warning-Output: $Singularity-Warning-Output + " Please replace all `$#{$var}` definitions with `@include sgs-change('#{$Singularity-Replace-Spaced}', $value)`"; } $Singularity-Warning-Output: $Singularity-Warning-Output + " In the next version of Singularity, this warning will be removed"; @warn $Singularity-Warning-Output; } } @return false; } $DEPRECATE:singularity-deprecation-warning(); ////////////////////////////// // Has Setting ////////////////////////////// @function sgs-has($setting) { @if map-has-key($singularity, $setting) { @return true; } @else { @return false; } } ////////////////////////////// // Get Settings ////////////////////////////// @function sgs-get($setting) { @if sgs-has($setting) { @return map-get($singularity, $setting); } @else { @return map-get($Singularity-Settings, $setting); } } ////////////////////////////// // Set Settings ////////////////////////////// @function sgs-set($setting, $value) { @if (str-index($setting, '-') > 0 or str-index($setting, '_') > 0) and str-index($setting, ' ') == 0 { @warn "Words in Singularity settings should be spaces, not dashes or underscores. Please replace dashes and underscores between words with spaces. Settings will not work as expected until changed."; } $singularity: map-merge($singularity, ($setting: $value)) !global; @return true; } @mixin sgs-change($setting, $value) { $sgs-change: sgs-set($setting, $value); } ////////////////////////////// // Remove Setting ////////////////////////////// @function sgs-reset($setting) { $Return: (); @each $Key, $Value in $singularity { $Return: if($setting == $Key, $Return, map-merge($Return, ($Key: $Value))); } $singularity: $Return !global; @return true; } @mixin sgs-reset($setting) { $sgs-reset: sgs-reset($setting); }