UNPKG

1.91 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';
7import capitalize from '../utils/capitalize';
8export const styles = theme => ({
9 root: {
10 position: 'absolute',
11 height: 2,
12 bottom: 0,
13 width: '100%',
14 transition: theme.transitions.create()
15 },
16 colorPrimary: {
17 backgroundColor: theme.palette.primary.main
18 },
19 colorSecondary: {
20 backgroundColor: theme.palette.secondary.main
21 },
22 vertical: {
23 height: '100%',
24 width: 2,
25 right: 0
26 }
27});
28/**
29 * @ignore - internal component.
30 */
31
32const TabIndicator = /*#__PURE__*/React.forwardRef(function TabIndicator(props, ref) {
33 const {
34 classes,
35 className,
36 color,
37 orientation
38 } = props,
39 other = _objectWithoutPropertiesLoose(props, ["classes", "className", "color", "orientation"]);
40
41 return /*#__PURE__*/React.createElement("span", _extends({
42 className: clsx(classes.root, classes[`color${capitalize(color)}`], className, orientation === 'vertical' && classes.vertical),
43 ref: ref
44 }, other));
45});
46process.env.NODE_ENV !== "production" ? TabIndicator.propTypes = {
47 /**
48 * Override or extend the styles applied to the component.
49 * See [CSS API](#css) below for more details.
50 */
51 classes: PropTypes.object.isRequired,
52
53 /**
54 * @ignore
55 */
56 className: PropTypes.string,
57
58 /**
59 * @ignore
60 * The color of the tab indicator.
61 */
62 color: PropTypes.oneOf(['primary', 'secondary']).isRequired,
63
64 /**
65 * The tabs orientation (layout flow direction).
66 */
67 orientation: PropTypes.oneOf(['horizontal', 'vertical']).isRequired
68} : void 0;
69export default withStyles(styles, {
70 name: 'PrivateTabIndicator'
71})(TabIndicator);
\No newline at end of file