Skip to content

Commit 65c4666

Browse files
committed
feat: ribbon support text slot
1 parent 31d641e commit 65c4666

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

components/badge/Ribbon.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { LiteralUnion } from '../_util/type';
1+
import { LiteralUnion, tuple } from '../_util/type';
22
import { PresetColorType } from '../_util/colors';
33
import { isPresetColor } from './utils';
44
import { defaultConfigProvider } from '../config-provider';
55
import { HTMLAttributes, FunctionalComponent, VNodeTypes, inject, CSSProperties } from 'vue';
6+
import PropTypes from '../_util/vue-types';
67

78
type RibbonPlacement = 'start' | 'end';
89

@@ -14,7 +15,7 @@ export interface RibbonProps extends HTMLAttributes {
1415
}
1516

1617
const Ribbon: FunctionalComponent<RibbonProps> = (props, { attrs, slots }) => {
17-
const { prefixCls: customizePrefixCls, color, text, placement = 'end' } = props;
18+
const { prefixCls: customizePrefixCls, color, text = slots.text?.(), placement = 'end' } = props;
1819
const { class: className, style } = attrs;
1920
const children = slots.default?.();
2021
const { getPrefixCls, direction } = inject('configProvider', defaultConfigProvider);
@@ -48,5 +49,12 @@ const Ribbon: FunctionalComponent<RibbonProps> = (props, { attrs, slots }) => {
4849
};
4950

5051
Ribbon.displayName = 'ABadgeRibbon';
52+
Ribbon.inheritAttrs = false;
53+
Ribbon.props = {
54+
prefix: PropTypes.string,
55+
color: PropTypes.string,
56+
text: PropTypes.any,
57+
placement: PropTypes.oneOf(tuple('start', 'end')),
58+
};
5159

5260
export default Ribbon;

0 commit comments

Comments
 (0)