Skip to content
Snippets Groups Projects
Unverified Commit d07f04e4 authored by Julius Haertl's avatar Julius Haertl
Browse files

Theming: Colorize checkboxes depending on luminance

parent 0acfbd5b
No related branches found
No related tags found
No related merge requests found
...@@ -214,6 +214,7 @@ class ThemingController extends Controller { ...@@ -214,6 +214,7 @@ class ThemingController extends Controller {
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
$responseCss = ''; $responseCss = '';
$color = $this->config->getAppValue($this->appName, 'color'); $color = $this->config->getAppValue($this->appName, 'color');
$elementColor = Util::elementColor($color);
if($color !== '') { if($color !== '') {
$responseCss .= sprintf( $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}', '#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}',
...@@ -221,11 +222,11 @@ class ThemingController extends Controller { ...@@ -221,11 +222,11 @@ class ThemingController extends Controller {
); );
$responseCss .= sprintf(' $responseCss .= sprintf('
input[type="checkbox"].checkbox:checked + label:before { input[type="checkbox"].checkbox:checked + label:before {
background-image:url(/core/img/actions/checkmark-white.svg); background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');
background-color: %s; background-position: center center; background-size:contain; background-color: %s; background-position: center center; background-size:contain;
width:12px; height:12px; padding:0; margin:1px 6px 7px 2px; width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;
}', }',
$color $elementColor
); );
} }
$logo = $this->config->getAppValue($this->appName, 'logoMime'); $logo = $this->config->getAppValue($this->appName, 'logoMime');
......
...@@ -38,6 +38,21 @@ class Util { ...@@ -38,6 +38,21 @@ class Util {
} }
} }
/**
* get color for on-page elements:
* theme color by default, grey if theme color is to bright
* @param $color
* @return string
*/
public static function elementColor($color) {
$l = self::calculateLuminance($color);
if($l>0.8) {
return '#969696';
} else {
return $color;
}
}
/** /**
* @param string $color rgb color value * @param string $color rgb color value
* @return float * @return float
......
...@@ -65,4 +65,14 @@ class UtilTest extends TestCase { ...@@ -65,4 +65,14 @@ class UtilTest extends TestCase {
$invert = Util::invertTextColor(''); $invert = Util::invertTextColor('');
$this->assertEquals(false, $invert); $this->assertEquals(false, $invert);
} }
public function testElementColorDefault() {
$elementColor = Util::elementColor("#000000");
$this->assertEquals('#000000', $elementColor);
}
public function testElementColorOnBrightBackground() {
$elementColor = Util::elementColor('#ffffff');
$this->assertEquals('#969696', $elementColor);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment