Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

feat(types): add type exports for color mode & theme providers #492

Merged
merged 3 commits into from
Oct 7, 2021

Conversation

Pwuts
Copy link
Contributor

@Pwuts Pwuts commented Oct 3, 2021

Added type export declarations for the CColorModeProvider and CThemeProvider components, for use with TypeScript environments. Rather than declaring them on the central Vue object, the provided types can be imported; an example is below.

import { Inject } from 'nuxt-property-decorator'
import type { CThemeProvides } from '@chakra-ui/vue'

/* ... inside a class component: */
@Inject('$chakraTheme')
theme: CThemeProvides['$chakraTheme'];

For consistency, I have taken the properties chakraColorMode and chakraToggleColorMode out of the Vue interface declaration. They are not injected or set on the main Vue instance, so they shouldn't be declared on it either.

Motivation and Context

A while ago I submitted a PR (#473) adding type declarations for chakra to the main Vue object. This PR is aimed at also providing types for the provided items from the CColorModeProvider and CThemeProvider components, so this package can be used without issue by Vue/Nuxt + TS users.

This PR fixes the last issues of #469 left over after #473.

How Has This Been Tested?

The pre-push tests are failing on the develop branch anyways, so hard to check.

Screenshots (if appropriate):

Types of changes

  • 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 change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@changeset-bot
Copy link

changeset-bot bot commented Oct 3, 2021

🦋 Changeset detected

Latest commit: e16f20e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@chakra-ui/vue Minor
@chakra-ui/nuxt Minor
chakra-ui-docs Patch
nuxt-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 3, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

chakra-ui-vue – ./

🔍 Inspect: https://vercel.com/chakra-ui/chakra-ui-vue/F2ZLMTxf9yY8vCi7EypdjoUe6yjZ
✅ Preview: https://chakra-ui-vue-git-fork-pwuts-improve-theme-types-chakra-ui.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 3, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e16f20e:

Sandbox Source
Chakra UI Vue (0.X) Starter Template Configuration
chakra-ui-nuxt-demo Configuration

@codebender828 codebender828 requested review from codebender828 and removed request for codebender828 October 7, 2021 14:56
@codebender828 codebender828 linked an issue Oct 7, 2021 that may be closed by this pull request
codebender828
codebender828 previously approved these changes Oct 7, 2021
Copy link
Collaborator

@codebender828 codebender828 left a comment

Choose a reason for hiding this comment

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

Thank you @Pwuts . This is helpful. I see no problems with this so far. Glad to see the TS community benefit from this

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

Successfully merging this pull request may close these issues.

qn: Error using $chakraColorMode method with typescript
2 participants