ArtemPchela / dark-mode-ts

Dark mode React Vite TypeScript
https://www.npmjs.com/package/dark-mode-ts
MIT License
1 stars 0 forks source link

DarkMode behaves weird when computers system pref is set to dark mode #1

Open MathiasGretland opened 1 month ago

MathiasGretland commented 1 month ago

^^ Title

Whenever the localStorage key is not set react-library-playground-theme (not set the first time you enter the site), then some colors are off if the system pref is set to dark mode.

This seems to only be related to the icons, so we might have to look for a better way to check isDarkModeSet in ThemeProviderUtils as this only checks for the localStorage key and not for the prefers-color-scheme (which most likely here is set to "light". Example illustration to check this would be to have a console log, like:

console.log(Window.matchMedia("(prefers-color-scheme: light)")

See screenshot for illustration: Screenshot 2024-07-21 at 23 33 29

ArtemPchela commented 1 month ago

^^ Title

Whenever the localStorage key is not set react-library-playground-theme (not set the first time you enter the site), then some colors are off if the system pref is set to dark mode.

This seems to only be related to the icons, so we might have to look for a better way to check isDarkModeSet in ThemeProviderUtils as this only checks for the localStorage key and not for the prefers-color-scheme (which most likely here is set to "light". Example illustration to check this would be to have a console log, like:

console.log(Window.matchMedia("(prefers-color-scheme: light)")

See screenshot for illustration: Screenshot 2024-07-21 at 23 33 29

Thank you for your detailed observation and suggestion! I appreciate that.