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

feat: add type definition of component #380

Merged
merged 5 commits into from
Feb 7, 2021

Conversation

odanado
Copy link
Contributor

@odanado odanado commented Jan 19, 2021

Description

Fix a part of #275.
I don't added any type definitions other than components (e.g. Chakra class).

Motivation and Context

We can import each components in a typescript file.

How Has This Been Tested?

Automatically generate d.ts file from each components.

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 Jan 19, 2021

⚠️ No Changeset found

Latest commit: b31c25f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Jan 19, 2021

@odanado is attempting to deploy a commit to the Chakra UI Team on Vercel.

A member of the Team first needs to authorize it.

@odanado
Copy link
Contributor Author

odanado commented Jan 19, 2021

Do I need to add a new document and a new test?

@vercel
Copy link

vercel bot commented Jan 22, 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/j1qgf1xkq
✅ Preview: https://chakra-ui-vue-git-fork-odanado-fix-issues-275.chakra-ui.vercel.app

@codebender828 codebender828 changed the title Add type definition of component feat: add type definition of component Jan 23, 2021
@codebender828 codebender828 added type: feature or enhancement ⚡️ New feature or request type: tooling 🛠 Has to do with support modules that enhance the development experience with Chakra UI Vue typescript To do with using Typescript labels Jan 23, 2021
@codebender828 codebender828 self-requested a review January 23, 2021 00:26
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 @odanado for the work done here. I commented about some improvements that we can possible make before merging this.

@@ -0,0 +1,150 @@
declare module '@chakra-ui/vue' {
import Vue from 'vue'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to include declarations for the default export from @chakra-ui/vue also? Since the plugin has some options, I think it will be useful as well. You can find a good reference here:

/**
* @typedef {Object} Options
* @property {Theme} theme
* @property {Theme} extendTheme
* @property {Object} icons
* @property {Object} icons.extend
* @property {String} icons.iconPack
* @property {Object} icons.iconSet
*
*/
/**
* Chakra-ui Component library plugin
* @type {Chakra}
*/
const Chakra = {
/**
*
* @param {Vue} Vue
* @param {Options} options
*/
install (Vue, options = {}) {
let packIcons = {}
const extendedIcons = options.icons ? options.icons.extend || {} : {}
if (options.icons) {
packIcons = parsePackIcons(options.icons.iconSet)
}
const icons = {
...internalIcons,
...packIcons,
...extendedIcons
}
// Recursively merge extended theme variables
const mergedTheme = merge(defaultTheme, options.extendTheme)
Vue.directive('chakra', createClientDirective(mergedTheme))
// Bind theme and icons to prototype
Vue.prototype.$chakra = {
theme: mergedTheme,
icons
}
const toast = useToast()
Vue.prototype.$toast = toast
/** Install dependent plugins */
Vue.use(VScrollLock)
}
}
export default Chakra

I think it can be improved since I last updated these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in 15ed202 and b7c9389

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you @odanado

@odanado
Copy link
Contributor Author

odanado commented Feb 6, 2021

The current .d.ts file of type is corrupted. I'm fixing it.

@odanado
Copy link
Contributor Author

odanado commented Feb 6, 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 @odanado

@@ -0,0 +1,150 @@
declare module '@chakra-ui/vue' {
import Vue from 'vue'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you @odanado

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.

Awesome work here @odanado. Thank you

@codebender828
Copy link
Collaborator

@all-contributors please add @odanado for code and tool

@allcontributors
Copy link
Contributor

@codebender828

I've put up a pull request to add @odanado! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature or enhancement ⚡️ New feature or request type: tooling 🛠 Has to do with support modules that enhance the development experience with Chakra UI Vue typescript To do with using Typescript
Projects
None yet
2 participants