Fix accessibility theme for guests

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/27889/head
Joas Schilling 3 years ago committed by backportbot[bot]
parent 0e90199f1d
commit 2b122fbcf0

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -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');
}
}
}

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

@ -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 {

Loading…
Cancel
Save