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(useColorMode): add option to return auto mode #1627

Merged
merged 5 commits into from Jul 6, 2022

Conversation

dfreier
Copy link
Contributor

@dfreier dfreier commented May 22, 2022

Description

Some applications need to know if the preferred color mode was used, e.g. when showing a dropdown menu with the three options light, dark or system. With the current implementation, there is no way to figure out if the user selected auto mode. That means it's not possible to highlight the system option in the dropdown as active.

I added an option emitAuto which defaults to false. When enabled, it includes the auto mode in the returned state variable.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

*
* @default true
*/
omitAuto?: boolean
Copy link
Member

@antfu antfu Jun 19, 2022

Choose a reason for hiding this comment

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

Instead of "omit" and defaulting to true, I think it's better to have it as opt-in, like "emitAuto" and defaulting to false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, feels more natural 👍 I pushed another commit to change it.

@dfreier dfreier requested a review from antfu June 21, 2022 11:05
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
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