Skip to content

Commit b7e7636

Browse files
feat: adapt semantic close
1 parent e6d5337 commit b7e7636

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
@@ -131,8 +131,9 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
131131
onClick={onClose}
132132
aria-label="Close"
133133
{...ariaProps}
134-
className={`${prefixCls}-close`}
134+
className={clsx(`${prefixCls}-close`, modalClassNames?.close)}
135135
disabled={closeBtnIsDisabled}
136+
style={modalStyles?.close}
136137
>
137138
{closableObj.closeIcon}
138139
</button>

src/IDialogPropTypes.tsx

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
@@ -133,7 +133,7 @@ exports[`dialog should support classNames 1`] = `
133133
>
134134
<button
135135
aria-label="Close"
136-
class="rc-dialog-close"
136+
class="rc-dialog-close custom-close"
137137
type="button"
138138
>
139139
<span
@@ -200,6 +200,7 @@ exports[`dialog should support styles 1`] = `
200200
<button
201201
aria-label="Close"
202202
class="rc-dialog-close"
203+
style="color: red;"
203204
type="button"
204205
>
205206
<span

tests/index.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ describe('dialog', () => {
617617
mask: 'custom-mask',
618618
wrapper: 'custom-wrapper',
619619
container: 'custom-container',
620+
close: 'custom-close',
620621
}}
621622
style={{ width: 600 }}
622623
height={903}
@@ -631,6 +632,7 @@ describe('dialog', () => {
631632
expect(document.querySelector('.rc-dialog-footer').className).toContain('custom-footer');
632633
expect(document.querySelector('.rc-dialog-mask').className).toContain('custom-mask');
633634
expect(document.querySelector('.rc-dialog-container').className).toContain('custom-container');
635+
expect(document.querySelector('.rc-dialog-close').className).toContain('custom-close');
634636
});
635637

636638
it('should support styles', () => {
@@ -647,6 +649,9 @@ describe('dialog', () => {
647649
wrapper: { background: 'pink' },
648650
container: { background: 'orange' },
649651
title: { background: 'orange' },
652+
close: {
653+
color: 'red',
654+
},
650655
}}
651656
style={{ width: 600 }}
652657
height={903}
@@ -662,6 +667,7 @@ describe('dialog', () => {
662667
expect(document.querySelector('.rc-dialog-mask')).toHaveStyle('background: yellow');
663668
expect(document.querySelector('.rc-dialog-container')).toHaveStyle('background: orange');
664669
expect(document.querySelector('.rc-dialog-title')).toHaveStyle('background: orange');
670+
expect(document.querySelector('.rc-dialog-close')).toHaveStyle('color: red');
665671
});
666672

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

0 commit comments

Comments
 (0)