Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switches the default logo color depending on the primary color #10898

Merged
merged 6 commits into from Oct 8, 2018

Conversation

weeman1337
Copy link
Member

These changes add switching the default logo from white to blue depending on the primary color.
The switch happens between #cccccc and #dddddd

image

image

A custom logo doesn't use this mechanism.

Closes #10684

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the blue versions and didn't use the svg api, because it may not be available e.g. on the guest page.
There was another issue also taking out some icons for that reason.

@weeman1337 weeman1337 added design Design, UI, UX, etc. 3. to review Waiting for reviews labels Aug 28, 2018
@jancborchardt
Copy link
Member

@weeman1337 cool! I will come over to you in a bit :) Meanwhile – what would happen, say, when you have a light yellow or green theming color? Cause then the logo color would clash, right? That's why I would make it dark instead of blue, just like the top bar icons.

@weeman1337
Copy link
Member Author

@jancborchardt I made it blue because of #10684 (comment)

We had some discussion about that in the past, and the conclusion was that we don't want to invert the logo, because the Nextcloud logo should either be blue or white.

@weeman1337
Copy link
Member Author

@skjnldsv I moved the logos to img/logo and started using the SVG API as suggested.
Let's see what the build says..

@jancborchardt
Copy link
Member

So @weeman1337 and me just looked at it and we just have to pick a tradeoff:

  1. Logo always ⚪ white: Looks bad as soon as the color is light and all icons are dark
  2. Logo ⚪ white on dark background, and 🔵 blue on light background: Looks really bad on any light color which is not grey.
  3. Logo ⚪ white on dark background, and ⚫ black on light background: Looks decent.

So we are going for option 3. cc for info @nextcloud/designers

Only thing to adjust is that the threshold for change is the same as for the app icons in the top bar. :) Then 👍 from me.

@MorrisJobke MorrisJobke added this to the Nextcloud 15 milestone Aug 28, 2018
@MorrisJobke
Copy link
Member

Please wait for the stable14 branch until merging. I would like to not merge this into 14 that short before a release.

@weeman1337
Copy link
Member Author

After a short discussion I updated it to work like the app icons. Looks quite nice:
image

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff :)
Some small nitpicks ;)


@if ($has-custom-logo == false) {
@if ($invert) {
$image-logo: url('../../../../svg/core/logo/logo/000000?v=1');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the scss function for that :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mixin icon-color($icon, $dir, $color, $version: 1, $core: false) {
// remove # from color
// inspect cast int to string
$index: str-index(inspect($color), '#');
@if $index {
$color: str-slice(inspect($color), 2);
}
$varName: "--icon-#{$icon}-#{$color}";
@if $core {
#{$varName}: url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=#{$version}');
} @else {
#{$varName}: url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=#{$version}');
}
background-image: var(#{$varName});
}

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change of the logo file? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed the grouping of the three circles. The svg coloring freaked out..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clean things up then? :)
We use scour ;)

scour --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata --strip-xml-prolog --no-line-breaks -i old.svg new.svg

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -119,8 +119,7 @@ private function getSvg(string $path, string $color, string $fileName) {
}

// add fill (fill is not present on black elements)
$fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;])+)\/>/mi';

$fillRe = '/<((circle|rect|path)((!fill)[a-z0-9 =".\-#():;])+)\/>/mi';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the regex, please update the tests to make sure we also cover the reason why you changed this ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a test!
It changes the regex to do what the comment says ;) The actual version replaces existing fills. Removing the ? only matches if there isn't a fill already.

@juliushaertl juliushaertl added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Aug 30, 2018
@weeman1337 weeman1337 force-pushed the feature/10684/default-logo-color-theme-colors branch from 7210b11 to 0576f82 Compare August 30, 2018 19:09
@weeman1337
Copy link
Member Author

@skjnldsv I added a SvgControllerTest. The SVG coloring has some pitfalls. E.g. applying it on a black circle (without stroke/fill) or a group (applying it to child elements) may result in unwanted filled elements. I tweaked the Nextcloud logo to work.

With the new test we may extend the behavior in the future.

* @param string $icon the icon filename
* @param string $dir the icon folder within /core/img if $core or app name
* @param string $color the desired color in hexadecimal
* @param int $version the version of the file
* @param bool [$core] search icon in core
*
* @returns string the url to the svg api endpoint
* @returns A background image with the url to the set to the requested icon.
*/
@mixin icon-color($icon, $dir, $color, $version: 1, $core: false) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took this apart, because it didn't do what the comment said...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

@skjnldsv
Copy link
Member

With the new test we may extend the behavior in the future.

Maybe we should enforce a fill attribute and only replace in the future :)

@suntorytimed
Copy link
Contributor

Could this be implemented for the favicon as well? Would be nice to have a favicon that corresponds to the primary color and the different color of the Nextcloud logo. Currently it is necessary to use imagmagick to do any changes to the favicon.

@skjnldsv
Copy link
Member

@suntorytimed unfortunately, no. Svg as favicon are nowhere near to be supported: https://caniuse.com/#feat=link-icon-svg

@weeman1337 weeman1337 force-pushed the feature/10684/default-logo-color-theme-colors branch from 0576f82 to d1478a9 Compare September 6, 2018 17:45
@weeman1337 weeman1337 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 22, 2018
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
@rullzer rullzer force-pushed the feature/10684/default-logo-color-theme-colors branch from d1478a9 to a45ec3d Compare October 2, 2018 06:38
@rullzer
Copy link
Member

rullzer commented Oct 2, 2018

Rebased

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good! Let's wait the input of our lord and master @juliushaertl 😉

@juliushaertl
Copy link
Member

@weeman1337 There is one test failing:

There was 1 failure:

1) OCA\Theming\Tests\UtilTest::testGetAppImage with data set #0 ('core', 'logo.svg', '/drone/src/github.com/nextclo...go.svg')
Failed asserting that false matches expected '/drone/src/github.com/nextcloud/server/core/img/logo.svg'.

/drone/src/github.com/nextcloud/server/apps/theming/tests/UtilTest.php:172

Besides that it looks good to me, the favicon could also use the inverted logo, as we generate a png from with imagemagick for that anyway, but we can do that in a follow up pr.

@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Oct 2, 2018
Copy link
Member

@jancborchardt jancborchardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looking good! 👍

And yes, @juliushaertl follow-up PR to adjust the favicon would be great! :)

Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
@MorrisJobke
Copy link
Member

@weeman1337 Tests still fail 😢

Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
@weeman1337 weeman1337 added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Oct 4, 2018
@MorrisJobke MorrisJobke merged commit 7971ba5 into master Oct 8, 2018
@MorrisJobke MorrisJobke deleted the feature/10684/default-logo-color-theme-colors branch October 8, 2018 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish design Design, UI, UX, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants