Mixin scss icon api

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-07-03 13:23:22 +02:00 committed by Julius Härtl
parent d904293ba3
commit 8977c71f88
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
15 changed files with 376 additions and 194 deletions

View File

@ -17,10 +17,6 @@ $color-box-shadow: rgba(darken($color-main-background, 70%), 0.5);
$color-border: lighten($color-main-background, 7%); $color-border: lighten($color-main-background, 7%);
$color-border-dark: lighten($color-main-background, 14%); $color-border-dark: lighten($color-main-background, 14%);
// invert svg icons colors
$color-white: #000;
$color-black: #fff;
#app-navigation > ul > li > a:first-child, #app-navigation > ul > li > a:first-child,
#app-navigation > ul > li > ul > li > a:first-child, #app-navigation > ul > li > ul > li > a:first-child,
#expanddiv a { #expanddiv a {

View File

@ -36,6 +36,7 @@ use OCP\IRequest;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use OC\Template\SCSSCacher;
class AccessibilityController extends Controller { class AccessibilityController extends Controller {

View File

@ -11,5 +11,5 @@
/* icons for sidebar */ /* icons for sidebar */
.nav-icon-basic-encryption-module { .nav-icon-basic-encryption-module {
background-image: icon-color('app', 'encryption', $color-black); @include icon-color('app', 'encryption', $color-black);
} }

View File

@ -84,26 +84,26 @@
/* icons for sidebar */ /* icons for sidebar */
.nav-icon-files { .nav-icon-files {
background-image: icon-color(folder, 'files', $color-black); @include icon-color(folder, 'files', $color-black);
} }
.nav-icon-recent { .nav-icon-recent {
background-image: icon-color(recent, 'files', $color-black); @include icon-color(recent, 'files', $color-black);
} }
.nav-icon-favorites { .nav-icon-favorites {
background-image: icon-color(star, 'files', $color-black); @include icon-color(star, 'files', $color-black);
} }
.nav-icon-sharingin, .nav-icon-sharingin,
.nav-icon-sharingout { .nav-icon-sharingout {
background-image: icon-color(share, 'files', $color-black); @include icon-color(share, 'files', $color-black);
} }
.nav-icon-sharinglinks { .nav-icon-sharinglinks {
background-image: icon-color(public, 'files', $color-black); @include icon-color(public, 'files', $color-black);
} }
.nav-icon-extstoragemounts { .nav-icon-extstoragemounts {
background-image: icon-color(external, 'files', $color-black); @include icon-color(external, 'files', $color-black);
} }
.nav-icon-trashbin { .nav-icon-trashbin {
background-image: icon-color(delete, 'files', $color-black); @include icon-color(delete, 'files', $color-black);
} }
.nav-icon-deletedshares { .nav-icon-deletedshares {
background-image: url('../img/unshare.svg?v=1'); background-image: url('../img/unshare.svg?v=1');
@ -667,7 +667,7 @@ table.dragshadow td.size {
background-image: none; background-image: none;
} }
& .icon-starred { & .icon-starred {
background-image: url('../../../core/img/actions/starred.svg?v=1'); @include icon-color('star-dark', 'actions', 'FC0', true);
} }
} }

View File

@ -74,7 +74,7 @@ class FileChanges implements IFilter {
* @since 11.0.0 * @since 11.0.0
*/ */
public function getIcon() { public function getIcon() {
return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/files-dark.svg')); return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/files.svg'));
} }
/** /**

View File

@ -122,5 +122,5 @@ td.mountPoint, td.backend { width:160px; }
} }
.nav-icon-external-storage { .nav-icon-external-storage {
background-image: icon-color('app-dark', 'files_external', $color-black); @include icon-color('app-dark', 'files_external', $color-black);
} }

View File

@ -31,6 +31,7 @@ use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\IRequest; use OCP\IRequest;
use OC\Template\IconsCacher;
class SvgController extends Controller { class SvgController extends Controller {
@ -40,13 +41,18 @@ class SvgController extends Controller {
/** @var ITimeFactory */ /** @var ITimeFactory */
protected $timeFactory; protected $timeFactory;
/** @var IconsCacher */
protected $iconsCacher;
public function __construct(string $appName, public function __construct(string $appName,
IRequest $request, IRequest $request,
ITimeFactory $timeFactory) { ITimeFactory $timeFactory,
IconsCacher $iconsCacher) {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->serverRoot = \OC::$SERVERROOT; $this->serverRoot = \OC::$SERVERROOT;
$this->timeFactory = $timeFactory; $this->timeFactory = $timeFactory;
$this->iconsCacher = $iconsCacher;
} }
/** /**

View File

@ -30,14 +30,17 @@
* *
* @returns string the url to the svg api endpoint * @returns string the url to the svg api endpoint
*/ */
@function icon-color($icon, $dir, $color, $core: false) { @mixin icon-color($icon, $dir, $color, $core: false) {
// remove # from color // remove # from color
$index: str-index($color, '#'); $index: str-index($color, '#');
@if $index { @if $index {
$color: str-slice($color, 2); $color: str-slice($color, 2);
} }
$varName: "--icon-#{$icon}-#{$color}";
@if $core { @if $core {
@return url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=1'); #{$varName}: url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=1');
} @else {
#{$varName}: url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=1');
} }
@return url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=1'); background-image: var(#{$varName});
} }

View File

@ -118,542 +118,543 @@ img, object, video, button, textarea, input, select, div[contenteditable='true']
/* ICONS ------------------------------------------------------------------- */ /* ICONS ------------------------------------------------------------------- */
.icon-add { .icon-add {
background-image: icon-color('add', 'actions', $color-black, 'core'); @include icon-color('add', 'actions', $color-black, true);
} }
.icon-address { .icon-address {
background-image: icon-color('address', 'actions', $color-black, 'core'); @include icon-color('address', 'actions', $color-black, true);
} }
.icon-address-white { .icon-address-white {
background-image: icon-color('address', 'actions', $color-white, 'core'); @include icon-color('address', 'actions', $color-white, true);
} }
.icon-audio { .icon-audio {
background-image: icon-color('audio', 'actions', $color-black, 'core'); @include icon-color('audio', 'actions', $color-black, true);
} }
.icon-audio-white { .icon-audio-white {
background-image: icon-color('audio', 'actions', $color-white, 'core'); @include icon-color('audio', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-audio-off { .icon-audio-off {
background-image: icon-color('audio-off', 'actions', $color-black, 'core'); @include icon-color('audio-off', 'actions', $color-black, true);
} }
.icon-audio-off-white { .icon-audio-off-white {
background-image: icon-color('audio-off', 'actions', $color-white, 'core'); @include icon-color('audio-off', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-caret-white, .icon-caret-white,
.icon-caret { .icon-caret {
background-image: icon-color('caret', 'actions', $color-white, 'core'); @include icon-color('caret', 'actions', $color-white, true);
} }
.icon-caret-dark { .icon-caret-dark {
background-image: icon-color('caret', 'actions', $color-black, 'core'); @include icon-color('caret', 'actions', $color-black, true);
} }
.icon-checkmark { .icon-checkmark {
background-image: icon-color('checkmark', 'actions', $color-black, 'core'); @include icon-color('checkmark', 'actions', $color-black, true);
} }
.icon-checkmark-white { .icon-checkmark-white {
background-image: icon-color('checkmark', 'actions', $color-white, 'core'); @include icon-color('checkmark', 'actions', $color-white, true);
} }
.icon-checkmark-color { .icon-checkmark-color {
background-image: icon-color('checkmark', 'actions', $color-success, 'core'); @include icon-color('checkmark', 'actions', $color-success, true);
} }
.icon-clippy { .icon-clippy {
background-image: icon-color('clippy', 'actions', $color-black, 'core'); @include icon-color('clippy', 'actions', $color-black, true);
} }
.icon-close { .icon-close {
background-image: icon-color('close', 'actions', $color-black, 'core'); @include icon-color('close', 'actions', $color-black, true);
} }
.icon-close-white { .icon-close-white {
background-image: icon-color('close', 'actions', $color-white, 'core'); @include icon-color('close', 'actions', $color-white, true);
} }
.icon-comment { .icon-comment {
background-image: icon-color('comment', 'actions', $color-black, 'core'); @include icon-color('comment', 'actions', $color-black, true);
} }
.icon-confirm { .icon-confirm {
background-image: icon-color('confirm', 'actions', $color-black, 'core'); @include icon-color('confirm', 'actions', $color-black, true);
} }
.icon-confirm-fade { .icon-confirm-fade {
background-image: icon-color('confirm-fade', 'actions', $color-black, 'core'); @include icon-color('confirm-fade', 'actions', $color-black, true);
} }
.icon-confirm-white { .icon-confirm-white {
background-image: icon-color('confirm', 'actions', $color-white, 'core'); @include icon-color('confirm', 'actions', $color-white, true);
} }
.icon-delete { .icon-delete {
background-image: icon-color('delete', 'actions', $color-black, 'core'); @include icon-color('delete', 'actions', $color-black, true);
&.no-permission { &.no-permission {
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('delete', 'actions', $color-black, 'core'); @include icon-color('delete', 'actions', $color-black, true);
} }
} }
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('delete', 'actions', $color-error, 'core'); @include icon-color('delete', 'actions', $color-error, true);
filter: initial; filter: initial;
} }
} }
.icon-delete-white { .icon-delete-white {
background-image: icon-color('delete', 'actions', $color-white, 'core'); @include icon-color('delete', 'actions', $color-white, true);
&.no-permission { &.no-permission {
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('delete', 'actions', $color-white, 'core'); @include icon-color('delete', 'actions', $color-white, true);
} }
} }
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('delete', 'actions', $color-error, 'core'); @include icon-color('delete', 'actions', $color-error, true);
} }
} }
.icon-details { .icon-details {
background-image: icon-color('details', 'actions', $color-black, 'core'); @include icon-color('details', 'actions', $color-black, true);
} }
.icon-download { .icon-download {
background-image: icon-color('download', 'actions', $color-black, 'core'); @include icon-color('download', 'actions', $color-black, true);
} }
.icon-download-white { .icon-download-white {
background-image: icon-color('download', 'actions', $color-white, 'core'); @include icon-color('download', 'actions', $color-white, true);
} }
.icon-edit { .icon-edit {
background-image: icon-color('edit', 'actions', $color-black, 'core'); @include icon-color('edit', 'actions', $color-black, true);
} }
.icon-error { .icon-error {
background-image: icon-color('error', 'actions', $color-black, 'core'); @include icon-color('error', 'actions', $color-black, true);
} }
.icon-error-white { .icon-error-white {
background-image: icon-color('error', 'actions', $color-white, 'core'); @include icon-color('error', 'actions', $color-white, true);
} }
.icon-error-color { .icon-error-color {
background-image: icon-color('error', 'actions', $color-error, 'core'); @include icon-color('error', 'actions', $color-error, true);
} }
.icon-external { .icon-external {
background-image: icon-color('external', 'actions', $color-black, 'core'); @include icon-color('external', 'actions', $color-black, true);
} }
.icon-fullscreen { .icon-fullscreen {
background-image: icon-color('fullscreen', 'actions', $color-black, 'core'); @include icon-color('fullscreen', 'actions', $color-black, true);
} }
.icon-fullscreen-white { .icon-fullscreen-white {
background-image: icon-color('fullscreen', 'actions', $color-white, 'core'); @include icon-color('fullscreen', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-history { .icon-history {
background-image: icon-color('history', 'actions', $color-black, 'core'); @include icon-color('history', 'actions', $color-black, true);
} }
.icon-info { .icon-info {
background-image: icon-color('info', 'actions', $color-black, 'core'); @include icon-color('info', 'actions', $color-black, true);
} }
.icon-info-white { .icon-info-white {
background-image: icon-color('info', 'actions', $color-white, 'core'); @include icon-color('info', 'actions', $color-white, true);
} }
.icon-logout { .icon-logout {
background-image: icon-color('logout', 'actions', $color-black, 'core'); @include icon-color('logout', 'actions', $color-black, true);
} }
.icon-mail { .icon-mail {
background-image: icon-color('mail', 'actions', $color-black, 'core'); @include icon-color('mail', 'actions', $color-black, true);
} }
.icon-menu { .icon-menu {
background-image: icon-color('menu', 'actions', $color-black, 'core'); @include icon-color('menu', 'actions', $color-black, true);
} }
.icon-more { .icon-more {
background-image: icon-color('more', 'actions', $color-black, 'core'); @include icon-color('more', 'actions', $color-black, true);
} }
.icon-more-white { .icon-more-white {
background-image: icon-color('more', 'actions', $color-white) @include icon-color('more', 'actions', $color-white)
} }
.icon-password { .icon-password {
background-image: icon-color('password', 'actions', $color-black, 'core'); @include icon-color('password', 'actions', $color-black, true);
} }
.icon-pause { .icon-pause {
background-image: icon-color('pause', 'actions', $color-black, 'core'); @include icon-color('pause', 'actions', $color-black, true);
} }
.icon-play { .icon-play {
background-image: icon-color('play', 'actions', $color-black, 'core'); @include icon-color('play', 'actions', $color-black, true);
} }
.icon-play-add { .icon-play-add {
background-image: icon-color('play-add', 'actions', $color-black, 'core'); @include icon-color('play-add', 'actions', $color-black, true);
} }
.icon-play-next { .icon-play-next {
background-image: icon-color('play-next', 'actions', $color-black, 'core'); @include icon-color('play-next', 'actions', $color-black, true);
} }
.icon-play-previous { .icon-play-previous {
background-image: icon-color('play-previous', 'actions', $color-black, 'core'); @include icon-color('play-previous', 'actions', $color-black, true);
} }
.icon-public { .icon-public {
background-image: icon-color('public', 'actions', $color-black, 'core'); @include icon-color('public', 'actions', $color-black, true);
} }
.icon-quota { .icon-quota {
background-image: icon-color('quota', 'actions', $color-black, 'core'); @include icon-color('quota', 'actions', $color-black, true);
} }
.icon-rename { .icon-rename {
background-image: icon-color('rename', 'actions', $color-black, 'core'); @include icon-color('rename', 'actions', $color-black, true);
} }
.icon-screen { .icon-screen {
background-image: icon-color('screen', 'actions', $color-black, 'core'); @include icon-color('screen', 'actions', $color-black, true);
} }
.icon-screen-white { .icon-screen-white {
background-image: icon-color('screen', 'actions', $color-white, 'core'); @include icon-color('screen', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-screen-off { .icon-screen-off {
background-image: icon-color('screen-off', 'actions', $color-black, 'core'); @include icon-color('screen-off', 'actions', $color-black, true);
} }
.icon-screen-off-white { .icon-screen-off-white {
background-image: icon-color('screen-off', 'actions', $color-white, 'core'); @include icon-color('screen-off', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-search { .icon-search {
background-image: icon-color('search', 'actions', $color-black, 'core'); @include icon-color('search', 'actions', $color-black, true);
} }
.icon-search-white { .icon-search-white {
background-image: icon-color('search', 'actions', $color-white, 'core'); @include icon-color('search', 'actions', $color-white, true);
} }
/* default icon have a .5 opacity */ /* default icon have a .5 opacity */
.icon-settings { .icon-settings {
background-image: icon-color('settings', 'actions', $color-black, 'core'); @include icon-color('settings', 'actions', $color-black, true);
} }
.icon-settings-dark { .icon-settings-dark {
background-image: icon-color('settings-dark', 'actions', $color-black, 'core'); @include icon-color('settings-dark', 'actions', $color-black, true);
} }
.icon-settings-white { .icon-settings-white {
background-image: icon-color('settings-dark', 'actions', $color-white, 'core'); @include icon-color('settings-dark', 'actions', $color-white, true);
} }
/* always use icon-shared, AdBlock blocks icon-share */ /* always use icon-shared, AdBlock blocks icon-share */
.icon-shared, .icon-shared,
.icon-share { .icon-share {
background-image: icon-color('share', 'actions', $color-black, 'core'); @include icon-color('share', 'actions', $color-black, true);
} }
.icon-sound { .icon-sound {
background-image: icon-color('sound', 'actions', $color-black, 'core'); @include icon-color('sound', 'actions', $color-black, true);
} }
.icon-sound-off { .icon-sound-off {
background-image: icon-color('sound-off', 'actions', $color-black, 'core'); @include icon-color('sound-off', 'actions', $color-black, true);
} }
.icon-favorite { .icon-favorite {
background-image: icon-color('star-dark', 'actions', $color-black, 'core'); @include icon-color('star-dark', 'actions', $color-black, true);
} }
.icon-star { .icon-star {
background-image: icon-color('star', 'actions', $color-black, 'core'); @include icon-color('star', 'actions', $color-black, true);
} }
.icon-star-dark { .icon-star-dark {
background-image: icon-color('star-dark', 'actions', $color-black, 'core'); @include icon-color('star-dark', 'actions', $color-black, true);
} }
.icon-starred { .icon-starred {
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('star', 'actions', $color-black, 'core'); @include icon-color('star', 'actions', $color-black, true);
} }
background-image: icon-color('starred', 'actions', $color-black, 'core'); @include icon-color('star-dark', 'actions', 'FC0', true);
} }
.icon-star { .icon-star {
&:hover, &:hover,
&:focus { &:focus {
background-image: icon-color('starred', 'actions', $color-black, 'core'); @include icon-color('star-dark', 'actions', 'FC0', true);
} }
} }
.icon-tag { .icon-tag {
background-image: icon-color('tag', 'actions', $color-black, 'core'); @include icon-color('tag', 'actions', $color-black, true);
} }
.icon-timezone { .icon-timezone {
background-image: icon-color('timezone', 'actions', $color-black, 'core'); @include icon-color('timezone', 'actions', $color-black, true);
} }
.icon-toggle { .icon-toggle {
background-image: icon-color('toggle', 'actions', $color-black, 'core'); @include icon-color('toggle', 'actions', $color-black, true);
} }
.icon-toggle-background { .icon-toggle-background {
background-image: icon-color('toggle-background', 'actions', $color-black, 'core'); @include icon-color('toggle-background', 'actions', $color-black, true);
} }
.icon-toggle-pictures { .icon-toggle-pictures {
background-image: icon-color('toggle-pictures', 'actions', $color-black, 'core'); @include icon-color('toggle-pictures', 'actions', $color-black, true);
} }
.icon-triangle-e { .icon-triangle-e {
background-image: icon-color('triangle-e', 'actions', $color-black, 'core'); @include icon-color('triangle-e', 'actions', $color-black, true);
} }
.icon-triangle-n { .icon-triangle-n {
background-image: icon-color('triangle-n', 'actions', $color-black, 'core'); @include icon-color('triangle-n', 'actions', $color-black, true);
} }
.icon-triangle-s { .icon-triangle-s {
background-image: icon-color('triangle-s', 'actions', $color-black, 'core'); @include icon-color('triangle-s', 'actions', $color-black, true);
} }
.icon-upload { .icon-upload {
background-image: icon-color('upload', 'actions', $color-black, 'core'); @include icon-color('upload', 'actions', $color-black, true);
} }
.icon-upload-white { .icon-upload-white {
background-image: icon-color('upload', 'actions', $color-white, 'core'); @include icon-color('upload', 'actions', $color-white, true);
} }
.icon-user { .icon-user {
background-image: icon-color('user', 'actions', $color-black, 'core'); @include icon-color('user', 'actions', $color-black, true);
} }
.icon-video { .icon-video {
background-image: icon-color('video', 'actions', $color-black, 'core'); @include icon-color('video', 'actions', $color-black, true);
} }
.icon-video-white { .icon-video-white {
background-image: icon-color('video', 'actions', $color-white, 'core'); @include icon-color('video', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-video-off { .icon-video-off {
background-image: icon-color('video-off', 'actions', $color-black, 'core'); @include icon-color('video-off', 'actions', $color-black, true);
} }
.icon-video-off-white { .icon-video-off-white {
background-image: icon-color('video-off', 'actions', $color-white, 'core'); @include icon-color('video-off', 'actions', $color-white, true);
filter: drop-shadow(1px 1px 4px var(--color-box-shadow)); filter: drop-shadow(1px 1px 4px var(--color-box-shadow));
} }
.icon-video-switch { .icon-video-switch {
background-image: icon-color('video-switch', 'actions', $color-black, 'core'); @include icon-color('video-switch', 'actions', $color-black, true);
} }
.icon-view-close { .icon-view-close {
background-image: icon-color('view-close', 'actions', $color-black, 'core'); @include icon-color('view-close', 'actions', $color-black, true);
} }
.icon-view-download { .icon-view-download {
background-image: icon-color('view-download', 'actions', $color-black, 'core'); @include icon-color('view-download', 'actions', $color-black, true);
} }
.icon-view-next { .icon-view-next {
background-image: icon-color('arrow-right', 'actions', $color-black, 'core'); @include icon-color('arrow-right', 'actions', $color-black, true);
} }
.icon-view-pause { .icon-view-pause {
background-image: icon-color('view-pause', 'actions', $color-black, 'core'); @include icon-color('view-pause', 'actions', $color-black, true);
} }
.icon-view-play { .icon-view-play {
background-image: icon-color('view-play', 'actions', $color-black, 'core'); @include icon-color('view-play', 'actions', $color-black, true);
} }
.icon-view-previous { .icon-view-previous {
background-image: icon-color('arrow-left', 'actions', $color-black, 'core'); @include icon-color('arrow-left', 'actions', $color-black, true);
} }
.icon-disabled-user { .icon-disabled-user {
background-image: icon-color('disabled-user', 'actions', $color-black, 'core'); @include icon-color('disabled-user', 'actions', $color-black, true);
} }
.icon-disabled-users { .icon-disabled-users {
background-image: icon-color('disabled-users', 'actions', $color-black, 'core'); @include icon-color('disabled-users', 'actions', $color-black, true);
} }
.icon-user-admin { .icon-user-admin {
background-image: icon-color('user-admin', 'actions', $color-black, 'core'); @include icon-color('user-admin', 'actions', $color-black, true);
} }
/* PLACES ------------------------------------------------------------------- */ /* PLACES ------------------------------------------------------------------- */
.icon-calendar { .icon-calendar {
background-image: icon-color('calendar', 'places', $color-white, 'core'); @include icon-color('calendar', 'places', $color-white, true);
} }
.icon-calendar-dark { .icon-calendar-dark {
background-image: icon-color('calendar', 'places', $color-black, 'core'); @include icon-color('calendar', 'places', $color-black, true);
} }
.icon-contacts { .icon-contacts {
background-image: icon-color('contacts', 'places', $color-white, 'core'); @include icon-color('contacts', 'places', $color-white, true);
} }
.icon-contacts-dark { .icon-contacts-dark {
background-image: icon-color('contacts', 'places', $color-black, 'core'); @include icon-color('contacts', 'places', $color-black, true);
} }
.icon-files { .icon-files {
background-image: icon-color('files', 'places', $color-white, 'core'); @include icon-color('files', 'places', $color-white, true);
} }
.icon-files-dark { .icon-files-dark {
background-image: icon-color('files', 'places', $color-black, 'core'); @include icon-color('files', 'places', $color-black, true);
} }
.icon-file, .icon-file,
.icon-filetype-text { .icon-filetype-text {
background-image: icon-color('text', 'filetypes', $color-black, 'core'); @include icon-color('text', 'filetypes', $color-black, true);
} }
.icon-folder, .icon-folder,
.icon-filetype-folder { .icon-filetype-folder {
background-image: icon-color('folder', 'filetypes', $color-black, 'core'); @include icon-color('folder', 'filetypes', $color-black, true);
} }
.icon-filetype-folder-drag-accept { .icon-filetype-folder-drag-accept {
background-image: icon-color('folder-drag-accept', 'filetypes', $color-black) !important; @include icon-color('folder-drag-accept', 'filetypes', $color-black);
} }
.icon-home { .icon-home {
background-image: icon-color('home', 'places', $color-black, 'core'); @include icon-color('home', 'places', $color-black, true);
} }
.icon-link { .icon-link {
background-image: icon-color('link', 'places', $color-black, 'core'); @include icon-color('link', 'places', $color-black, true);
} }
.icon-music { .icon-music {
background-image: icon-color('music', 'places', $color-black, 'core'); @include icon-color('music', 'places', $color-black, true);
} }
.icon-picture { .icon-picture {
background-image: icon-color('picture', 'places', $color-black, 'core'); @include icon-color('picture', 'places', $color-black, true);
} }
/* CLIENTS ------------------------------------------------------------------- */ /* CLIENTS ------------------------------------------------------------------- */
.icon-desktop { .icon-desktop {
background-image: icon-color('desktop', 'clients', $color-black, 'core'); @include icon-color('desktop', 'clients', $color-black, true);
} }
.icon-phone { .icon-phone {
background-image: icon-color('phone', 'clients', $color-black, 'core'); @include icon-color('phone', 'clients', $color-black, true);
} }
.icon-tablet { .icon-tablet {
background-image: icon-color('tablet', 'clients', $color-black, 'core'); @include icon-color('tablet', 'clients', $color-black, true);
} }
/* APP CATEGORIES ------------------------------------------------------------------- */ /* APP CATEGORIES ------------------------------------------------------------------- */
.icon-category-installed { .icon-category-installed {
background-image: icon-color('user', 'actions', $color-black, 'core'); @include icon-color('user', 'actions', $color-black, true);
} }
.icon-category-enabled { .icon-category-enabled {
background-image: icon-color('checkmark', 'actions', $color-black, 'core'); @include icon-color('checkmark', 'actions', $color-black, true);
} }
.icon-category-disabled { .icon-category-disabled {
background-image: icon-color('close', 'actions', $color-black, 'core'); @include icon-color('close', 'actions', $color-black, true);
} }
.icon-category-app-bundles { .icon-category-app-bundles {
background-image: icon-color('bundles', 'categories', $color-black, 'core'); @include icon-color('bundles', 'categories', $color-black, true);
} }
.icon-category-updates { .icon-category-updates {
background-image: icon-color('download', 'actions', $color-black, 'core'); @include icon-color('download', 'actions', $color-black, true);
} }
.icon-category-files { .icon-category-files {
background-image: icon-color('files', 'categories', $color-black, 'core'); @include icon-color('files', 'categories', $color-black, true);
} }
.icon-category-social { .icon-category-social {
background-image: icon-color('social', 'categories', $color-black, 'core'); @include icon-color('social', 'categories', $color-black, true);
} }
.icon-category-office { .icon-category-office {
background-image: icon-color('office', 'categories', $color-black, 'core'); @include icon-color('office', 'categories', $color-black, true);
} }
.icon-category-auth { .icon-category-auth {
background-image: icon-color('auth', 'categories', $color-black, 'core'); @include icon-color('auth', 'categories', $color-black, true);
} }
.icon-category-monitoring { .icon-category-monitoring {
background-image: icon-color('monitoring', 'categories', $color-black, 'core'); @include icon-color('monitoring', 'categories', $color-black, true);
} }
.icon-category-multimedia { .icon-category-multimedia {
background-image: icon-color('multimedia', 'categories', $color-black, 'core'); @include icon-color('multimedia', 'categories', $color-black, true);
} }
.icon-category-organization { .icon-category-organization {
background-image: icon-color('organization', 'categories', $color-black, 'core'); @include icon-color('organization', 'categories', $color-black, true);
} }
.icon-category-customization { .icon-category-customization {
background-image: icon-color('customization', 'categories', $color-black, 'core'); @include icon-color('customization', 'categories', $color-black, true);
} }
.icon-category-integration { .icon-category-integration {
background-image: icon-color('integration', 'categories', $color-black, 'core'); @include icon-color('integration', 'categories', $color-black, true);
} }
.icon-category-tools { .icon-category-tools {
background-image: icon-color('settings-dark', 'actions', $color-black, 'core'); @include icon-color('settings-dark', 'actions', $color-black, true);
} }
.icon-category-games { .icon-category-games {
background-image: icon-color('games', 'categories', $color-black, 'core'); @include icon-color('games', 'categories', $color-black, true);
} }
.icon-category-security { .icon-category-security {
background-image: icon-color('password', 'actions', $color-black, 'core'); @include icon-color('password', 'actions', $color-black, true);
} }
.icon-category-search { .icon-category-search {
background-image: icon-color('search', 'actions', $color-black, 'core'); @include icon-color('search', 'actions', $color-black, true);
} }

View File

@ -50,8 +50,8 @@ $color-error: #e9322d;
$color-warning: #eca700; $color-warning: #eca700;
$color-success: #46ba61; $color-success: #46ba61;
// used for svg // used for svg
$color-white: #fff !default; $color-white: #fff;
$color-black: #000 !default; $color-black: #000;
// rgb(118, 118, 118) / #767676 // rgb(118, 118, 118) / #767676
// min. color contrast for normal text on white background according to WCAG AA // min. color contrast for normal text on white background according to WCAG AA

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 16 16" width="16" height="16"><path fill="#FC0" d="m8 0.5 2.2 5.3 5.8 0.45-4.5 3.75 1.5 5.5-5-3.1-5 3.1 1.5-5.5-4.5-3.75 5.8-0.45z"/></svg>

Before

Width:  |  Height:  |  Size: 207 B

View File

@ -90,7 +90,7 @@ class Group implements IGroup {
public function getDisplayName() { public function getDisplayName() {
if (is_null($this->displayName)) { if (is_null($this->displayName)) {
return $this->gid; return $this->gid.'-name';
} }
return $this->displayName; return $this->displayName;
} }

View File

@ -0,0 +1,138 @@
<?php
/**
* @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
*
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
*
* @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/>.
*
*/
namespace OC\Template;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\ILogger;
use OCP\IURLGenerator;
use OC\Files\AppData\Factory;
class IconsCacher {
/** @var ILogger */
protected $logger;
/** @var IAppData */
protected $appData;
/** @var ISimpleFolder */
private $folder;
/** @var IURLGenerator */
protected $urlGenerator;
/** @var string */
private $iconVarRE = '/--([a-z-]+): url\("([a-z0-9-\/]+)[^;]+;/m';
/** @var string */
private $fileName = 'icons-vars.css';
/**
* @param ILogger $logger
* @param Factory $appDataFactory
* @param IURLGenerator $urlGenerator
*/
public function __construct(ILogger $logger,
Factory $appDataFactory,
IURLGenerator $urlGenerator) {
$this->logger = $logger;
$this->appData = $appDataFactory->get('css');
$this->urlGenerator = $urlGenerator;
try {
$this->folder = $this->appData->getFolder('icons');
} catch (NotFoundException $e) {
$this->folder = $this->appData->newFolder('icons');
}
}
private function getIconsFromCss(string $css): array{
preg_match_all($this->iconVarRE, $css, $matches, PREG_SET_ORDER);
$icons = [];
foreach ($matches as $icon) {
$icons[$icon[1]] = $icon[2];
}
return $icons;
}
/**
* Parse and cache css
*
* @param string $css
*/
public function setIconsCss(string $css) {
try {
$data = $this->folder->getFile($this->fileName)->getContent();
} catch (NotFoundException $e) {
$data = '';
}
$icons = $this->getIconsFromCss($data . $css);
$data = '';
foreach ($icons as $icon => $url) {
$data .= "--$icon: url('$url?v=1');";
}
if (strlen($data) > 0) {
try {
$cachedfile = $this->folder->getFile($this->fileName);
} catch (NotFoundException $e) {
$cachedfile = $this->folder->newFile($this->fileName);
}
$data = ":root {
$data
}";
$cachedfile->putContent($data);
}
return preg_replace($this->iconVarRE, '', $css);
}
/**
* Get icons css file
* @return ISimpleFile|boolean
*/
public function getCachedCSS() {
try {
return $this->folder->getFile($this->fileName);
} catch (NotFoundException $e) {
return false;
}
}
public function injectCss() {
// Only inject once
foreach (\OC_Util::$headers as $header) {
if (strpos($header['attributes']['href'], $this->fileName) !== false) {
return;
}
}
$linkToCSS = substr($this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName]), strlen(\OC::$WEBROOT));
\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
}
}

View File

@ -32,7 +32,6 @@ use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Exception\ParserException; use Leafo\ScssPhp\Exception\ParserException;
use Leafo\ScssPhp\Formatter\Crunched; use Leafo\ScssPhp\Formatter\Crunched;
use Leafo\ScssPhp\Formatter\Expanded; use Leafo\ScssPhp\Formatter\Expanded;
use OC\Files\AppData\Factory;
use OCP\Files\IAppData; use OCP\Files\IAppData;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException; use OCP\Files\NotPermittedException;
@ -43,6 +42,8 @@ use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OC\Files\AppData\Factory;
use OC\Template\IconsCacher;
class SCSSCacher { class SCSSCacher {
@ -73,6 +74,9 @@ class SCSSCacher {
/** @var ICacheFactory */ /** @var ICacheFactory */
private $cacheFactory; private $cacheFactory;
/** @var IconsCacher */
private $iconsCacher;
/** /**
* @param ILogger $logger * @param ILogger $logger
* @param Factory $appDataFactory * @param Factory $appDataFactory
@ -97,6 +101,12 @@ class SCSSCacher {
$this->serverRoot = $serverRoot; $this->serverRoot = $serverRoot;
$this->cacheFactory = $cacheFactory; $this->cacheFactory = $cacheFactory;
$this->depsCache = $cacheFactory->createDistributed('SCSS-' . md5($this->urlGenerator->getBaseUrl())); $this->depsCache = $cacheFactory->createDistributed('SCSS-' . md5($this->urlGenerator->getBaseUrl()));
$this->iconsCacher = new IconsCacher(
$this->logger,
$appDataFactory,
$this->urlGenerator
);
} }
/** /**
@ -119,16 +129,27 @@ class SCSSCacher {
try { try {
$folder = $this->appData->getFolder($app); $folder = $this->appData->getFolder($app);
} catch(NotFoundException $e) { } catch (NotFoundException $e) {
// creating css appdata folder // creating css appdata folder
$folder = $this->appData->newFolder($app); $folder = $this->appData->newFolder($app);
} }
if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) {
if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) { // Inject icons vars css if any
if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) {
$this->iconsCacher->injectCss();
}
return true; return true;
} }
return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
$cached = $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
// Inject icons vars css if any
if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) {
$this->iconsCacher->injectCss();
}
return $cached;
} }
/** /**
@ -139,6 +160,7 @@ class SCSSCacher {
public function getCachedCSS(string $appName, string $fileName): ISimpleFile { public function getCachedCSS(string $appName, string $fileName): ISimpleFile {
$folder = $this->appData->getFolder($appName); $folder = $this->appData->getFolder($appName);
$cachedFileName = $this->prependVersionPrefix($this->prependBaseurlPrefix($fileName), $appName); $cachedFileName = $this->prependVersionPrefix($this->prependBaseurlPrefix($fileName), $appName);
return $folder->getFile($cachedFileName); return $folder->getFile($cachedFileName);
} }
@ -162,15 +184,17 @@ class SCSSCacher {
} }
$deps = json_decode($deps, true); $deps = json_decode($deps, true);
foreach ((array)$deps as $file=>$mtime) { foreach ((array) $deps as $file => $mtime) {
if (!file_exists($file) || filemtime($file) > $mtime) { if (!file_exists($file) || filemtime($file) > $mtime) {
return false; return false;
} }
} }
return true; return true;
} }
return false; return false;
} catch(NotFoundException $e) { } catch (NotFoundException $e) {
return false; return false;
} }
} }
@ -181,11 +205,13 @@ class SCSSCacher {
*/ */
private function variablesChanged(): bool { private function variablesChanged(): bool {
$injectedVariables = $this->getInjectedVariables(); $injectedVariables = $this->getInjectedVariables();
if($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { if ($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) {
$this->resetCache(); $this->resetCache();
$this->config->setAppValue('core', 'scss.variables', md5($injectedVariables)); $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables));
return true; return true;
} }
return false; return false;
} }
@ -204,11 +230,12 @@ class SCSSCacher {
$scss = new Compiler(); $scss = new Compiler();
$scss->setImportPaths([ $scss->setImportPaths([
$path, $path,
$this->serverRoot . '/core/css/', $this->serverRoot . '/core/css/'
]); ]);
// Continue after throw // Continue after throw
$scss->setIgnoreErrors(true); $scss->setIgnoreErrors(true);
if($this->config->getSystemValue('debug')) { if ($this->config->getSystemValue('debug')) {
// Debug mode // Debug mode
$scss->setFormatter(Expanded::class); $scss->setFormatter(Expanded::class);
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS); $scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
@ -219,7 +246,7 @@ class SCSSCacher {
try { try {
$cachedfile = $folder->getFile($fileNameCSS); $cachedfile = $folder->getFile($fileNameCSS);
} catch(NotFoundException $e) { } catch (NotFoundException $e) {
$cachedfile = $folder->newFile($fileNameCSS); $cachedfile = $folder->newFile($fileNameCSS);
} }
@ -233,16 +260,20 @@ class SCSSCacher {
// Compile // Compile
try { try {
$compiledScss = $scss->compile( $compiledScss = $scss->compile(
'$webroot: \'' . \OC::$WEBROOT. '\';'. '$webroot: \'' . \OC::$WEBROOT . '\';' .
'@import "functions.scss";' .
'@import "variables.scss";' . '@import "variables.scss";' .
'@import "functions.scss";' .
$this->getInjectedVariables() . $this->getInjectedVariables() .
'@import "'.$fileNameSCSS.'";'); '@import "' . $fileNameSCSS . '";');
} catch(ParserException $e) { } catch (ParserException $e) {
$this->logger->error($e, ['app' => 'core']); $this->logger->error($e, ['app' => 'core']);
return false; return false;
} }
// Parse Icons and create related css variables
$compiledScss = $this->iconsCacher->setIconsCss($compiledScss);
// Gzip file // Gzip file
try { try {
$gzipFile = $folder->getFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz $gzipFile = $folder->getFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz
@ -257,10 +288,12 @@ class SCSSCacher {
$depFile->putContent($deps); $depFile->putContent($deps);
$this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps);
$gzipFile->putContent(gzencode($data, 9)); $gzipFile->putContent(gzencode($data, 9));
$this->logger->debug('SCSSCacher: '.$webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); $this->logger->debug('SCSSCacher: ' . $webDir . '/' . $fileNameSCSS . ' compiled and successfully cached', ['app' => 'core']);
return true; return true;
} catch(NotPermittedException $e) { } catch (NotPermittedException $e) {
$this->logger->error('SCSSCacher: unable to cache: ' . $fileNameSCSS); $this->logger->error('SCSSCacher: unable to cache: ' . $fileNameSCSS);
return false; return false;
} }
} }
@ -277,7 +310,7 @@ class SCSSCacher {
foreach ($folder->getDirectoryListing() as $file) { foreach ($folder->getDirectoryListing() as $file) {
try { try {
$file->delete(); $file->delete();
} catch(NotPermittedException $e) { } catch (NotPermittedException $e) {
$this->logger->logException($e, ['message' => 'SCSSCacher: unable to delete file: ' . $file->getName()]); $this->logger->logException($e, ['message' => 'SCSSCacher: unable to delete file: ' . $file->getName()]);
} }
} }
@ -316,7 +349,8 @@ class SCSSCacher {
*/ */
private function rebaseUrls(string $css, string $webDir): string { private function rebaseUrls(string $css, string $webDir): string {
$re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
$subst = 'url(\''.$webDir.'/$1\')'; $subst = 'url(\'' . $webDir . '/$1\')';
return preg_replace($re, $subst, $css); return preg_replace($re, $subst, $css);
} }
@ -341,6 +375,7 @@ class SCSSCacher {
*/ */
private function prependBaseurlPrefix(string $cssFile): string { private function prependBaseurlPrefix(string $cssFile): string {
$frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); $frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 4) . '-' . $cssFile; return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 4) . '-' . $cssFile;
} }
@ -356,6 +391,7 @@ class SCSSCacher {
return substr(md5($appVersion), 0, 4) . '-' . $cssFile; return substr(md5($appVersion), 0, 4) . '-' . $cssFile;
} }
$coreVersion = \OC_Util::getVersionString(); $coreVersion = \OC_Util::getVersionString();
return substr(md5($coreVersion), 0, 4) . '-' . $cssFile; return substr(md5($coreVersion), 0, 4) . '-' . $cssFile;
} }
@ -369,12 +405,14 @@ class SCSSCacher {
*/ */
private function getWebDir(string $path, string $appName, string $serverRoot, string $webRoot): string { private function getWebDir(string $path, string $appName, string $serverRoot, string $webRoot): string {
// Detect if path is within server root AND if path is within an app path // Detect if path is within server root AND if path is within an app path
if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) { if (strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
// Get the file path within the app directory // Get the file path within the app directory
$appDirectoryPath = explode($appName, $path)[1]; $appDirectoryPath = explode($appName, $path)[1];
// Remove the webroot // Remove the webroot
return str_replace($webRoot, '', $appWebPath.$appDirectoryPath);
return str_replace($webRoot, '', $appWebPath . $appDirectoryPath);
} }
return $webRoot.substr($path, strlen($serverRoot));
return $webRoot . substr($path, strlen($serverRoot));
} }
} }

View File

@ -15,23 +15,23 @@ input {
/* icons for sidebar */ /* icons for sidebar */
.nav-icon-personal-settings { .nav-icon-personal-settings {
background-image: icon-color('personal', 'settings', $color-black); @include icon-color('personal', 'settings', $color-black);
} }
.nav-icon-security { .nav-icon-security {
background-image: icon-color('toggle-filelist', 'settings', $color-black); @include icon-color('toggle-filelist', 'settings', $color-black);
} }
.nav-icon-clientsbox { .nav-icon-clientsbox {
background-image: icon-color('change', 'settings', $color-black); @include icon-color('change', 'settings', $color-black);
} }
.nav-icon-federated-cloud { .nav-icon-federated-cloud {
background-image: icon-color('share', 'settings', $color-black); @include icon-color('share', 'settings', $color-black);
} }
.nav-icon-second-factor-backup-codes, .nav-icon-ssl-root-certificate { .nav-icon-second-factor-backup-codes, .nav-icon-ssl-root-certificate {
background-image: icon-color('password', 'settings', $color-black); @include icon-color('password', 'settings', $color-black);
} }
#avatarform { #avatarform {