Skip to content

Commit

Permalink
feat: classNames & styles support content (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiner-tang authored Sep 22, 2023
1 parent 0b0d4a0 commit 2ea8730
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/DrawerPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
id={id}
containerRef={motionRef}
prefixCls={prefixCls}
className={className}
style={style}
className={classNames(className, drawerClassNames?.content)}
style={{
...style,
...styles?.content,
}}
{...eventHandlers}
>
{children}
Expand Down
2 changes: 2 additions & 0 deletions src/inter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export interface DrawerClassNames {
mask?: string;
wrapper?: string;
content?: string;
}

export interface DrawerStyles {
mask?: React.CSSProperties;
wrapper?: React.CSSProperties;
content?: React.CSSProperties;
}
8 changes: 8 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ describe('rc-drawer-menu', () => {
<Drawer classNames={{
wrapper: 'customer-wrapper',
mask: 'customer-mask',
content: 'customer-content',
}} open />
);
expect(
Expand All @@ -409,13 +410,17 @@ describe('rc-drawer-menu', () => {
expect(
document.querySelector('.rc-drawer-mask')
).toHaveClass('customer-mask');
expect(
document.querySelector('.rc-drawer-content')
).toHaveClass('customer-content');
unmount();
});
it('should support styles', () => {
const { unmount } = render(
<Drawer styles={{
wrapper: { background: 'red' },
mask: { background: 'blue' },
content: { background: 'green' },
}} open />
);
expect(
Expand All @@ -424,6 +429,9 @@ describe('rc-drawer-menu', () => {
expect(
document.querySelector('.rc-drawer-mask')
).toHaveStyle('background: blue');
expect(
document.querySelector('.rc-drawer-content')
).toHaveStyle('background: green');
unmount();
});
});

1 comment on commit 2ea8730

@vercel
Copy link

@vercel vercel bot commented on 2ea8730 Sep 22, 2023

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-react-component.vercel.app
drawer-git-master-react-component.vercel.app

Please sign in to comment.