Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
onNoticeClose,
times,
hovering: forcedHovering,
classNames,
styles,
} = props;
const [hovering, setHovering] = React.useState(false);
const [percent, setPercent] = React.useState(0);
Expand Down Expand Up @@ -138,7 +140,8 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
{/* Close Icon */}
{closable && (
<button
className={`${noticePrefixCls}-close`}
className={clsx(`${noticePrefixCls}-close`, classNames?.close)}
style={{ ...styles?.close }}
onKeyDown={onCloseKeyDown}
aria-label="Close"
{...ariaProps}
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type React from 'react';

export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';

type NoticeSemanticProps = 'wrapper';
type NoticeSemanticProps = 'wrapper' | 'close';

export interface NoticeConfig {
content?: React.ReactNode;
Expand Down
10 changes: 10 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,18 @@ describe('Notification.Basic', () => {

act(() => {
instance.open({
closable: true,
styles: {
wrapper: {
content: 'little',
},
close: {
color: 'red',
},
},
classNames: {
wrapper: 'bamboo',
close: 'custom-close',
},
});
});
Expand All @@ -638,6 +643,11 @@ describe('Notification.Basic', () => {
content: 'little',
});
expect(document.querySelector('.rc-notification-notice-wrapper')).toHaveClass('bamboo');

expect(document.querySelector('.rc-notification-notice-close')).toHaveClass('custom-close');
expect(document.querySelector('.rc-notification-notice-close')).toHaveStyle({
color: 'rgb(255, 0, 0)',
});
});

it('should className work', () => {
Expand Down