Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to override prefers-color-scheme via url param for guests #29940

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions apps/accessibility/src/accessibilityoca.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@
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
// Force a specific theme for guests based on force-color-scheme param
var srv_url = new URL(window.location.href)
var force_color_scheme = srv_url.searchParams.get("force-color-scheme")
if(force_color_scheme !== null) {
if(force_color_scheme=="dark") {
OCA.Accessibility.theme = 'dark'
}
else {
OCA.Accessibility.theme = 'light'
}
}
else if (OCA.Accessibility.checkMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
CarlSchwan marked this conversation as resolved.
Show resolved Hide resolved
// Overwrite the theme for guests based on the prefers-color-scheme
OCA.Accessibility.theme = 'dark'
}

Expand Down