Conversation
core/Controller/SvgController.php
Outdated
| * @return DataDisplayResponse|NotFoundException | ||
| */ | ||
| public function getSvg(string $fileName, $color = 'ffffff') { | ||
| $path = $this->serverRoot . "/core/img/actions/$fileName.svg"; |
There was a problem hiding this comment.
This then needs to be redone for all the other icon locations :/
There was a problem hiding this comment.
Yeah, it was a first shot, I'm asking for feedback on how to tackle this :)
how do you think we should handle custom paths? Right now I implemented this for the actions folder only, but in the end we'll probably need this for the apps menu and other stuff.
There was a problem hiding this comment.
On the other side I'm fine with doing it like this for now and test it.
There was a problem hiding this comment.
Lets first try it like this. I'd rather have 3 endpoints that are dead simple. (and do their own stuff) than 1 endpoint that does a lot of stuff.
There was a problem hiding this comment.
@rullzer though we'll need to access icons in apps, so I guess I will add a new endpoint for apps icons
There was a problem hiding this comment.
Sure but like I said. Small endpoints beat complex ones. so 🚀
core/css/icons.scss
Outdated
| &:hover, | ||
| &:focus { | ||
| background-image: url('../img/actions/delete-hover.svg?v=1'); | ||
| background-image: url('#{$webroot}/svg/icon-delete/d40000?v=1'); |
There was a problem hiding this comment.
icon-star (or icon-starred) then also needs the yellow star color. And the folders the Nextcloud blue (or rather theming color)?
There was a problem hiding this comment.
@jancborchardt that's correct, we can extend this to whatever colours we want :)
I think we can add another endpoint that is a bit more generic, so it works for other apps with different icon paths as well. We do have such a route in the theming app already: https://github.com/nextcloud/server/blob/master/apps/theming/appinfo/routes.php#L80-L84 |
|
I've added a new /svg/app/icon/color path :) |
core/Controller/SvgController.php
Outdated
|
|
||
| // Set cache control | ||
| $ttl = 31536000; | ||
| $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable'); |
There was a problem hiding this comment.
@skjnldsv I cannot find it, maybe you forgot to push? 😉 |
😅😅 |
f888fae to
10ebd3b
Compare
Codecov Report
@@ Coverage Diff @@
## master #9984 +/- ##
=========================================
Coverage ? 52.06%
Complexity ? 25950
=========================================
Files ? 1646
Lines ? 95867
Branches ? 1290
=========================================
Hits ? 49910
Misses ? 45957
Partials ? 0
|
|
@MorrisJobke still some fixes to do :)
|
|
|
||
| $data = ''; | ||
| foreach ($icons as $icon => $url) { | ||
| $data .= "--$icon: url('$url?v=1');"; |
There was a problem hiding this comment.
Is there a reason that the v=1 is appended here and not at the css level? I think that could lead to icons not being reloaded if they are changed.
There was a problem hiding this comment.
I have no idea, they were always like that, so I didn't give it a lot of thought :)
There was a problem hiding this comment.
I mean usually we have it inside of the css file, which is fine, since then it can be bumped once the icon file is changed, and the browsers can detect that they should load the file again.
There was a problem hiding this comment.
We should probably remove all of those ?v=1 then
|
Okay, that's how I proceed: .icon-screen-off {
@include icon-color('screen-off', 'actions', $color-black, true);
}Basically you just need to add this to your css and the background-image will be automatically added to a variable. The Mixin works that way: /**
* SVG COLOR API
*
* @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 bool [$core] search icon in core
*
* @returns string the url to the svg api endpoint
*/
@mixin icon-color($icon, $dir, $color, $core: false)Then, every time the scss is compiled, the system will detect if an icon is used via this mixin and export it to a new css file called icons-vars.css (cached into the appdata) @nextcloud/designers what are your thoughts? Is this a good behavior? |
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
5a25b3d to
bfc6fc8
Compare
|
@rullzer Rebased. |
MorrisJobke
left a comment
There was a problem hiding this comment.
Unit tests fail:
1) Test\Template\SCSSCacherTest::testProcessUncachedFileNoAppDataFolder
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:127
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:245
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:142
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:143
2) Test\Template\SCSSCacherTest::testProcessUncachedFile
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:167
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:245
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:142
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:179
3) Test\Template\SCSSCacherTest::testProcessCachedFile
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:203
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:245
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:142
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:210
4) Test\Template\SCSSCacherTest::testProcessCachedFileMemcache
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:242
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:245
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:142
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:249
5) Test\Template\SCSSCacherTest::testGetCachedSCSS with data set #0 ('core', 'core/css/styles.scss', '/css/core/styles.css', '14.0.0 alpha')
Expectation failed for method name is equal to "linkToRoute" when invoked 1 time(s)
Parameter 1 for invocation OCP\IURLGenerator::linkToRoute('core.Css.getCss', Array (...)): string does not match expected value.
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 'fileName' => '77d8-8422-styles.css'
+ 'fileName' => '77d8-0ab8-styles.css'
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:365
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:454
6) Test\Template\SCSSCacherTest::testGetCachedSCSS with data set #1 ('files', 'apps/files/css/styles.scss', '/css/files/styles.css', '1.9.0')
Expectation failed for method name is equal to "linkToRoute" when invoked 1 time(s)
Parameter 1 for invocation OCP\IURLGenerator::linkToRoute('core.Css.getCss', Array (...)): string does not match expected value.
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 'fileName' => 'd16b-8422-styles.css'
+ 'fileName' => 'd16b-0ab8-styles.css'
/drone/src/github.com/nextcloud/server/lib/private/Template/SCSSCacher.php:365
/drone/src/github.com/nextcloud/server/tests/lib/Template/SCSSCacherTest.php:454
core/Controller/SvgController.php
Outdated
| * @param string $folder | ||
| * @param string $fileName | ||
| * @param string $color | ||
| * @return DataDisplayResponse|NotFoundException |
There was a problem hiding this comment.
You don't return an exception you throw it ;)
| * @param string $color | ||
| * @return DataDisplayResponse|NotFoundException | ||
| */ | ||
| public function getSvgFromCore(string $folder, string $fileName, string $color = 'ffffff') { |
There was a problem hiding this comment.
You can also declare return types ;)
core/Controller/SvgController.php
Outdated
| * @param string $app | ||
| * @param string $fileName | ||
| * @param string $color | ||
| * @return DataDisplayResponse|NotFoundException |
core/Controller/SvgController.php
Outdated
| return $this->getSvg($path, $color, $fileName); | ||
| } | ||
|
|
||
| $appPath = \OC_App::getAppWebPath($app); |
| @@ -0,0 +1,146 @@ | |||
| <?php | |||
| /** | |||
| @@ -0,0 +1,126 @@ | |||
| <?php | |||
| /** | |||
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
| protected $urlGenerator; | ||
|
|
||
| /** @var string */ | ||
| private $iconVarRE = '/--(icon-[a-z0-9-]+): url\(["\']([a-z0-9-_\~\/\?\&\=\.]+)[^;]+;/m'; |
There was a problem hiding this comment.
@juliushaertl some of the icons are broken because of your last edit.
We shoudl exclude the ?v= from the matches because otherwise it gets re-added on every compile and we get stuff like that: --icon-confirm-fade-000: url('/svg/core/actions/confirm-fade/000?v=2?v=1?v=1?v=1?v=1');
Was there a specific reason? Or can I remove the ?=& from the regex? :)
There was a problem hiding this comment.
No, your right, we can remove those. The others might be needed depending on the base URL of the nextcloud installation.
| background-image: url('../img/actions/video.svg?v=2'); | ||
| filter: invert(100%) drop-shadow(1px 1px 4px var(--color-box-shadow)); | ||
| @include icon-color('video', 'actions', $color-white, 1, true); | ||
| filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); |
There was a problem hiding this comment.
Is there a bigger reason the invert(100%) was removed? this breaks the icons on the Talk UI, because now the white icon has a white shadow on a white background while you are waiting for a participant to join the call
|
The shadow? you mean @nickvergessen are you using the proper new css class? |
|
This causes high load on Safari: #11179 😢 |
This create a new endpoint to get one of our svg and change the colour.
This will allow us to:
Fix #8702
@nextcloud/designers do you see any issues with this?
@juliushaertl how do you think we should handle custom paths? Right now I implemented this for the actions folder only, but in the end we'll probably need this for the apps menu and other stuff.
Any example on where to use this?