Skip to content

Commit 956beac

Browse files
authored
feat: classNames & styles support content (#368)
* feat: classNames & styles support content * feat: optimize code * feat: optimize code
1 parent 9d0b1cd commit 956beac

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/Dialog/Content/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const Panel = React.forwardRef<ContentRef, PanelProps>((props, ref) => {
104104
}
105105

106106
const content = (
107-
<div className={`${prefixCls}-content`}>
107+
<div className={classNames(`${prefixCls}-content`, modalClassNames?.content)} style={modalStyles?.content}>
108108
{closer}
109109
{headerNode}
110110
<div className={classNames(`${prefixCls}-body`, modalClassNames?.body)} style={{...bodyStyle, ...modalStyles?.body}} {...bodyProps}>

src/IDialogPropTypes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface ModalClassNames {
66
body?: string;
77
footer?: string;
88
mask?: string;
9+
content?: string;
910
wrapper?: string;
1011
}
1112

@@ -15,6 +16,7 @@ export interface ModalStyles {
1516
footer?: CSSProperties;
1617
mask?: CSSProperties;
1718
wrapper?: CSSProperties;
19+
content?: CSSProperties;
1820
}
1921

2022
export type IDialogPropTypes = {

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ exports[`dialog should support classNames 1`] = `
131131
tabindex="0"
132132
/>
133133
<div
134-
class="rc-dialog-content"
134+
class="rc-dialog-content custom-content"
135135
>
136136
<button
137137
aria-label="Close"
@@ -198,6 +198,7 @@ exports[`dialog should support styles 1`] = `
198198
/>
199199
<div
200200
class="rc-dialog-content"
201+
style="background: orange;"
201202
>
202203
<button
203204
aria-label="Close"

tests/index.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ describe('dialog', () => {
563563
footer: 'custom-footer',
564564
mask: 'custom-mask',
565565
wrapper: 'custom-wrapper',
566+
content: 'custom-content',
566567
}}
567568
style={{ width: 600 }}
568569
height={903}
@@ -577,6 +578,8 @@ describe('dialog', () => {
577578
expect(wrapper.find('.rc-dialog-header').props().className).toContain('custom-header');
578579
expect(wrapper.find('.rc-dialog-footer').props().className).toContain('custom-footer');
579580
expect(wrapper.find('.rc-dialog-mask').props().className).toContain('custom-mask');
581+
expect(wrapper.find('.rc-dialog-content').props().className).toContain('custom-content');
582+
580583
});
581584

582585
it('should support styles', () => {
@@ -591,6 +594,7 @@ describe('dialog', () => {
591594
footer: { background: 'blue' },
592595
mask: { background: 'yellow' },
593596
wrapper: { background: 'pink' },
597+
content: { background: 'orange' },
594598
}}
595599
style={{ width: 600 }}
596600
height={903}
@@ -605,6 +609,7 @@ describe('dialog', () => {
605609
expect(wrapper.find('.rc-dialog-header').props().style.background).toBe('red');
606610
expect(wrapper.find('.rc-dialog-footer').props().style.background).toBe('blue');
607611
expect(wrapper.find('.rc-dialog-mask').props().style.background).toBe('yellow');
612+
expect(wrapper.find('.rc-dialog-content').props().style.background).toBe('orange');
608613
});
609614
it('should warning', () => {
610615
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});

0 commit comments

Comments
 (0)