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): expose state to the ref, deprecated emitAuto #2980

Merged
merged 4 commits into from Apr 22, 2023

Conversation

Waleed-KH
Copy link
Contributor

@Waleed-KH Waleed-KH commented Apr 15, 2023

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.
⚠️ Slowing down new functions

Warning: Slowing down new functions

As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. Please note that new features for VueUse may not be accepted at this time. If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.


Description

Applied some improvements was done in #2023

  • Allow initialValue to be passed as ref
  • Deprecated emitAuto, in favor of store.value when auto mode needs to be known
  • Expose state, so dev won't need to write computed(() => store.value === 'auto' ? system.value : store.value) when extracting the store value
  • Type improvements and fixes, this will help the dev to know exactly the values of store, system, state
  • update useDark to use system.value instead of importing usePreferredDark

Additional context


🤖 Generated by Copilot at f8e66e3

This pull request enhances the useColorMode function and its test case to provide better type safety, customization, and readability. It also removes some redundant code and improves the naming consistency.

🤖 Generated by Copilot at f8e66e3

  • Introduce BasicColorMode type and constrain generic type parameter T to extend it (link, link, link, link)
  • Change initialValue option to accept MaybeRef type and use it directly for store variable (link, link, link)
  • Add state property to return value and use computed ref to return either store.value or state.value depending on emitAuto option (link, link)
  • Simplify defaultOnChanged function and remove watch function for system value (link, link)
  • Add deprecation notice to value property and link to documentation (link)
  • Rename test case and variable to avoid confusion (packages/core/useColorMode/index.test.ts, link)

@antfu antfu changed the title feat(useColorMode): MaybeRef for initialValue, deprecated emitAuto, expose state, type improvements feat(useColorMode): expose state to the ref, deprecated emitAuto Apr 22, 2023
@antfu antfu merged commit a1bef49 into vueuse:main Apr 22, 2023
2 of 3 checks passed
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