]> source.dussan.org Git - nextcloud-server.git/commitdiff
Theming: fix primary button for bright colors 1170/head
authorJulius Haertl <jus@bitgrid.net>
Mon, 29 Aug 2016 17:07:27 +0000 (19:07 +0200)
committerJulius Haertl <jus@bitgrid.net>
Mon, 29 Aug 2016 17:07:27 +0000 (19:07 +0200)
apps/theming/lib/Controller/ThemingController.php
apps/theming/tests/Controller/ThemingControllerTest.php

index fbb4c9047737860f5884eaaf0ebde4aff45146a4..b4e3a95710f6ac7cbd9f69d26eca306b82b2dad4 100644 (file)
@@ -304,6 +304,13 @@ class ThemingController extends Controller {
                $responseCss = '';
                $color = $this->config->getAppValue($this->appName, 'color');
                $elementColor = $this->util->elementColor($color);
+
+               if($this->util->invertTextColor($color)) {
+                       $textColor = '#000000';
+               } else {
+                       $textColor = '#ffffff';
+               }
+
                if($color !== '') {
                        $responseCss .= sprintf(
                                '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n",
@@ -321,19 +328,26 @@ class ThemingController extends Controller {
                                'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($elementColor).'\');' .
                                "}\n";
                        $responseCss .= '.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary,' .
-                               '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active,' .
-                               '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
-                               '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
-                               '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                               '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {' .
                                'border: 1px solid '.$elementColor.';'.
                                'background-color: '.$elementColor.';'.
-                               'opacity: 0.8' .
+                               'opacity: 0.8;' .
+                               'color: ' . $textColor . ';'.
                                "}\n" .
                                '.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,' .
                                '.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {' .
                                'border: 1px solid '.$elementColor.';'.
                                'background-color: '.$elementColor.';'.
                                'opacity: 1.0;' .
+                               'color: ' . $textColor . ';'.
+                               "}\n" .
+                               '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
+                               '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
+                               '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                               'border: 1px solid '.$elementColor.';'.
+                               'background-color: '.$elementColor.';'.
+                               'opacity: 0.4;' .
+                               'color: '.$textColor.';'.
                                "}\n";
                        $responseCss .= '.ui-widget-header { border: 1px solid ' . $color . '; background: '. $color . '; color: #ffffff;' . "}\n";
                        $responseCss .= '.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {' .
index d053d8c1a1c0deaebab39b5800d4d04a63957f13..193e0bdcb4bf74fd059bc67aa20bde625b247bda 100644 (file)
@@ -437,19 +437,26 @@ class ThemingControllerTest extends TestCase {
                        'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($color).'\');' .
                        "}\n";
                $expectedData .= '.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary,' .
-                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active,' .
-                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
-                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
-                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
-                       'border: 1px solid '.$color .';'.
+                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {' .
+                       'border: 1px solid '.$color.';'.
                        'background-color: '.$color.';'.
-                       'opacity: 0.8' .
+                       'opacity: 0.8;' .
+                       'color: #ffffff;'.
                        "}\n" .
                        '.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,' .
                        '.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {' .
                        'border: 1px solid '.$color.';'.
                        'background-color: '.$color.';'.
                        'opacity: 1.0;' .
+                       'color: #ffffff;'.
+                       "}\n" .
+                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
+                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
+                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                       'border: 1px solid '.$color.';'.
+                       'background-color: '.$color.';'.
+                       'opacity: 0.4;' .
+                       'color: #ffffff;'.
                        "}\n";
                $expectedData .= '.ui-widget-header { border: 1px solid ' . $color . '; background: '. $color . '; color: #ffffff;' . "}\n";
                $expectedData .= '.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {' .
@@ -520,19 +527,26 @@ class ThemingControllerTest extends TestCase {
                        'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton('#555555').'\');' .
                        "}\n";
                $expectedData .= '.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary,' .
-                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active,' .
-                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
-                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
-                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
-                       'border: 1px solid #555555;'.
-                       'background-color: #555555;'.
-                       'opacity: 0.8' .
+                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {' .
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
+                       'opacity: 0.8;' .
+                       'color: #000000;'.
                        "}\n" .
                        '.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,' .
                        '.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {' .
-                       'border: 1px solid #555555;'.
-                       'background-color: #555555;'.
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
                        'opacity: 1.0;' .
+                       'color: #000000;'.
+                       "}\n" .
+                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
+                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
+                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
+                       'opacity: 0.4;' .
+                       'color: #000000;'.
                        "}\n";
                $expectedData .= '.ui-widget-header { border: 1px solid ' . $color . '; background: '. $color . '; color: #ffffff;' . "}\n";
                $expectedData .= '.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {' .
@@ -689,19 +703,26 @@ class ThemingControllerTest extends TestCase {
                        'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton($color).'\');' .
                        "}\n";
                $expectedData .= '.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary,' .
-                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active,' .
-                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
-                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
-                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
-                       'border: 1px solid '.$color .';'.
+                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {' .
+                       'border: 1px solid '.$color.';'.
                        'background-color: '.$color.';'.
-                       'opacity: 0.8' .
+                       'opacity: 0.8;' .
+                       'color: #ffffff;'.
                        "}\n" .
                        '.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,' .
                        '.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {' .
                        'border: 1px solid '.$color.';'.
                        'background-color: '.$color.';'.
                        'opacity: 1.0;' .
+                       'color: #ffffff;'.
+                       "}\n" .
+                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
+                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
+                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                       'border: 1px solid '.$color.';'.
+                       'background-color: '.$color.';'.
+                       'opacity: 0.4;' .
+                       'color: #ffffff;'.
                        "}\n";
                $expectedData .= '.ui-widget-header { border: 1px solid ' . $color . '; background: '. $color . '; color: #ffffff;' . "}\n";
                $expectedData .= '.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {' .
@@ -789,19 +810,26 @@ class ThemingControllerTest extends TestCase {
                        'background-image: url(\'data:image/svg+xml;base64,'.$this->util->generateRadioButton('#555555').'\');' .
                        "}\n";
                $expectedData .= '.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary,' .
-                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active,' .
-                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
-                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
-                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
-                       'border: 1px solid #555555;'.
-                       'background-color: #555555;'.
-                       'opacity: 0.8' .
+                       '.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {' .
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
+                       'opacity: 0.8;' .
+                       'color: #000000;'.
                        "}\n" .
                        '.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,' .
                        '.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {' .
-                       'border: 1px solid #555555;'.
-                       'background-color: #555555;'.
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
                        'opacity: 1.0;' .
+                       'color: #000000;'.
+                       "}\n" .
+                       '.primary:disabled, input[type="submit"].primary:disabled, input[type="button"].primary:disabled, button.primary:disabled, .button.primary:disabled,' .
+                       '.primary:disabled:hover, input[type="submit"].primary:disabled:hover, input[type="button"].primary:disabled:hover, button.primary:disabled:hover, .button.primary:disabled:hover,' .
+                       '.primary:disabled:focus, input[type="submit"].primary:disabled:focus, input[type="button"].primary:disabled:focus, button.primary:disabled:focus, .button.primary:disabled:focus {' .
+                       'border: 1px solid '.$elementColor.';'.
+                       'background-color: '.$elementColor.';'.
+                       'opacity: 0.4;' .
+                       'color: #000000;'.
                        "}\n";
                $expectedData .= '.ui-widget-header { border: 1px solid ' . $color . '; background: '. $color . '; color: #ffffff;' . "}\n";
                $expectedData .= '.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {' .