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

Apart from light and dark, add a system option #46

Open
filiptronicek opened this issue Mar 4, 2021 · 9 comments
Open

Apart from light and dark, add a system option #46

filiptronicek opened this issue Mar 4, 2021 · 9 comments

Comments

@filiptronicek
Copy link

Is there any way (currently) or are there any plans on adding a system theme option that would just reflect the system and not override it? Or do I have to somehow make a custom one that clears the localStorage?

@tomayac
Copy link
Member

tomayac commented Mar 5, 2021

If you never touch the toggle, it uses what the system says.

@filiptronicek
Copy link
Author

@tomayac yes, I'm aware of that, but if I (as a random user) once accidentally touch the toggle, I can never go back (I have no idea how to clear local storage). Is that supposed to work like that? I think there could be a better solution.

@tomayac
Copy link
Member

tomayac commented Mar 5, 2021

If the toggle doesn't have the permanent attribute, the site will reset to the system default.

Let's assume the system preference is light mode.

<dark-mode-toggle>:

  • Toggle dark mode.
  • Reload.
  • Mode is light again.

<dark-mode-toggle permanent>:

  • Toggle dark mode.
  • Reload.
  • Mode is dark again.

@tomayac tomayac closed this as completed Mar 5, 2021
@tomayac
Copy link
Member

tomayac commented Mar 5, 2021

(It's up to the site owner to choose if they set the permanent attribute. Personally, I do on my blog.)

@vapier
Copy link

vapier commented Jan 13, 2024

this is just bad UX. interacting with UI that cannot be undone, and practically speaking, is not recoverable for users, is bad design. a pretty fundamental key UI principle is that actions be easy reversible which this violates.

it's not like Google doesn't know how to write this behavior. some of its properties have a tristate theme selector.

@tomayac
Copy link
Member

tomayac commented Jan 15, 2024

I changed my mind and now do think we should have at least an option to have a three-way toggle. Is anyone on this thread happy to work on a PR that adds such a feature?

@tomayac tomayac reopened this Jan 15, 2024
@tomayac
Copy link
Member

tomayac commented Jan 15, 2024

Functionality-wise, the "system" option would just need to delete the localStorage entry. The actual work would more need to focus on how to expose this UI wise. Some of the properties need rethinking, and the HTML structure, too. The appearance toggle means there's just one visible thing to click at a time that cycles through the possible states, and the switch means all possible states are visible at the same time and clickable.

@tomayac tomayac changed the title System theme Apart from light and dark, add a system option Jan 15, 2024
@vapier
Copy link

vapier commented Jan 15, 2024

for me, the most time consuming part is the graphics, not the underlying logic. do we have an icon ready-to-go here ?

@tomayac
Copy link
Member

tomayac commented Jan 15, 2024

I have seen sites use a slash icon like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants