summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-08-15 10:42:40 +0200
committerGitHub <noreply@github.com>2018-08-15 10:42:40 +0200
commit52995a017599e286aafc4ef55425cd55179eee3d (patch)
tree6c3b678a8fdcfbbce3c36d4778fde1d836cc3648
parent6ed87c0c6bd64debf7e7bbe39b7c704e573baa1a (diff)
parenta7c426aa5cce521b44c24d245b816f60e7806c53 (diff)
downloadnextcloud-server-52995a017599e286aafc4ef55425cd55179eee3d.tar.gz
nextcloud-server-52995a017599e286aafc4ef55425cd55179eee3d.zip
Merge pull request #10689 from nextcloud/darktheme-theming-fixes
Add default theming into accessibility compiler
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
index 4ee88b90a7a..0a1d091d1c5 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -70,6 +70,12 @@ class AccessibilityController extends Controller {
/** @var IconsCacher */
protected $iconsCacher;
+ /** @var \OC_Defaults */
+ private $defaults;
+
+ /** @var null|string */
+ private $injectedVariables;
+
/**
* Account constructor.
*
@@ -82,6 +88,7 @@ class AccessibilityController extends Controller {
* @param ITimeFactory $timeFactory
* @param IUserSession $userSession
* @param IAppManager $appManager
+ * @param \OC_Defaults $defaults
*/
public function __construct(string $appName,
IRequest $request,
@@ -92,7 +99,8 @@ class AccessibilityController extends Controller {
ITimeFactory $timeFactory,
IUserSession $userSession,
IAppManager $appManager,
- IconsCacher $iconsCacher) {
+ IconsCacher $iconsCacher,
+ \OC_Defaults $defaults) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->config = $config;
@@ -103,6 +111,7 @@ class AccessibilityController extends Controller {
$this->userSession = $userSession;
$this->appManager = $appManager;
$this->iconsCacher = $iconsCacher;
+ $this->defaults = $defaults;
$this->serverRoot = \OC::$SERVERROOT;
$this->appRoot = $this->appManager->getAppPath($this->appName);
@@ -141,6 +150,7 @@ class AccessibilityController extends Controller {
$css .= $scss->compile(
$imports .
'@import "variables.scss";' .
+ $this->getInjectedVariables() .
'@import "css-variables.scss";'
);
} catch (ParserException $e) {
@@ -220,4 +230,27 @@ class AccessibilityController extends Controller {
private function invertSvgIconsColor(string $css) {
return str_replace(['/000', '/fff', '/***'], ['/***', '/000', '/fff'], $css);
}
+
+ /**
+ * @return string SCSS code for variables from OC_Defaults
+ */
+ private function getInjectedVariables(): string {
+ if ($this->injectedVariables !== null) {
+ return $this->injectedVariables;
+ }
+ $variables = '';
+ foreach ($this->defaults->getScssVariables() as $key => $value) {
+ $variables .= '$' . $key . ': ' . $value . ';';
+ }
+
+ // check for valid variables / otherwise fall back to defaults
+ try {
+ $scss = new Compiler();
+ $scss->compile($variables);
+ $this->injectedVariables = $variables;
+ } catch (ParserException $e) {
+ $this->logger->error($e, ['app' => 'core']);
+ }
+ return $variables;
+ }
}