Skip to content

Commit 33b8245

Browse files
captain-yossarianoliviertassinari
authored andcommitted
[SwipeableDrawer] Add SwipeAreaProps property (#13592)
* Initial ... * SwipeAreaProps improvements * let's merge
1 parent 9ad2a64 commit 33b8245

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

packages/material-ui/src/SwipeableDrawer/SwipeArea.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export const styles = theme => ({
3636
* @ignore - internal component.
3737
*/
3838
function SwipeArea(props) {
39-
const { anchor, classes, width, ...other } = props;
39+
const { anchor, classes, className, width, ...other } = props;
4040

4141
return (
4242
<div
43-
className={classNames(classes.root, classes[`anchor${capitalize(anchor)}`])}
43+
className={classNames(classes.root, classes[`anchor${capitalize(anchor)}`], className)}
4444
style={{
4545
[isHorizontal(props) ? 'width' : 'height']: width,
4646
}}
@@ -58,6 +58,10 @@ SwipeArea.propTypes = {
5858
* @ignore
5959
*/
6060
classes: PropTypes.object.isRequired,
61+
/**
62+
* @ignore
63+
*/
64+
className: PropTypes.string,
6165
/**
6266
* The width of the left most (or right most) area in pixels where the
6367
* drawer can be swiped open from.

packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface SwipeableDrawerProps extends Omit<DrawerProps, 'onClose' | 'ope
1111
onClose: React.ReactEventHandler<{}>;
1212
onOpen: React.ReactEventHandler<{}>;
1313
open: boolean;
14+
SwipeAreaProps?: object;
1415
swipeAreaWidth?: number;
1516
}
1617

packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ class SwipeableDrawer extends React.Component {
360360
onOpen,
361361
open,
362362
PaperProps = {},
363+
SwipeAreaProps,
363364
swipeAreaWidth,
364365
variant,
365366
...other
@@ -391,7 +392,7 @@ class SwipeableDrawer extends React.Component {
391392
/>
392393
{!disableDiscovery && !disableSwipeToOpen && variant === 'temporary' && (
393394
<NoSsr>
394-
<SwipeArea anchor={anchor} width={swipeAreaWidth} />
395+
<SwipeArea anchor={anchor} width={swipeAreaWidth} {...SwipeAreaProps} />
395396
</NoSsr>
396397
)}
397398
</React.Fragment>
@@ -454,6 +455,10 @@ SwipeableDrawer.propTypes = {
454455
* @ignore
455456
*/
456457
PaperProps: PropTypes.object,
458+
/**
459+
* Properties applied to the swipe area element.
460+
*/
461+
SwipeAreaProps: PropTypes.object,
457462
/**
458463
* The width of the left most (or right most) area in pixels where the
459464
* drawer can be swiped open from.

pages/api/swipeable-drawer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import SwipeableDrawer from '@material-ui/core/SwipeableDrawer';
2727
| <span class="prop-name required">onClose *</span> | <span class="prop-type">func</span> |   | Callback fired when the component requests to be closed.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback |
2828
| <span class="prop-name required">onOpen *</span> | <span class="prop-type">func</span> |   | Callback fired when the component requests to be opened.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback |
2929
| <span class="prop-name required">open *</span> | <span class="prop-type">bool</span> |   | If `true`, the drawer is open. |
30+
| <span class="prop-name">SwipeAreaProps</span> | <span class="prop-type">object</span> |   | Properties applied to the swipe area element. |
3031
| <span class="prop-name">swipeAreaWidth</span> | <span class="prop-type">number</span> | <span class="prop-default">20</span> | The width of the left most (or right most) area in pixels where the drawer can be swiped open from. |
3132
| <span class="prop-name">transitionDuration</span> | <span class="prop-type">union:&nbsp;number&nbsp;&#124;<br>&nbsp;{ enter?: number, exit?: number }<br></span> | <span class="prop-default">{ enter: duration.enteringScreen, exit: duration.leavingScreen }</span> | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. |
3233

0 commit comments

Comments
 (0)