Skip to content

Commit

Permalink
refactor: update content to section
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkasany committed Jan 7, 2025
1 parent c3471c8 commit e43b27c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
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');
});
});

0 comments on commit e43b27c

Please sign in to comment.