-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Svg color api #9984
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
Svg color api #9984
Changes from 1 commit
84e90e2
98a0113
29ff7ef
ccd70a4
09f591f
d904293
8977c71
9e58859
a24cad1
cd6f00a
59db525
14bc9ff
dccfed8
6194681
6ed8c19
9159ed3
bfc6fc8
37a4d2b
9d94cc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,12 +55,13 @@ public function __construct(string $appName, | |
| * | ||
| * Generate svg from filename with the requested color | ||
| * | ||
| * @param string $folder | ||
| * @param string $fileName | ||
| * @param string $color | ||
| * @return DataDisplayResponse|NotFoundException | ||
| */ | ||
| public function getSvgFromCore(string $fileName, string $color = 'ffffff') { | ||
| $path = $this->serverRoot . "/core/img/actions/$fileName.svg"; | ||
| public function getSvgFromCore(string $folder, string $fileName, string $color = 'ffffff') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also declare return types ;) |
||
| $path = $this->serverRoot . "/core/img/$folder/$fileName.svg"; | ||
| return $this->getSvg($path, $color); | ||
| } | ||
|
|
||
|
|
@@ -70,11 +71,18 @@ public function getSvgFromCore(string $fileName, string $color = 'ffffff') { | |
| * | ||
| * Generate svg from filename with the requested color | ||
| * | ||
| * @param string $app | ||
| * @param string $fileName | ||
| * @param string $color | ||
| * @return DataDisplayResponse|NotFoundException | ||
|
||
| */ | ||
| public function getSvgFromApp(string $app, string $fileName, string $color = 'ffffff') { | ||
|
|
||
| if ($app === 'settings') { | ||
| $path = $this->serverRoot . "/settings/img/$fileName.svg"; | ||
| return $this->getSvg($path, $color); | ||
| } | ||
|
|
||
| $appPath = \OC_App::getAppWebPath($app); | ||
|
||
| if (!$appPath) { | ||
| return new NotFoundResponse(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2018, John Molakvoæ ([email protected]) | ||
| * | ||
| * @author John Molakvoæ (skjnldsv) <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| /** | ||
| * 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 | ||
| */ | ||
| @function icon-color($icon, $dir, $color, $core: false) { | ||
| // remove # from color | ||
| $index: str-index($color, '#'); | ||
| @if $index { | ||
| $color: str-slice($color, 2); | ||
| } | ||
| @if $core { | ||
| @return url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=1'); | ||
| } | ||
| @return url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=1'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't return an exception you throw it ;)