File tree Expand file tree Collapse file tree 12 files changed +100
-26
lines changed Expand file tree Collapse file tree 12 files changed +100
-26
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ import { createApp } from 'vue'
3
3
import { createRouter , createWebHistory } from 'vue-router'
4
4
import App from './App.vue'
5
5
import routes from './routes'
6
+ import antd from 'ant-design-vue'
6
7
7
8
const router = createRouter ( {
8
9
history : createWebHistory ( ) ,
9
10
routes,
10
11
} )
11
12
12
- createApp ( App ) . use ( router ) . mount ( '#app' )
13
+ createApp ( App ) . use ( router ) . use ( antd ) . mount ( '#app' )
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" flex flex-col gap-2" >
3
- <button class =" btn btn-primary" >Primary Button</button >
4
- <button class =" btn btn-secondary" >Default Button</button >
5
- <button class =" btn btn-error" >Dashed Button</button >
6
- <button class =" btn btn-link" >Text Button</button >
7
- <button class =" btn btn-link" >Link Button</button >
3
+ <a- button class =" btn btn-primary" >Primary Button</a- button >
4
+ <a- button class =" btn btn-secondary" >Default Button</a- button >
5
+ <a- button class =" btn btn-error" >Dashed Button</a- button >
6
+ <a- button class =" btn btn-link" >Text Button</a- button >
7
+ <a- button class =" btn btn-link" >Link Button</a- button >
8
8
</div >
9
9
</template >
Original file line number Diff line number Diff line change 1
1
/* eslint-disable @typescript-eslint/consistent-type-imports */
2
2
declare module 'vue' {
3
- export interface GlobalComponents { }
3
+ export interface GlobalComponents {
4
+ AButton : typeof import ( 'ant-design-vue' ) . Button
5
+ }
4
6
}
5
7
export { }
Original file line number Diff line number Diff line change 5
5
"compilerOptions" : {
6
6
"paths" : {
7
7
"@/*" : [" ./src/*" ],
8
- "~/*" : [" ./assets/*" ]
8
+ "~/*" : [" ./assets/*" ],
9
+ "ant-design-vue" : [" ./../../packages/ui/src/index.ts" ]
9
10
}
10
11
}
11
12
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export default defineConfig({
15
15
alias : {
16
16
'@' : resolve ( __dirname , './src' ) ,
17
17
'~' : resolve ( __dirname , './assets' ) ,
18
+ 'ant-design-vue' : resolve ( __dirname , '../../packages/ui/src/index.ts' ) ,
18
19
} ,
19
20
} ,
20
21
} )
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <button :class =" classes" @click =" $emit('click', $event)" >
3
+ <slot ></slot >
4
+ </button >
5
+ </template >
6
+
7
+ <script setup lang="ts">
8
+ import { computed } from ' vue'
9
+ import { buttonProps , buttonEmits , ButtonSlots } from ' ./meta'
10
+
11
+ const props = defineProps (buttonProps )
12
+
13
+ defineEmits (buttonEmits )
14
+ defineSlots <ButtonSlots >()
15
+
16
+ const classes = computed (() => {
17
+ return [
18
+ ' rounded-md px-4 py-2 cursor-pointer' ,
19
+ props .type ,
20
+ {
21
+ ' bg-primary text-primary-content' : props .type === ' primary' ,
22
+ ' bg-secondary text-secondary-content' : props .type === ' secondary' ,
23
+ },
24
+ ]
25
+ })
26
+ </script >
Original file line number Diff line number Diff line change
1
+ import { App , Plugin } from 'vue'
2
+ import Button from './Button.vue'
3
+
4
+ /* istanbul ignore next */
5
+ Button . install = function ( app : App ) {
6
+ app . component ( 'AButton' , Button )
7
+ return app
8
+ }
9
+
10
+ export default Button as typeof Button & Plugin
Original file line number Diff line number Diff line change
1
+ import { PropType , ExtractPublicPropTypes } from 'vue'
2
+
3
+ // Button Props
4
+ export const buttonProps = {
5
+ /**
6
+ * Specifies the visual style variant of the button
7
+ * @default 'primary'
8
+ */
9
+ type : {
10
+ type : String as PropType < 'primary' | 'secondary' > ,
11
+ default : 'primary' ,
12
+ } ,
13
+ } as const
14
+
15
+ export type ButtonProps = ExtractPublicPropTypes < typeof buttonProps >
16
+
17
+ // Button Emits
18
+ export const buttonEmits = {
19
+ /**
20
+ * Triggered when the button is clicked by the user
21
+ * @param e - The native MouseEvent object
22
+ */
23
+ click : ( e : MouseEvent ) => e instanceof MouseEvent ,
24
+ } as const
25
+
26
+ export type ButtonEmits = typeof buttonEmits
27
+
28
+ // Button Slots
29
+ export const buttonSlots = {
30
+ /**
31
+ * Main content slot for the button text or custom content
32
+ */
33
+ default : ( _ : any ) => null as any ,
34
+ } as const
35
+
36
+ export type ButtonSlots = typeof buttonSlots
Original file line number Diff line number Diff line change
1
+ export { default as Button } from './button'
Original file line number Diff line number Diff line change 1
1
import { App } from 'vue'
2
2
3
- const components = { } as any
3
+ import * as components from './components'
4
+ export * from './components'
4
5
export const install = function ( app : App ) {
5
6
Object . keys ( components ) . forEach ( key => {
6
7
const component = components [ key ]
7
8
if ( component . install ) {
8
9
app . use ( component )
9
10
}
10
11
} )
11
- app . config . globalProperties . $message = components . message
12
- app . config . globalProperties . $notification = components . notification
13
- app . config . globalProperties . $info = components . Modal . info
14
- app . config . globalProperties . $success = components . Modal . success
15
- app . config . globalProperties . $error = components . Modal . error
16
- app . config . globalProperties . $warning = components . Modal . warning
17
- app . config . globalProperties . $confirm = components . Modal . confirm
18
- app . config . globalProperties . $destroyAll = components . Modal . destroyAll
12
+ // app.config.globalProperties.$message = components.message
13
+ // app.config.globalProperties.$notification = components.notification
14
+ // app.config.globalProperties.$info = components.Modal.info
15
+ // app.config.globalProperties.$success = components.Modal.success
16
+ // app.config.globalProperties.$error = components.Modal.error
17
+ // app.config.globalProperties.$warning = components.Modal.warning
18
+ // app.config.globalProperties.$confirm = components.Modal.confirm
19
+ // app.config.globalProperties.$destroyAll = components.Modal.destroyAll
19
20
return app
20
21
}
21
22
You can’t perform that action at this time.
0 commit comments