Commit 5da5a38f authored by Mark Otto's avatar Mark Otto Committed by Mark Otto
Browse files

Move scss functions from top of variables to separate file, then import it into other build files

parent 2e798301
Showing with 42 additions and 56 deletions
+42 -56
@mixin _assert-ascending($map, $map-name) {
$prev-key: null;
$prev-num: null;
@each $key, $num in $map {
@if $prev-num == null {
// Do nothing
} @else if not comparable($prev-num, $num) {
@warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !";
} @else if $prev-num >= $num {
@warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !";
}
$prev-key: $key;
$prev-num: $num;
}
}
// Replace `$search` with `$replace` in `$string`
// @author Hugo Giraudel
// @param {String} $string - Initial string
// @param {String} $search - Substring to replace
// @param {String} $replace ('') - New value
// @return {String} - Updated string
@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
@mixin _assert-starts-at-zero($map) {
$values: map-values($map);
$first-value: nth($values, 1);
@if $first-value != 0 {
@warn "First breakpoint in `$grid-breakpoints` must start at 0, but starts at #{$first-value}.";
}
}
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
// Variables should follow the `$component-state-property-size` formula for // Variables should follow the `$component-state-property-size` formula for
// consistent naming. Ex: $nav-link-disabled-color and $modal-content-box-shadow-xs. // consistent naming. Ex: $nav-link-disabled-color and $modal-content-box-shadow-xs.
// Table of Contents // Table of Contents
// //
// Colors // Colors
...@@ -44,51 +43,6 @@ ...@@ -44,51 +43,6 @@
// Close // Close
// Code // Code
@mixin _assert-ascending($map, $map-name) {
$prev-key: null;
$prev-num: null;
@each $key, $num in $map {
@if $prev-num == null {
// Do nothing
} @else if not comparable($prev-num, $num) {
@warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !";
} @else if $prev-num >= $num {
@warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !";
}
$prev-key: $key;
$prev-num: $num;
}
}
// Replace `$search` with `$replace` in `$string`
// @author Hugo Giraudel
// @param {String} $string - Initial string
// @param {String} $search - Substring to replace
// @param {String} $replace ('') - New value
// @return {String} - Updated string
@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
@mixin _assert-starts-at-zero($map) {
$values: map-values($map);
$first-value: nth($values, 1);
@if $first-value != 0 {
@warn "First breakpoint in `$grid-breakpoints` must start at 0, but starts at #{$first-value}.";
}
}
// General variable structure
//
// Variable format should follow the `$component-modifier-state-property` order.
// Colors // Colors
// //
......
...@@ -23,6 +23,7 @@ html { ...@@ -23,6 +23,7 @@ html {
} }
@import "custom"; @import "custom";
@import "functions";
@import "variables"; @import "variables";
// //
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// Includes only Normalize and our custom Reboot reset. // Includes only Normalize and our custom Reboot reset.
@import "custom"; @import "custom";
@import "functions";
@import "variables"; @import "variables";
@import "mixins"; @import "mixins";
......
...@@ -5,14 +5,11 @@ ...@@ -5,14 +5,11 @@
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/ */
// Core variables and mixins
@import "custom"; @import "custom";
@import "functions";
@import "variables"; @import "variables";
@import "mixins"; @import "mixins";
@import "print"; @import "print";
// Core CSS
@import "reboot"; @import "reboot";
@import "type"; @import "type";
@import "images"; @import "images";
...@@ -21,8 +18,6 @@ ...@@ -21,8 +18,6 @@
@import "tables"; @import "tables";
@import "forms"; @import "forms";
@import "buttons"; @import "buttons";
// Components
@import "transitions"; @import "transitions";
@import "dropdown"; @import "dropdown";
@import "button-group"; @import "button-group";
...@@ -41,12 +36,8 @@ ...@@ -41,12 +36,8 @@
@import "list-group"; @import "list-group";
@import "responsive-embed"; @import "responsive-embed";
@import "close"; @import "close";
// Components w/ JavaScript
@import "modal"; @import "modal";
@import "tooltip"; @import "tooltip";
@import "popover"; @import "popover";
@import "carousel"; @import "carousel";
// Utility classes
@import "utilities"; @import "utilities";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment