UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

97 lines (86 loc) 2.36 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 { fade } from '../styles/colorManipulator'; export const styles = theme => ({ /* Styles applied to the root element. */ root: { height: 1, margin: 0, // Reset browser default style. border: 'none', flexShrink: 0, backgroundColor: theme.palette.divider }, /* Styles applied to the root element if `absolute={true}`. */ absolute: { position: 'absolute', bottom: 0, left: 0, width: '100%' }, /* Styles applied to the root element if `inset={true}`. */ inset: { marginLeft: 72 }, /* Styles applied to the root element if `light={true}`. */ light: { backgroundColor: fade(theme.palette.divider, 0.08) } }); function Divider(props) { const { absolute, classes, className: classNameProp, component: Component, inset, light } = props, other = _objectWithoutProperties(props, ["absolute", "classes", "className", "component", "inset", "light"]); const className = classNames(classes.root, { [classes.absolute]: absolute, [classes.inset]: inset, [classes.light]: light }, classNameProp); return React.createElement(Component, _extends({ className: className }, other)); } Divider.propTypes = process.env.NODE_ENV !== "production" ? { absolute: PropTypes.bool, /** * Override or extend the styles applied to the component. * See [CSS API](#css-api) below for more details. */ classes: PropTypes.object.isRequired, /** * @ignore */ className: PropTypes.string, /** * The component used for the root node. * Either a string to use a DOM element or a component. */ component: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]), /** * If `true`, the divider will be indented. */ inset: PropTypes.bool, /** * If `true`, the divider will have a lighter color. */ light: PropTypes.bool } : {}; Divider.defaultProps = { absolute: false, component: 'hr', inset: false, light: false }; export default withStyles(styles, { name: 'MuiDivider' })(Divider);