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
path: root/core
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-08-30 21:00:13 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-10-02 09:37:55 +0300
commita45ec3d32430f40be93fa5f09832917b82c83f15 (patch)
treebdd333db314d26f5018217cb79c255cf9fac405d /core
parentc7e81e17c86a6e6beff433238a6923f5d931c22f (diff)
Refactors the scss svg functions
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/SvgController.php4
-rw-r--r--core/css/functions.scss52
-rw-r--r--core/img/logo/logo.svg2
3 files changed, 40 insertions, 18 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php
index f0fc1dac4d4..c6bf7b94da3 100644
--- a/core/Controller/SvgController.php
+++ b/core/Controller/SvgController.php
@@ -29,7 +29,6 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\Files\NotFoundException;
use OCP\App\IAppManager;
use OCP\IRequest;
@@ -99,7 +98,6 @@ class SvgController extends Controller {
return $this->getSvg($path, $color, $fileName);
}
-
/**
* Generate svg from filename with the requested color
*
@@ -119,7 +117,7 @@ class SvgController extends Controller {
}
// 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';
$svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg);
// replace any fill or stroke colors
diff --git a/core/css/functions.scss b/core/css/functions.scss
index 0815ba29ab6..5007c3bbe79 100644
--- a/core/css/functions.scss
+++ b/core/css/functions.scss
@@ -19,31 +19,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
+
+/**
+ * Removes the "#" from a color.
+ *
+ * @param string $color The color
+ * @return string The color without #
+ */
+@function remove-hash-from-color($color) {
+ $index: str-index(inspect($color), '#');
+ @if $index {
+ $color: str-slice(inspect($color), 2);
+ }
+ @return $color;
+}
+
+/**
+ * Calculates the URL to the svg under the SVG 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 int [$version] the version of the file
+ * @param bool [$core] search icon in core
+ * @return string The URL to the svg.
+ */
+@function icon-color-path($icon, $dir, $color, $version: 1, $core: false) {
+ $color: remove-hash-from-color($color);
+ @if $core {
+ @return '#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=#{$version}';
+ } @else {
+ @return '#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=#{$version}';
+ }
+}
+
/**
* 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 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) {
- // remove # from color
- // inspect cast int to string
- $index: str-index(inspect($color), '#');
- @if $index {
- $color: str-slice(inspect($color), 2);
- }
+ $color: remove-hash-from-color($color);
$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}');
- }
+ #{$varName}: url(icon-color-path($icon, $dir, $color, $version, $core));
background-image: var(#{$varName});
}
diff --git a/core/img/logo/logo.svg b/core/img/logo/logo.svg
index dbc3e7f3f8e..076f295e4d1 100644
--- a/core/img/logo/logo.svg
+++ b/core/img/logo/logo.svg
@@ -1 +1 @@
-<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>
+<svg width="256" height="128" version="1.1" viewBox="0 0 256 128" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke-width="22"><circle cx="40" cy="64" r="26" stroke="#fff" fill="none"/><circle cx="216" cy="64" r="26" stroke="#fff" fill="none"/><circle cx="128" cy="64" r="46" stroke="#fff" fill="none"/></g></svg>