Skip to content
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

refactor: update content to section #478

Merged
merged 1 commit into from
Jan 8, 2025
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
2 changes: 1 addition & 1 deletion src/DrawerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const DrawerPanel = (props: DrawerPanelProps) => {

return (
<div
className={classNames(`${prefixCls}-content`, className)}
className={classNames(`${prefixCls}-section`, className)}
role="dialog"
ref={mergedRef}
{...pickAttrs(props, { aria: true })}
Expand Down
4 changes: 2 additions & 2 deletions src/DrawerPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
id={id}
containerRef={motionRef}
prefixCls={prefixCls}
className={classNames(className, drawerClassNames?.content)}
className={classNames(className, drawerClassNames?.section)}
style={{
...style,
...styles?.content,
...styles?.section,
}}
{...pickAttrs(props, { aria: true })}
{...eventHandlers}
Expand Down
4 changes: 2 additions & 2 deletions src/inter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export interface DrawerClassNames {
mask?: string;
wrapper?: string;
content?: string;
section?: string;
}

export interface DrawerStyles {
mask?: React.CSSProperties;
wrapper?: React.CSSProperties;
content?: React.CSSProperties;
section?: React.CSSProperties;
}
22 changes: 11 additions & 11 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe('rc-drawer-menu', () => {
const { container } = render(
<Drawer open getContainer={false} onClose={onClose} />,
);
fireEvent.keyDown(container.querySelector('.rc-drawer-content'), {
fireEvent.keyDown(container.querySelector('.rc-drawer-section'), {
keyCode: KeyCode.ESC,
});
expect(onClose).toHaveBeenCalled();
Expand All @@ -312,7 +312,7 @@ describe('rc-drawer-menu', () => {
const { container } = render(
<Drawer open getContainer={false} onClose={onClose} keyboard={false} />,
);
fireEvent.keyDown(container.querySelector('.rc-drawer-content'), {
fireEvent.keyDown(container.querySelector('.rc-drawer-section'), {
keyCode: KeyCode.ESC,
});
expect(onClose).not.toHaveBeenCalled();
Expand Down Expand Up @@ -376,20 +376,20 @@ describe('rc-drawer-menu', () => {
const { baseElement } = render(
<Drawer width="93" open onMouseEnter={enter} onMouseLeave={leave} />,
);
fireEvent.mouseOver(baseElement.querySelector('.rc-drawer-content'));
fireEvent.mouseOver(baseElement.querySelector('.rc-drawer-section'));
expect(enter).toHaveBeenCalled();
fireEvent.mouseLeave(baseElement.querySelector('.rc-drawer-content'));
fireEvent.mouseLeave(baseElement.querySelector('.rc-drawer-section'));
expect(leave).toHaveBeenCalled();
});

it('pass id & className props to Panel', () => {
const { unmount } = render(
<Drawer className="customer-className" id="customer-id" open />,
);
expect(document.querySelector('.rc-drawer-content')).toHaveClass(
expect(document.querySelector('.rc-drawer-section')).toHaveClass(
'customer-className',
);
expect(document.querySelector('.rc-drawer-content')).toHaveAttribute(
expect(document.querySelector('.rc-drawer-section')).toHaveAttribute(
'id',
'customer-id',
);
Expand Down Expand Up @@ -430,7 +430,7 @@ describe('rc-drawer-menu', () => {
classNames={{
wrapper: 'customer-wrapper',
mask: 'customer-mask',
content: 'customer-content',
section: 'customer-section',
}}
open
/>,
Expand All @@ -441,8 +441,8 @@ describe('rc-drawer-menu', () => {
expect(document.querySelector('.rc-drawer-mask')).toHaveClass(
'customer-mask',
);
expect(document.querySelector('.rc-drawer-content')).toHaveClass(
'customer-content',
expect(document.querySelector('.rc-drawer-section')).toHaveClass(
'customer-section',
);
unmount();
});
Expand All @@ -452,7 +452,7 @@ describe('rc-drawer-menu', () => {
styles={{
wrapper: { background: 'red' },
mask: { background: 'blue' },
content: { background: 'green' },
section: { background: 'green' },
}}
open
/>,
Expand All @@ -463,7 +463,7 @@ describe('rc-drawer-menu', () => {
expect(document.querySelector('.rc-drawer-mask')).toHaveStyle(
'background: blue',
);
expect(document.querySelector('.rc-drawer-content')).toHaveStyle(
expect(document.querySelector('.rc-drawer-section')).toHaveStyle(
'background: green',
);
unmount();
Expand Down
2 changes: 1 addition & 1 deletion tests/ref.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ describe('Drawer.ref', () => {
jest.runAllTimers();
});

expect(panelRef.current).toHaveClass('rc-drawer-content');
expect(panelRef.current).toHaveClass('rc-drawer-section');
});
});
Loading