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

Conversation

jonathanmmm
Copy link

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
Author

Could solve this issue: #29699

@szaimen
Copy link
Contributor

szaimen commented Nov 27, 2021

/compile amend /

@szaimen szaimen 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
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
@jonathanmmm
Copy link
Author

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

@jonathanmmm
Copy link
Author

jonathanmmm commented Dec 4, 2021

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
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.

@skjnldsv skjnldsv mentioned this pull request Mar 24, 2022
@blizzz blizzz mentioned this pull request Mar 31, 2022
This was referenced Apr 7, 2022
@blizzz blizzz modified the milestones: Nextcloud 24, Nextcloud 25 Apr 21, 2022
This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
This was referenced Sep 6, 2022
@skjnldsv skjnldsv mentioned this pull request Sep 15, 2022
This was referenced Sep 20, 2022
@blizzz blizzz modified the milestones: Nextcloud 25, Nextcloud 26 Sep 22, 2022
@blizzz blizzz mentioned this pull request Feb 1, 2023
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@blizzz blizzz mentioned this pull request Mar 7, 2023
@blizzz blizzz modified the milestones: Nextcloud 26, Nextcloud 27 Mar 9, 2023
This was referenced May 3, 2023
@skjnldsv skjnldsv modified the milestones: Nextcloud 27, Nextcloud 28 May 9, 2023
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
@skjnldsv skjnldsv added the 2. developing Work in progress label Feb 21, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 29 milestone Feb 27, 2024
@skjnldsv
Copy link
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! 🙇

@skjnldsv skjnldsv closed this Feb 27, 2024
Sign up for free to 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