Skip to content

Commit d5ee44b

Browse files
authored
feat: support root style (#469)
* feat: support root style * add test * update
1 parent f8c0131 commit d5ee44b

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/Dialog/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const Dialog: React.FC<IDialogPropTypes> = (props) => {
4141
maskStyle,
4242
maskProps,
4343
rootClassName,
44+
rootStyle,
4445
classNames: modalClassNames,
4546
styles: modalStyles,
4647
} = props;
@@ -175,6 +176,7 @@ const Dialog: React.FC<IDialogPropTypes> = (props) => {
175176
return (
176177
<div
177178
className={classNames(`${prefixCls}-root`, rootClassName)}
179+
style={rootStyle}
178180
{...pickAttrs(props, { data: true })}
179181
>
180182
<Mask

src/IDialogPropTypes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type IDialogPropTypes = {
1111
className?: string;
1212
keyboard?: boolean;
1313
style?: CSSProperties;
14+
rootStyle?: CSSProperties;
1415
mask?: boolean;
1516
children?: React.ReactNode;
1617
afterClose?: () => any;

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`dialog add rootClassName should render correct 1`] = `
3+
exports[`dialog add rootClassName and rootStyle should render correct 1`] = `
44
<div
55
class="rc-dialog-root customize-root-class"
6+
style="font-size: 20px;"
67
>
78
<div
89
class="rc-dialog-mask"

tests/index.spec.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ describe('dialog', () => {
3636
expect(wrapper.render()).toMatchSnapshot();
3737
});
3838

39-
it('add rootClassName should render correct', () => {
39+
it('add rootClassName and rootStyle should render correct', () => {
4040
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
4141
const wrapper = mount(
4242
<Dialog
4343
visible
4444
rootClassName="customize-root-class"
45+
rootStyle={{ fontSize: 20 }}
4546
style={{ width: 600 }}
4647
height={903}
4748
wrapStyle={{ fontSize: 10 }}
@@ -56,6 +57,7 @@ describe('dialog', () => {
5657
);
5758
expect(wrapper.find('.customize-root-class').length).toBeTruthy();
5859
expect(wrapper.find('.rc-dialog-wrap').props().style.fontSize).toBe(10);
60+
expect(wrapper.find('.rc-dialog-root').props().style.fontSize).toBe(20);
5961
expect(wrapper.find('.rc-dialog').props().style.height).toEqual(903);
6062
expect(wrapper.find('.rc-dialog').props().style.width).toEqual(600);
6163
});

0 commit comments

Comments
 (0)