forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.tsx
49 lines (45 loc) · 1.42 KB
/
Button.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import type { ExtractPropTypes, PropType } from 'vue';
import { computed, defineComponent } from 'vue';
import classNames from '../_util/classNames';
import useConfigInject from '../config-provider/hooks/useConfigInject';
import { initDefaultProps } from '../_util/props-util';
import Element, { skeletonElementProps } from './Element';
import useStyle from './style';
export const skeletonButtonProps = () => {
return {
...skeletonElementProps(),
size: String as PropType<'large' | 'small' | 'default'>,
block: Boolean,
};
};
export type SkeletonButtonProps = Partial<ExtractPropTypes<ReturnType<typeof skeletonButtonProps>>>;
const SkeletonButton = defineComponent({
compatConfig: { MODE: 3 },
name: 'ASkeletonButton',
props: initDefaultProps(skeletonButtonProps(), {
size: 'default',
}),
setup(props) {
const { prefixCls } = useConfigInject('skeleton', props);
const [wrapSSR, hashId] = useStyle(prefixCls);
const cls = computed(() =>
classNames(
prefixCls.value,
`${prefixCls.value}-element`,
{
[`${prefixCls.value}-active`]: props.active,
[`${prefixCls.value}-block`]: props.block,
},
hashId.value,
),
);
return () => {
return wrapSSR(
<div class={cls.value}>
<Element {...props} prefixCls={`${prefixCls.value}-button`} />
</div>,
);
};
},
});
export default SkeletonButton;