Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

enhancement(switcher): implementing dark-light switcher for remote #398

Merged
merged 1 commit into from
Oct 10, 2019
Merged

enhancement(switcher): implementing dark-light switcher for remote #398

merged 1 commit into from
Oct 10, 2019

Conversation

grantlouisherman
Copy link
Contributor

hey @peterpeterparker let me know what you think.

@peterpeterparker
Copy link
Contributor

@grantlouisherman really cool!

before merging (the switcher itself looks neat 👍 ) I have just have one request, if you allow me.

instead of defining a new .dark style, could you use the already defined default dark mode (defined with @media (prefers-color-scheme: dark)) ?

@grantlouisherman
Copy link
Contributor Author

Hey @peterpeterparker so it doesn't seem like I can set media types with js, but I can add something that if that media exist to set the toggle to dark. Unless you know of a way to set a media with js? I just couldn't find a way. It seemed like all the material I read was more for detecting if that media preference existed as opposed to setting one

@peterpeterparker
Copy link
Contributor

@grantlouisherman I'll have a look tomorrow morning and will keep you posted

@grantlouisherman
Copy link
Contributor Author

grantlouisherman commented Oct 8, 2019

This is what I found in terms of interaction with media queries: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList

It seems like you can add listeners or remove listeners, but you cant specifically add a media query via the DOM api. One example I saw was to create a separate style sheet with the preferred media behavior and inject that into the DOM , but I think that is over engineering the problem.

Let me know what you find.

@peterpeterparker
Copy link
Contributor

@grantlouisherman I think the media query listener is probably the way. When the app load, we should check the current state if dark or light and then if dark, set the .dark as you do in your PR. Of course only if the user didn't already selected a style using the toggler.

Then, to finish the transformation, we should move the current css from @media (prefers-color-scheme: dark) to .dark

So basically we only use the prefers-color-scheme to test the platform preferences but to apply the css we use .dark.

Does that make sense you think?

@peterpeterparker peterpeterparker added enhancement New feature or request hacktoberfest-accepted Good for Hacktoberfest remote Remote control labels Oct 10, 2019
@peterpeterparker peterpeterparker merged commit 26a9fb4 into deckgo:master Oct 10, 2019
@peterpeterparker
Copy link
Contributor

Awesome @grantlouisherman 👍 Thx a lot for the amazing work 🙏

I'll continue this in the UX refactoring #228 but damn it's cool!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request hacktoberfest-accepted Good for Hacktoberfest remote Remote control
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants