Skip to content

Commit

Permalink
feat: Badge.Ribbon support rootClassName (ant-design#44056)
Browse files Browse the repository at this point in the history
* feat: Badge.Ribbon support rootClassName

* docs: update rootClassName description

* feat: optimize code

* feat: optimize code
  • Loading branch information
kiner-tang authored Aug 7, 2023
1 parent dcba47b commit 5351fac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion components/badge/Ribbon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface RibbonProps {
color?: LiteralUnion<PresetColorType>;
children?: React.ReactNode;
placement?: RibbonPlacement;
rootClassName?: string;
}

const Ribbon: React.FC<RibbonProps> = (props) => {
Expand All @@ -27,6 +28,7 @@ const Ribbon: React.FC<RibbonProps> = (props) => {
children,
text,
placement = 'end',
rootClassName,
} = props;
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('ribbon', customizePrefixCls);
Expand All @@ -48,7 +50,7 @@ const Ribbon: React.FC<RibbonProps> = (props) => {
cornerColorStyle.color = color;
}
return wrapSSR(
<div className={classNames(`${prefixCls}-wrapper`, hashId)}>
<div className={classNames(`${prefixCls}-wrapper`, rootClassName, hashId)}>
{children}
<div className={classNames(ribbonCls, hashId)} style={{ ...colorStyle, ...style }}>
<span className={`${prefixCls}-text`}>{text}</span>
Expand Down
3 changes: 0 additions & 3 deletions components/badge/__tests__/demo.test.ts

This file was deleted.

8 changes: 8 additions & 0 deletions components/badge/__tests__/demo.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react';
import demoTest, { rootPropsTest } from '../../../tests/shared/demoTest';

demoTest('badge');

rootPropsTest('badge', (Badge, props) => <Badge.Ribbon {...props} />, {
name: 'Badge.Ribbon',
});

0 comments on commit 5351fac

Please sign in to comment.