Skip to content

Commit

Permalink
refactor: remove contentWrapperStyle, use styles.wrapper instead (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jan 4, 2024
1 parent 570e77b commit 5848294
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ ReactDom.render(
| props | type | default | description |
|------------|----------------|---------|----------------|
| className | string | null | - |
| classNames | { mask?: string; wrapper?: string; } | - | pass className to target area |
| styles | { mask?: CSSProperties; wrapper?: CSSProperties; } | - | pass style to target area |
| classNames | { mask?: string; content?: string; wrapper?: string; } | - | pass className to target area |
| styles | { mask?: CSSProperties; content?: CSSProperties; wrapper?: CSSProperties; } | - | pass style to target area |
| prefixCls | string | 'drawer' | prefix class |
| width | string \| number | null | drawer content wrapper width, drawer level transition width |
| height | string \| number | null | drawer content wrapper height, drawer level transition height |
Expand All @@ -63,7 +63,6 @@ ReactDom.render(
| afterVisibleChange | func | null | transition end callback(open) |
| onClose | func | null | close click function |
| keyboard | boolean | true | Whether support press esc to close |
| contentWrapperStyle | CSSProperties | null | content wrapper style |
| autoFocus | boolean | true | Whether focusing on the drawer after it opened |
| onMouseEnter | React.MouseEventHandler\<HTMLDivElement\> | - | Trigger when mouse enter drawer panel |
| onMouseOver | React.MouseEventHandler\<HTMLDivElement\> | - | Trigger when mouse over drawer panel |
Expand Down
3 changes: 0 additions & 3 deletions src/DrawerPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export interface DrawerPopupProps extends DrawerPanelEvents {
children?: React.ReactNode;
width?: number | string;
height?: number | string;
contentWrapperStyle?: React.CSSProperties;

// Mask
mask?: boolean;
Expand Down Expand Up @@ -98,7 +97,6 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
width,
height,
children,
contentWrapperStyle,

// Mask
mask,
Expand Down Expand Up @@ -304,7 +302,6 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
style={{
...wrapperStyle,
...motionStyle,
...contentWrapperStyle,
...styles?.wrapper,
}}
{...pickAttrs(props, { data: true })}
Expand Down
4 changes: 2 additions & 2 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ describe('rc-drawer-menu', () => {
});
});

it('contentWrapperStyle', () => {
render(<Drawer contentWrapperStyle={{ background: '#f00' }} open />);
it('styles.wrapper', () => {
render(<Drawer styles={{ wrapper: { background: '#f00' } }} open />);

expect(document.querySelector('.rc-drawer-content-wrapper')).toHaveStyle({
background: '#f00',
Expand Down
4 changes: 2 additions & 2 deletions tests/motion.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ describe('motion', () => {
jest.useRealTimers();
});

// zombieJ: Do not modify patch dom since user use `contentWrapperStyle` for override style
// zombieJ: Do not modify patch dom since user use `styles.wrapper` for override style
it('motion patch on the correct element', () => {
const { container } = render(
<Drawer
width="93%"
open
getContainer={false}
motion={{ motionName: 'bamboo', motionAppear: true }}
contentWrapperStyle={{ background: 'red' }}
styles={{ wrapper: { background: 'red' } }}
/>,
);

Expand Down

1 comment on commit 5848294

@vercel
Copy link

@vercel vercel bot commented on 5848294 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

drawer – ./

drawer.vercel.app
drawer-git-master-react-component.vercel.app
drawer-react-component.vercel.app

Please sign in to comment.