Skip to content

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

Closed
jonathanmmm wants to merge 4 commits into
nextcloud:masterfrom
jonathanmmm:feature/allow_overriding_prefers-color-scheme
Closed

allow to override prefers-color-scheme via url param for guests#29940
jonathanmmm wants to merge 4 commits into
nextcloud:masterfrom
jonathanmmm:feature/allow_overriding_prefers-color-scheme

Conversation

@jonathanmmm

Copy link
Copy Markdown

using ?force-color-scheme=light should make the theme light and ?force-color-scheme=dark should make it dark.
Useful for iframes to match a website theme and to send a specific theme to a guest.

I couldn't test it locally, as it seems that javascript is somehow like compiled (and the src folder is missing for example) and have no developer setup. If needed, I can set one up.

My first pull request to nextcloud, if you have feedback how to make it better next time, tell me.

@jonathanmmm

Copy link
Copy Markdown
Author

Could solve this issue: #29699

@szaimen

Copy link
Copy Markdown
Contributor

/compile amend /

@szaimenszaimen added this to the Nextcloud 24 milestone Nov 27, 2021
using ?force-color-scheme=light should make the theme light and ?force-color-scheme=dark should make it dark.
Useful for iframes to match a website theme and to send a specific theme to a guest.
Signed-off-by: jonathanmmm <32403139+jonathanmmm@users.noreply.github.com>
@jonathanmmm

Copy link
Copy Markdown
Author

Ok, somehow it doesn't do anything.
Seems to be that /server/apps/accessibility/lib/AppInfo/Application.php
`$userValues = ['dark'];

 $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');`

If I put into the third line light instead of dark it changes to light theme.
Testing in incognito mode.

Does somebody know, if accessibilityoca.js in src has to be compiled and lands then in the js folder?

Don't know how these js files with the super long lines work, are they compiled or do I have to change them too?

This pull and commit seem to made prefer-color-scheme possible in the first place https://github.com/nextcloud/server/pull/21366/files
ede5db1

@jonathanmmm
jonathanmmm marked this pull request as draft November 27, 2021 16:50
Comment threadapps/accessibility/src/accessibilityoca.js Outdated
@jonathanmmm

Copy link
Copy Markdown
Author

@CarlSchwan If you have motivation+time, we could takle this feature together.

@jonathanmmm

jonathanmmm commented Dec 4, 2021

Copy link
Copy Markdown
Author

Research:

2916402
override these changes in the commit if url parameter is given
line 75-82: https://github.com/nextcloud/server/blob/master/apps/accessibility/lib/AppInfo/Application.php
line 113-117: https://github.com/nextcloud/server/blob/master/apps/accessibility/lib/Controller/AccessibilityController.php

and change it so that line 27-30 the value in line 29 is not changed if url parameter is given
https://github.com/nextcloud/server/blob/master/apps/accessibility/src/accessibilityoca.js

@jonathanmmm

Copy link
Copy Markdown
Author

@CarlSchwan It is working now when dark mode is enabled in the system (forcing light mode), but not the other way around and I don't know. I even tried and replaced every theme--light string I could find under accessibility and replaced it with theme--dark, still light mode.

@skjnldsvskjnldsv mentioned this pull request Mar 24, 2022
@blizzzblizzz mentioned this pull request Mar 31, 2022
This was referenced Apr 7, 2022
@blizzzblizzz modified the milestones: Nextcloud 24, Nextcloud 25Apr 21, 2022
This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
This was referenced Sep 6, 2022
@skjnldsvskjnldsv mentioned this pull request Sep 15, 2022
This was referenced Sep 20, 2022
@blizzzblizzz modified the milestones: Nextcloud 25, Nextcloud 26Sep 22, 2022
@blizzzblizzz mentioned this pull request Feb 1, 2023
@skjnldsvskjnldsv mentioned this pull request Feb 23, 2023
@blizzzblizzz mentioned this pull request Mar 7, 2023
@blizzzblizzz modified the milestones: Nextcloud 26, Nextcloud 27Mar 9, 2023
This was referenced May 3, 2023
@skjnldsvskjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzzblizzz modified the milestones: Nextcloud 28, Nextcloud 29Nov 23, 2023
@skjnldsvskjnldsv added the 2. developing Work in progress label Feb 21, 2024
@skjnldsvskjnldsv removed this from the Nextcloud 29 milestone Feb 27, 2024
@skjnldsv

Copy link
Copy Markdown
Member

As there is no feedback since a while I will close this ticket.
If you will decide to work on this feature again and if it hasn't been fixed or implemented already, feel free to re-open and solve the various conflicts.

Thanks for the interest in Nextcloud and the effort put into this! 🙇

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jonathanmmm@szaimen@skjnldsv@CarlSchwan@blizzz