2021-03-16 04:54:22 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2021-06-26 01:35:40 +00:00
|
|
|
import type { HTMLAttributes } from 'vue';
|
|
|
|
import { defineComponent } from 'vue';
|
2021-03-16 04:54:22 +00:00
|
|
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
|
|
|
import classNames from '../_util/classNames';
|
|
|
|
|
|
|
|
export interface TypographyProps extends HTMLAttributes {
|
|
|
|
prefixCls?: string;
|
|
|
|
}
|
|
|
|
|
2021-11-09 06:36:15 +00:00
|
|
|
export interface InternalTypographyProps extends TypographyProps {
|
2021-03-16 04:54:22 +00:00
|
|
|
component?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Typography = defineComponent<InternalTypographyProps>({
|
|
|
|
name: 'ATypography',
|
|
|
|
inheritAttrs: false,
|
|
|
|
setup(props, { slots, attrs }) {
|
|
|
|
const { prefixCls } = useConfigInject('typography', props);
|
|
|
|
return () => {
|
|
|
|
const {
|
|
|
|
prefixCls: _prefixCls,
|
|
|
|
class: _className,
|
|
|
|
component: Component = 'article' as any,
|
|
|
|
...restProps
|
|
|
|
} = { ...props, ...attrs };
|
|
|
|
return (
|
|
|
|
<Component class={classNames(prefixCls.value, attrs.class)} {...restProps}>
|
|
|
|
{slots.default?.()}
|
|
|
|
</Component>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Typography.props = {
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
component: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
2021-06-23 13:47:53 +00:00
|
|
|
export default Typography;
|