Signed-off-by: Joas Schilling <coding@schilljs.com>tags/v23.0.0beta1
@@ -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 { |