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

Adds a theme toggle component #21

Merged
merged 2 commits into from
Jul 13, 2022

Conversation

soupaJ
Copy link
Collaborator

@soupaJ soupaJ commented Jul 3, 2022

Description

Adds a theme toggle component to the header. The logic works like:

  1. Check if localstorage has a preference set.
  2. Check the system preference.
  3. If localstorage and system preference are the same, delete localstorage value. This assumes that if the user had a localstorage value, but it now matches the system preference, the user must have changed their system preference or Gistdoc preference at some point.
  4. When applying the color scheme preference, prefer localstorage value over system preference. This assumes the user changed their preference for Gistdoc specifically.

Screenshots

Light mode:
image

Dark mode:
image

Condensed header, dark mode:
image

@vercel
Copy link

vercel bot commented Jul 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
gistdoc ✅ Ready (Inspect) Visit Preview Jul 13, 2022 at 2:13AM (UTC)

Copy link
Owner

@jkulton jkulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice. *chefs kiss*

components/theme-toggle/theme-toggle.module.css Outdated Show resolved Hide resolved
components/theme-toggle/theme-toggle.module.css Outdated Show resolved Hide resolved
pages/_document.tsx Show resolved Hide resolved
@soupaJ soupaJ force-pushed the feature/adds-theme-toggle branch from 880e7ed to f012325 Compare July 12, 2022 04:33
@soupaJ soupaJ force-pushed the feature/adds-theme-toggle branch from f012325 to f5a0a61 Compare July 12, 2022 04:37
@soupaJ soupaJ changed the title WIP: Adds a theme toggle component Adds a theme toggle component Jul 12, 2022
updates tailwind to use arbitrary variants
@soupaJ soupaJ force-pushed the feature/adds-theme-toggle branch from f5a0a61 to 8ce163f Compare July 12, 2022 04:53
@soupaJ soupaJ marked this pull request as ready for review July 12, 2022 04:53
@soupaJ
Copy link
Collaborator Author

soupaJ commented Jul 12, 2022

@jkulton I made changes to address the PR feedback. I've converted it to use tailwind instead of css modules since that's the way we're currently styling all things. It now check if the user prefers reduced motion and, if so, turns off the transitions and animations.

Copy link
Owner

@jkulton jkulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the accessibility-mindedness, this looks great! 🙇 Just one small suggestion.

components/theme-toggle/theme-toggle.tsx Outdated Show resolved Hide resolved
Co-authored-by: Jon Kulton <6694167+jkulton@users.noreply.github.com>
@jkulton jkulton merged commit 589c8d2 into jkulton:main Jul 13, 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.

None yet

2 participants