Skip to content

Commit aa7bb5a

Browse files
feat: adapt semantic close (#517)
Co-authored-by: 二货机器人 <smith3816@gmail.com>
1 parent 045d38c commit aa7bb5a

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/Dialog/Content/Panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
118118
onClick={onClose}
119119
aria-label="Close"
120120
{...ariaProps}
121-
className={`${prefixCls}-close`}
121+
className={clsx(`${prefixCls}-close`, modalClassNames?.close)}
122122
disabled={closeBtnIsDisabled}
123+
style={modalStyles?.close}
123124
>
124125
{closableObj.closeIcon}
125126
</button>

src/IDialogPropTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { GetContainer } from '@rc-component/util/lib/PortalWrapper';
22
import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';
33

4-
export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask';
4+
export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask' | 'close';
55

66
export type ModalClassNames = Partial<Record<SemanticName, string>>;
77

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ exports[`dialog should support classNames 1`] = `
111111
>
112112
<button
113113
aria-label="Close"
114-
class="rc-dialog-close"
114+
class="rc-dialog-close custom-close"
115115
type="button"
116116
>
117117
<span
@@ -169,6 +169,7 @@ exports[`dialog should support styles 1`] = `
169169
<button
170170
aria-label="Close"
171171
class="rc-dialog-close"
172+
style="color: red;"
172173
type="button"
173174
>
174175
<span

tests/index.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ describe('dialog', () => {
624624
mask: 'custom-mask',
625625
wrapper: 'custom-wrapper',
626626
container: 'custom-container',
627+
close: 'custom-close',
627628
}}
628629
style={{ width: 600 }}
629630
height={903}
@@ -638,6 +639,7 @@ describe('dialog', () => {
638639
expect(document.querySelector('.rc-dialog-footer').className).toContain('custom-footer');
639640
expect(document.querySelector('.rc-dialog-mask').className).toContain('custom-mask');
640641
expect(document.querySelector('.rc-dialog-container').className).toContain('custom-container');
642+
expect(document.querySelector('.rc-dialog-close').className).toContain('custom-close');
641643
});
642644

643645
it('should support styles', () => {
@@ -654,6 +656,9 @@ describe('dialog', () => {
654656
wrapper: { background: 'pink' },
655657
container: { background: 'orange' },
656658
title: { background: 'orange' },
659+
close: {
660+
color: 'red',
661+
},
657662
}}
658663
style={{ width: 600 }}
659664
height={903}
@@ -669,6 +674,7 @@ describe('dialog', () => {
669674
expect(document.querySelector('.rc-dialog-mask')).toHaveStyle('background: yellow');
670675
expect(document.querySelector('.rc-dialog-container')).toHaveStyle('background: orange');
671676
expect(document.querySelector('.rc-dialog-title')).toHaveStyle('background: orange');
677+
expect(document.querySelector('.rc-dialog-close')).toHaveStyle('color: red');
672678
});
673679

674680
it('should warning', () => {

0 commit comments

Comments
 (0)