Skip to content

Commit 0a0aada

Browse files
feat: adapt semantic close
1 parent 307d8a7 commit 0a0aada

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Notice.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
3333
onNoticeClose,
3434
times,
3535
hovering: forcedHovering,
36+
classNames,
37+
styles,
3638
} = props;
3739
const [hovering, setHovering] = React.useState(false);
3840
const [percent, setPercent] = React.useState(0);
@@ -138,7 +140,8 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
138140
{/* Close Icon */}
139141
{closable && (
140142
<button
141-
className={`${noticePrefixCls}-close`}
143+
className={clsx(`${noticePrefixCls}-close`, classNames?.close)}
144+
style={{ ...styles?.close }}
142145
onKeyDown={onCloseKeyDown}
143146
aria-label="Close"
144147
{...ariaProps}

src/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type React from 'react';
22

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

5-
type NoticeSemanticProps = 'wrapper';
5+
type NoticeSemanticProps = 'wrapper' | 'close';
66

77
export interface NoticeConfig {
88
content?: React.ReactNode;

tests/index.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,18 @@ describe('Notification.Basic', () => {
623623

624624
act(() => {
625625
instance.open({
626+
closable: true,
626627
styles: {
627628
wrapper: {
628629
content: 'little',
629630
},
631+
close: {
632+
color: 'red',
633+
},
630634
},
631635
classNames: {
632636
wrapper: 'bamboo',
637+
close: 'custom-close',
633638
},
634639
});
635640
});
@@ -638,6 +643,11 @@ describe('Notification.Basic', () => {
638643
content: 'little',
639644
});
640645
expect(document.querySelector('.rc-notification-notice-wrapper')).toHaveClass('bamboo');
646+
647+
expect(document.querySelector('.rc-notification-notice-close')).toHaveClass('custom-close');
648+
expect(document.querySelector('.rc-notification-notice-close')).toHaveStyle({
649+
color: 'rgb(255, 0, 0)',
650+
});
641651
});
642652

643653
it('should className work', () => {

0 commit comments

Comments
 (0)