-
Notifications
You must be signed in to change notification settings - Fork 139
feat: add type definition of component #380
Conversation
|
@odanado is attempting to deploy a commit to the Chakra UI Team on Vercel. A member of the Team first needs to authorize it. |
Do I need to add a new document and a new test? |
This pull request is being automatically deployed with Vercel (learn more). chakra-ui-vue – ./🔍 Inspect: https://vercel.com/chakra-ui/chakra-ui-vue/j1qgf1xkq |
There was a problem hiding this 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' | |||
|
There was a problem hiding this comment.
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:
chakra-ui-vue/packages/chakra-ui-core/src/Chakra/index.js
Lines 28 to 82 in e76b657
/** | |
* @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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @odanado
The current |
@codebender828 Could you review again. |
There was a problem hiding this 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' | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @odanado
There was a problem hiding this 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
@all-contributors please add @odanado for code and tool |
I've put up a pull request to add @odanado! 🎉 |
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
Checklist: