Skip to content

refactor: remove contentWrapperStyle, use styles.wrapper instead #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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