Skip to content

Commit

Permalink
feat(react-components): add "modalProps" prop to Drawer component
Browse files Browse the repository at this point in the history
  • Loading branch information
donskov committed Aug 29, 2024
1 parent 2d3cd04 commit 8f24955
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions packages/react-components/src/Drawer/drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import styled from '@emotion/styled';
import { Modal } from '../Modal';
import { Modal, ModalProps } from '../Modal';
import { Slide } from '../Slide';

/**
Expand All @@ -24,13 +24,9 @@ type DrawerOwnProps = {
*/
transitionDuration?: number;
/**
* If `true`, clicking the backdrop will not fire the `onClose` callback.
* Props applied to the `Modal` element.
*/
disableBackdropClick?: boolean;
/**
* If `true`, hitting escape will not fire the `onClose` callback.
*/
disableEscapeKeyDown?: boolean;
modalProps?: Partial<Omit<ModalProps, 'transitionDuration' | 'open' | 'onClose' | 'keepMounted'>>;
/**
* Callback fired when the component requests to be closed.
*/
Expand Down Expand Up @@ -72,22 +68,20 @@ export const Drawer = React.forwardRef<HTMLDivElement, DrawerProps>((props, ref)
children,
open,
transitionDuration,
disableBackdropClick,
disableEscapeKeyDown,
modalProps = {},
onClose,
'data-testid': dataTestId,
...other
} = props;

return (
<Modal
{...modalProps}
ref={ref}
open={open}
transitionDuration={transitionDuration}
onClose={onClose}
data-testid={dataTestId}
disableBackdropClick={disableBackdropClick}
disableEscapeKeyDown={disableEscapeKeyDown}
keepMounted
>
<Slide
Expand All @@ -109,6 +103,4 @@ Drawer.displayName = 'Drawer';

Drawer.defaultProps = {
transitionDuration: 225,
disableBackdropClick: false,
disableEscapeKeyDown: false,
};

0 comments on commit 8f24955

Please sign in to comment.