From c31d52499811d5c68d122db806ce27a112b489bd Mon Sep 17 00:00:00 2001
From: Mark Otto <markdotto@gmail.com>
Date: Thu, 15 Jun 2017 11:15:48 -0700
Subject: [PATCH] add color contrast and map-get functions

---
 scss/_functions.scss | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scss/_functions.scss b/scss/_functions.scss
index 5aa9f66209..6c85bbd4ef 100644
--- a/scss/_functions.scss
+++ b/scss/_functions.scss
@@ -47,3 +47,26 @@
 
   @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);
+}
-- 
GitLab