Skip to content

Commit

Permalink
feat: add modal to auto import
Browse files Browse the repository at this point in the history
  • Loading branch information
wiidede committed Nov 20, 2023
1 parent d624154 commit d2902d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
20 changes: 20 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ function handleMessage() {
function handleNotification() {
ANotification.success('This is a success message!')
}
function handleModal() {
AModal.info({
title: 'Info',
content: 'This is a info message',
})
}
const visible = ref(false)
</script>

<template>
Expand All @@ -23,6 +31,12 @@ function handleNotification() {
<a-button status="success" @click="handleNotification">
Success Notification
</a-button>
<a-button @click="handleModal">
Modal Function
</a-button>
<a-button @click="visible = true">
Modal Template
</a-button>
</div>
<a-divider />
<a-row :gutter="24">
Expand Down Expand Up @@ -53,4 +67,10 @@ function handleNotification() {
</a-card>
</a-col>
</a-row>
<AModal v-model:visible="visible">
<template #title>
h
</template>
modal template
</AModal>
</template>
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ export const allHooks: Options['hooks'] = [
export const allImportsWithStyle: Options['imports'] = [
'Notification',
'Message',
'Modal',
]

export const allComponents = Object.keys(AllComponents).filter(name =>
!allLocales.includes(name)
&& !allHooks.includes(name as any)
&& !allImportsWithStyle.includes(name as any)
&& !['Notification', 'Message'].includes(name as any)
&& !['install', 'default'].includes(name),
)

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export interface Options extends TransformOptions {
*
* @default
* ```ts
* ['Notification', 'Message']
* ['Notification', 'Message', 'Modal']
* ```
*/
imports: false | ('Notification' | 'Message')[]
imports: false | ('Notification' | 'Message' | 'Modal')[]

/**
* Prefix of the import name.
Expand Down

0 comments on commit d2902d2

Please sign in to comment.