Fix accessibility theme for guests

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-07-09 09:21:58 +02:00 committed by backportbot[bot]
parent 0e90199f1d
commit 2b122fbcf0
5 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -78,6 +78,7 @@ class Application extends App implements IBootstrap {
$hash = md5(implode('-', $userValues));
$linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]);
\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]);
\OCP\Util::addScript('accessibility', 'accessibilityoca');
}
}
}

View file

@ -60,6 +60,7 @@ class JSDataService extends InitialStateProvider {
}
return [
'checkMedia' => $user === null,
'theme' => $theme,
'highcontrast' => $highcontrast,
];

View file

@ -24,6 +24,11 @@
import { loadState } from '@nextcloud/initial-state'
OCA.Accessibility = loadState('accessibility', 'data')
if (OCA.Accessibility.checkMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// Overwrite the theme for Guests based on the prefers-color-scheme
OCA.Accessibility.theme = 'dark'
}
if (OCA.Accessibility.theme !== false) {
document.body.classList.add(`theme--${OCA.Accessibility.theme}`)
} else {