Skip to content

Commit 6502ae8

Browse files
authored
feat: support contentWrapper style (#166)
1 parent 5b659ce commit 6502ae8

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ ReactDom.render(
7070
| onClose | func | null | close click function |
7171
| onHandleClick | func | nul | handle icon click function |
7272
| keyboard | Boolean | true | Whether support press esc to close |
73+
| contentWrapperStyle | CSSProperties | null | content wrapper style |
7374

7475
> 2.0 Rename `onMaskClick` -> `onClose`, add `maskClosable`.
7576

src/DrawerChild.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
480480
keyboard,
481481
getOpenCount,
482482
scrollLocker,
483+
contentWrapperStyle,
483484
...props
484485
} = this.props;
485486
// 首次渲染都将是关闭状态。
@@ -542,6 +543,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
542543
msTransform: transform,
543544
width: isNumeric(width) ? `${width}px` : width,
544545
height: isNumeric(height) ? `${height}px` : height,
546+
...contentWrapperStyle
545547
}}
546548
ref={c => {
547549
this.contentWrapper = c as HTMLElement;

src/IDrawerPropTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface IProps extends Omit<React.HTMLAttributes<any>, 'onChange'> {
3434
onHandleClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
3535
onClose?: (e: React.MouseEvent | React.KeyboardEvent) => void;
3636
keyboard?: boolean;
37+
contentWrapperStyle?: React.CSSProperties;
3738
}
3839

3940
export interface IDrawerProps extends IProps {

tests/index.spec.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,12 @@ describe('rc-drawer-menu', () => {
217217
});
218218
expect(toJson(instance.render())).toMatchSnapshot();
219219
});
220+
221+
it('contentWrapperStyle', () => {
222+
instance = mount(
223+
<Drawer contentWrapperStyle={{ background: '#f00' }} level={null} />,
224+
);
225+
const content = instance.find('.drawer-content-wrapper').instance() as any;
226+
expect(content.style.background).toBe('rgb(255, 0, 0)');
227+
});
220228
});

0 commit comments

Comments
 (0)