zyachel / quetre

A libre front-end for Quora
https://quetre.iket.me
GNU Affero General Public License v3.0
418 stars 28 forks source link

Automatic theme switching doesn't work with JS disabled #11

Closed bbhtt closed 1 year ago

bbhtt commented 2 years ago

Hi, it'd be great to have support for automatic dark/light mode switching based on system/browser theme with prefers-color-scheme

This would be in addition to the theme button on top.

zyachel commented 2 years ago

it does follow system theme.

here's the relevant code:

moreover it also applies theme colours in the URL bar: https://github.com/zyachel/quetre/blob/e9b9c76aa2234d4c3842253d2a49495b0a2f3b79/views/pug/base.pug#L17-L18

in action:

https://user-images.githubusercontent.com/97783235/175810568-3357cc28-a315-4748-bd18-29fc4e764701.mp4


perhaps you're using a hardened browser(eg: librewolf or firefox with tweaks)?
In those cases, the browser doesn't reveal system theme.

Or maybe you've toggled theme with the button once?
Because if that's the case, your theme preference will be stored in local storage. And next time you visit the website, your toggled preference will be applied, regardless of your system theme.

bbhtt commented 2 years ago

perhaps you're using a hardened browser(eg: librewolf or firefox with tweaks)? In those cases, the browser doesn't reveal system theme.

No regular Firefox Nightly, no additional config tweaks.

Or maybe you've toggled theme with the button once?

I clear browser data on quit so that shouldn't be an issue.

when JS is disabled:

It seems to be working only when I disable JS; if JS is enabled it is defaulting to the light theme irrespective of my system theme. Here is a video with Firefox Nightly on Android (with JS enabled, then the theme button and lastly with JS disabled), I can see the same behavior with Nightly on desktop.

https://user-images.githubusercontent.com/62639087/175812346-d4361299-23d3-4372-b0aa-8f79b8fff615.mp4

zyachel commented 2 years ago

I can sort of guess why it is not working.
In index.js, browser preference is being checked before user preference.
I'll fix it tomorrow!

zyachel commented 2 years ago

will only be able to fix it once I get time. a bit busy for some weeks.