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

feat(darkmode): add useDarkMode hook with tests #251

Merged
merged 2 commits into from
Oct 12, 2020

Conversation

LoganArnett
Copy link
Contributor

Pull Request Template

Description

Added a useDarkMode hook that utilizes the existing useLocalStorage hook to track users dark mode preferences and keep them for future sessions. It also uses the CSS rule for (prefers-color-scheme: dark) to try to detect this preference from the users browser.

Fixes #16

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

I added a useDarkMode.spec.js file with 3 basic tests

  • Test A - Ensures the hook is callable
  • Test B - Ensures you can set a default value when calling the hook
  • Test C - Ensures you can toggle value when calling the hook

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@JamesSingleton JamesSingleton merged commit 1916b03 into JamesSingleton:master Oct 12, 2020
JamesSingleton pushed a commit that referenced this pull request Oct 12, 2020
# [1.6.0](v1.5.0...v1.6.0) (2020-10-12)

### Features

* **darkmode:** add useDarkMode hook with tests ([#251](#251)) ([1916b03](1916b03))
@JamesSingleton
Copy link
Owner

🎉 This PR is included in version 1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Add useDarkMode
2 participants