UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

72 lines (67 loc) 1.7 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import withStyles from '../styles/withStyles'; import { capitalize } from '../utils/helpers'; import { isHorizontal } from '../Drawer/Drawer'; export const styles = theme => ({ /* Styles applied to the root element. */ root: { position: 'fixed', top: 0, left: 0, bottom: 0, zIndex: theme.zIndex.drawer - 1 }, anchorLeft: { right: 'auto' }, anchorRight: { left: 'auto', right: 0 }, anchorTop: { bottom: 'auto', right: 0 }, anchorBottom: { top: 'auto', bottom: 0, right: 0 } }); /** * @ignore - internal component. */ function SwipeArea(props) { const { anchor, classes, width } = props, other = _objectWithoutProperties(props, ["anchor", "classes", "width"]); return React.createElement("div", _extends({ className: classNames(classes.root, classes[`anchor${capitalize(anchor)}`]), style: { [isHorizontal(props) ? 'width' : 'height']: width } }, other)); } SwipeArea.propTypes = process.env.NODE_ENV !== "production" ? { /** * Side on which to attach the discovery area. */ anchor: PropTypes.oneOf(['left', 'top', 'right', 'bottom']).isRequired, /** * @ignore */ classes: PropTypes.object.isRequired, /** * The width of the left most (or right most) area in pixels where the * drawer can be swiped open from. */ width: PropTypes.number.isRequired } : {}; export default withStyles(styles)(SwipeArea);