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