diff --git a/README.md b/README.md index 3c425478..a78fb6cd 100755 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ ReactDom.render( | onClose | func | null | close click function | | onHandleClick | func | nul | handle icon click function | | keyboard | Boolean | true | Whether support press esc to close | +| contentWrapperStyle | CSSProperties | null | content wrapper style | > 2.0 Rename `onMaskClick` -> `onClose`, add `maskClosable`. diff --git a/src/DrawerChild.tsx b/src/DrawerChild.tsx index 04362136..c696d18c 100644 --- a/src/DrawerChild.tsx +++ b/src/DrawerChild.tsx @@ -480,6 +480,7 @@ class DrawerChild extends React.Component { keyboard, getOpenCount, scrollLocker, + contentWrapperStyle, ...props } = this.props; // 首次渲染都将是关闭状态。 @@ -542,6 +543,7 @@ class DrawerChild extends React.Component { msTransform: transform, width: isNumeric(width) ? `${width}px` : width, height: isNumeric(height) ? `${height}px` : height, + ...contentWrapperStyle }} ref={c => { this.contentWrapper = c as HTMLElement; diff --git a/src/IDrawerPropTypes.ts b/src/IDrawerPropTypes.ts index 9ad3aa24..028b3572 100644 --- a/src/IDrawerPropTypes.ts +++ b/src/IDrawerPropTypes.ts @@ -34,6 +34,7 @@ interface IProps extends Omit, 'onChange'> { onHandleClick?: (e: React.MouseEvent | React.KeyboardEvent) => void; onClose?: (e: React.MouseEvent | React.KeyboardEvent) => void; keyboard?: boolean; + contentWrapperStyle?: React.CSSProperties; } export interface IDrawerProps extends IProps { diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 0f16337b..c0414796 100755 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -217,4 +217,12 @@ describe('rc-drawer-menu', () => { }); expect(toJson(instance.render())).toMatchSnapshot(); }); + + it('contentWrapperStyle', () => { + instance = mount( + , + ); + const content = instance.find('.drawer-content-wrapper').instance() as any; + expect(content.style.background).toBe('rgb(255, 0, 0)'); + }); });