Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-08-28 19:21:17 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-10-02 09:37:55 +0300
commitc7e81e17c86a6e6beff433238a6923f5d931c22f (patch)
treee36ff2cb0a2875dabb0e5ed1dc4e4fc331cdf905
parentd855c38e078f2cd0bec86d5a20fc2f448799433b (diff)
Updates inverted logo handling to work like the app icons
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
-rw-r--r--apps/theming/css/theming.scss26
-rw-r--r--apps/theming/lib/ImageManager.php3
-rw-r--r--apps/theming/lib/ThemingDefaults.php21
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php67
-rw-r--r--core/img/logo/logo.svg72
5 files changed, 27 insertions, 162 deletions
diff --git a/apps/theming/css/theming.scss b/apps/theming/css/theming.scss
index b1b8896d0c1..35341159f19 100644
--- a/apps/theming/css/theming.scss
+++ b/apps/theming/css/theming.scss
@@ -7,6 +7,17 @@
@return (0.2126 * $-local-red + 0.7152 * $-local-green + 0.0722 * $-local-blue) / 255;
}
+$has-custom-logo: variable_exists('theming-logo-mime') and $theming-logo-mime != '';
+$invert: luma($color-primary) > 0.6;
+
+@if ($has-custom-logo == false) {
+ @if ($invert) {
+ $image-logo: url('../../../../svg/core/logo/logo/000000?v=1');
+ } @else {
+ $image-logo: url('../../../../svg/core/logo/logo/ffffff?v=1');
+ }
+}
+
.nc-theming-main-background {
background-color: $color-primary;
}
@@ -19,7 +30,7 @@
color: $color-primary-text;
}
-@if (luma($color-primary) > 0.6) {
+@if ($invert) {
#appmenu:not(.inverted) svg {
filter: invert(1);
}
@@ -104,7 +115,8 @@
}
/* override styles for login screen in guest.css */
-@if variable_exists('theming-logo-mime') and $theming-logo-mime != '' {
+@if ($has-custom-logo) {
+ // custom logo
#theming-preview-logo,
#header .logo {
background-size: contain;
@@ -113,6 +125,14 @@
#body-login #header .logo {
margin-bottom: 22px;
}
+} @else {
+ // default logo
+ @if ($invert) {
+ #theming-preview-logo,
+ #header .logo {
+ opacity: .6;
+ }
+ }
}
@if variable_exists('theming-background-mime') and $theming-background-mime != '' {
@@ -157,7 +177,7 @@ input.primary,
color: $color-primary-text;
}
-@if (luma($color-primary) > 0.6) {
+@if ($invert) {
#body-login #submit-wrapper .icon-confirm-white {
background-image: url('../../../core/img/actions/confirm.svg');
}
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index 46598673f14..75c978f2adb 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -80,9 +80,6 @@ class ImageManager {
}
switch ($key) {
- case 'logo-blue':
- // the blue logo is only available as svg
- return $this->urlGenerator->getAbsoluteURL('svg/core/logo/logo/0082C9') . '?v=' . $cacheBusterCounter;
case 'logo':
case 'logoheader':
case 'favicon':
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index 7a26b46516f..0573f7b84d7 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -33,7 +33,6 @@
namespace OCA\Theming;
-
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\Files\NotFoundException;
@@ -275,7 +274,7 @@ class ThemingDefaults extends \OC_Defaults {
'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'"
];
- $variables['image-logo'] = "url('". $this->getLogoUrl() ."')";
+ $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')";
$variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'";
$variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'";
$variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')";
@@ -301,24 +300,6 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
- * Returns the logo url.
- * If there is a custom logo, it just returns it.
- * For the default logo it returns the white or blue one depending on the color luminance.
- *
- * @return string
- */
- private function getLogoUrl() {
- $logoMime = $this->config->getAppValue('theming', 'logoMime');
- $primaryColor = $this->getColorPrimary();
- $luminance = $this->util->calculateLuminance($primaryColor);
- if ($logoMime === '' & $luminance > 0.8) {
- return $this->imageManager->getImageUrl('logo-blue', true);
- } else {
- return $this->imageManager->getImageUrl('logo', true);
- }
- }
-
- /**
* Check if the image should be replaced by the theming app
* and return the new image location then
*
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 3da39fbbf2f..68435dd148a 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -632,66 +632,6 @@ class ThemingDefaultsTest extends TestCase {
$this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables());
}
- /**
- * Provides test data for the get logo scss variable test.
- *
- * @return array
- */
- public function provideTestGetImageLogoScssVariableTestData(): array {
- return [
- // default logo
- ['', '#000000', 0.0, 'logo'],
- ['', '#cccccc', 0.8, 'logo'],
- ['', '#dddddd', 0.81, 'logo-blue'],
- ['', '#ffffff', 1.0, 'logo-blue'],
-
- // custom logo
- ['image/png', '#000000', 0.0, 'logo'],
- ['image/png', '#cccccc', 0.8, 'logo'],
- ['image/png', '#dddddd', 0.81, 'logo'],
- ['image/png', '#ffffff', 1.0, 'logo'],
- ];
- }
-
- /**
- * Tests chat the logo url scss variable has the expected value
- * depending on color and custom logo presence.
- *
- * @dataProvider provideTestGetImageLogoScssVariableTestData
- * @param string $themingLogoMime The custom logo mime type
- * @param string $primaryColor The primary theme color
- * @param float $luminance The calculated luminance
- * @param string $expected The expected requested logo
- * @return void
- */
- public function testGetImageLogoScssVariable(
- string $themingLogoMime,
- string $primaryColor,
- float $luminance,
- string $expected
- ) {
- $this->config->expects($this->at(5))
- ->method('getAppValue')
- ->with('theming', 'logoMime')
- ->willReturn($themingLogoMime);
- $this->config->expects($this->at(6))
- ->method('getAppValue')
- ->with('theming', 'color', $this->defaults->getColorPrimary())
- ->willReturn($primaryColor);
-
- $this->util
- ->method('calculateLuminance')
- ->with($primaryColor)
- ->willReturn($luminance);
-
- $this->imageManager->expects($this->at(0))
- ->method('getImageUrl')
- ->with($expected)
- ->willReturn('custom-logo?v=0');
-
- $this->template->getScssVariables();
- }
-
public function testGetScssVariables() {
$this->config->expects($this->at(0))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0');
$this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
@@ -699,13 +639,10 @@ class ThemingDefaultsTest extends TestCase {
$this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'logoheaderMime', false)->willReturn('jpeg');
$this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'faviconMime', false)->willReturn('jpeg');
- $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
+ $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary());
$this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
-
- $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary());
+ $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
$this->config->expects($this->at(8))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
- $this->config->expects($this->at(9))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
- $this->config->expects($this->at(10))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
diff --git a/core/img/logo/logo.svg b/core/img/logo/logo.svg
index dda265dfa16..dbc3e7f3f8e 100644
--- a/core/img/logo/logo.svg
+++ b/core/img/logo/logo.svg
@@ -1,71 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- version="1.1"
- height="128"
- width="256"
- viewBox="0 0 256 128"
- id="svg10"
- sodipodi:docname="logo.svg"
- inkscape:version="0.92.3 (2405546, 2018-03-11)">
- <metadata
- id="metadata16">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs14" />
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1920"
- inkscape:window-height="1053"
- id="namedview12"
- showgrid="false"
- inkscape:zoom="1.4296875"
- inkscape:cx="128"
- inkscape:cy="91.978142"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg10" />
- <g
- stroke="#fff"
- stroke-width="22"
- fill="none"
- id="g8">
- <circle
- cy="64"
- cx="40"
- r="26"
- id="circle2" />
- <circle
- cy="64"
- cx="216"
- r="26"
- id="circle4" />
- <circle
- cy="64"
- cx="128"
- r="46"
- id="circle6" />
- </g>
-</svg>
+<svg width="256" height="128" version="1.1" viewBox="0 0 256 128" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="#fff" stroke-width="22"><circle cx="40" cy="64" r="26"/><circle cx="216" cy="64" r="26"/><circle cx="128" cy="64" r="46"/></g></svg>