UNPKG

2.34 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import withStyles from '../styles/withStyles';
7export const styles = theme => ({
8 /* Styles applied to the root element. */
9 root: {
10 position: 'relative',
11 display: 'flex',
12 alignItems: 'center'
13 },
14
15 /* Styles applied to the root element if `disableGutters={false}`. */
16 gutters: {
17 paddingLeft: theme.spacing(2),
18 paddingRight: theme.spacing(2),
19 [theme.breakpoints.up('sm')]: {
20 paddingLeft: theme.spacing(3),
21 paddingRight: theme.spacing(3)
22 }
23 },
24
25 /* Styles applied to the root element if `variant="regular"`. */
26 regular: theme.mixins.toolbar,
27
28 /* Styles applied to the root element if `variant="dense"`. */
29 dense: {
30 minHeight: 48
31 }
32});
33const Toolbar = /*#__PURE__*/React.forwardRef(function Toolbar(props, ref) {
34 const {
35 classes,
36 className,
37 component: Component = 'div',
38 disableGutters = false,
39 variant = 'regular'
40 } = props,
41 other = _objectWithoutPropertiesLoose(props, ["classes", "className", "component", "disableGutters", "variant"]);
42
43 return /*#__PURE__*/React.createElement(Component, _extends({
44 className: clsx(classes.root, classes[variant], className, !disableGutters && classes.gutters),
45 ref: ref
46 }, other));
47});
48process.env.NODE_ENV !== "production" ? Toolbar.propTypes = {
49 /**
50 * Toolbar children, usually a mixture of `IconButton`, `Button` and `Typography`.
51 */
52 children: PropTypes.node,
53
54 /**
55 * Override or extend the styles applied to the component.
56 * See [CSS API](#css) below for more details.
57 */
58 classes: PropTypes.object.isRequired,
59
60 /**
61 * @ignore
62 */
63 className: PropTypes.string,
64
65 /**
66 * The component used for the root node.
67 * Either a string to use a HTML element or a component.
68 */
69 component: PropTypes
70 /* @typescript-to-proptypes-ignore */
71 .elementType,
72
73 /**
74 * If `true`, disables gutter padding.
75 */
76 disableGutters: PropTypes.bool,
77
78 /**
79 * The variant to use.
80 */
81 variant: PropTypes.oneOf(['regular', 'dense'])
82} : void 0;
83export default withStyles(styles, {
84 name: 'MuiToolbar'
85})(Toolbar);
\No newline at end of file