From 068330fc5419e953fa4df9246744cca9c5cce768 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Tue, 27 Sep 2022 07:39:40 +0000
Subject: [PATCH] fix contrast in dialogs, closes #1562

Closes #1562

Merge request studip/studip!1032
---
 resources/assets/stylesheets/mixins/colors.scss | 4 ++--
 resources/assets/stylesheets/mixins/misc.scss   | 4 ++--
 resources/assets/stylesheets/scss/dialog.scss   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/resources/assets/stylesheets/mixins/colors.scss b/resources/assets/stylesheets/mixins/colors.scss
index d58e4468fd1..560733f0ebe 100644
--- a/resources/assets/stylesheets/mixins/colors.scss
+++ b/resources/assets/stylesheets/mixins/colors.scss
@@ -124,8 +124,8 @@ $fieldset-header: $content-color-20;
 $fieldset-border: $base-color-20;
 
 // contrast colors
-$contrast-content-white: text-contrast($content-color, #ffffff, #000000, 67%);
-$contrast-content-gray: text-contrast($content-color, $dark-gray-color, #000000 , 67%);
+$contrast-content-white: text-contrast($content-color, #ffffff, #000000);
+$contrast-content-gray: text-contrast($content-color, $dark-gray-color, #000000 , 67);
 $contrast-content-hovergray: text-contrast($content-color, $dark-gray-color-10, $dark-gray-color);
 
 $public-course-bgcolor: $red;
diff --git a/resources/assets/stylesheets/mixins/misc.scss b/resources/assets/stylesheets/mixins/misc.scss
index ef2f277296e..d1f3fe67e7c 100644
--- a/resources/assets/stylesheets/mixins/misc.scss
+++ b/resources/assets/stylesheets/mixins/misc.scss
@@ -30,6 +30,6 @@
 }
 
 // https://codepen.io/kennyglenn/pen/kxqWjP
-@function text-contrast($color, $dark, $light, $threshold: 50%) {
-    @return if(lightness($color) > $threshold, $light, $dark)
+@function text-contrast($color, $dark, $light, $threshold: 51) {
+    @return if(lightness($color) < $threshold, $light, $dark)
 }
diff --git a/resources/assets/stylesheets/scss/dialog.scss b/resources/assets/stylesheets/scss/dialog.scss
index 36e666e58c2..81804ec5c8d 100644
--- a/resources/assets/stylesheets/scss/dialog.scss
+++ b/resources/assets/stylesheets/scss/dialog.scss
@@ -145,7 +145,7 @@
 
     .ui-dialog-titlebar {
         background-color: $yellow;
-        color: $contrast-content-white;
+        color: text-contrast($yellow, $black, $white);
         text-align: left;
     }
     .ui-dialog-titlebar-close {
-- 
GitLab