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 use of custom data-theme values that also override auto light/dark switching #272

Merged
merged 1 commit into from
Dec 26, 2022

Conversation

wmurphyrd
Copy link
Contributor

@wmurphyrd wmurphyrd commented Nov 3, 2022

I'm migrating https://github.com/immers-space/immers over to pico in order to make the style customizable for each server, and I love it. The extensive use of CSS custom properties means we can customize it at runtime without having to rebuild the web client.

We'd like to offer an additional built-in theme that is activated via data-theme attribute value, but we have an issue that setting data-theme to anything other than light leaves the auto light/dark switch enabled, making that particular theme unreadable for prefers-color-scheme: dark users.

This tiny change makes it so any value for data-theme will disable the auto-switching. All of the existing behavior is preserved:

  • Users with no preference on page with no data-theme gets light mode
  • Users with dark preference on page with no data-theme gets dark mode
  • Users with light preference on page with no data-theme gets light mode
  • [data-theme=light] shows light mode regardless of preference
  • [data-theme=dark] shows dark mode regardless of preference
2022-11-03.11-10-33.mp4

@lucaslarroche
Copy link
Member

Hi @wmurphyrd,
I finally took the time to look at the PR and do some testing.
Thank you. You are right, that's how it should be.

I will merge your PR into dev, then I will add a few more fixes before merging into master.

@lucaslarroche lucaslarroche changed the base branch from master to dev December 26, 2022 05:45
@lucaslarroche lucaslarroche merged commit f33b27f into picocss:dev Dec 26, 2022
@lucaslarroche lucaslarroche mentioned this pull request Dec 26, 2022
lucaslarroche added a commit that referenced this pull request Dec 29, 2022
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

Successfully merging this pull request may close these issues.

2 participants