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

feat: classNames & styles support content #428

Merged
merged 1 commit into from
Sep 22, 2023
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
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();
});
});
Loading