]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
add color contrast and map-get functions
authorMark Otto <markdotto@gmail.com>
Thu, 15 Jun 2017 18:15:48 +0000 (11:15 -0700)
committerMark Otto <markdotto@gmail.com>
Thu, 15 Jun 2017 18:15:48 +0000 (11:15 -0700)
scss/_functions.scss

index 5aa9f662093331e961e7445b7c3c7a6fc3d719f6..6c85bbd4ef545c15a801fe49d3bebdc4032ffecb 100644 (file)
 
   @return $string;
 }
+
+// Color contrast
+@mixin color-yiq($color) {
+  $r: red($color);
+  $g: green($color);
+  $b: blue($color);
+
+  $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
+
+  @if ($yiq >= 128) {
+    color: #111;
+  } @else {
+    color: #fff;
+  }
+}
+
+// Retreive color Sass maps
+@function color($key: "blue") {
+  @return map-get($colors, $key);
+}
+@function theme-color($key: "primary") {
+  @return map-get($theme-colors, $key);
+}