1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import ButtonBase from '../ButtonBase';
|
8 | import unsupportedProp from '../utils/unsupportedProp';
|
9 | export const styles = theme => ({
|
10 |
|
11 | root: {
|
12 | transition: theme.transitions.create(['color', 'padding-top'], {
|
13 | duration: theme.transitions.duration.short
|
14 | }),
|
15 | padding: '6px 12px 8px',
|
16 | minWidth: 80,
|
17 | maxWidth: 168,
|
18 | color: theme.palette.text.secondary,
|
19 | flex: '1',
|
20 | '&$iconOnly': {
|
21 | paddingTop: 16
|
22 | },
|
23 | '&$selected': {
|
24 | paddingTop: 6,
|
25 | color: theme.palette.primary.main
|
26 | }
|
27 | },
|
28 |
|
29 |
|
30 | selected: {},
|
31 |
|
32 |
|
33 | iconOnly: {},
|
34 |
|
35 |
|
36 | wrapper: {
|
37 | display: 'inline-flex',
|
38 | alignItems: 'center',
|
39 | justifyContent: 'center',
|
40 | width: '100%',
|
41 | flexDirection: 'column'
|
42 | },
|
43 |
|
44 |
|
45 | label: {
|
46 | fontFamily: theme.typography.fontFamily,
|
47 | fontSize: theme.typography.pxToRem(12),
|
48 | opacity: 1,
|
49 | transition: 'font-size 0.2s, opacity 0.2s',
|
50 | transitionDelay: '0.1s',
|
51 | '&$iconOnly': {
|
52 | opacity: 0,
|
53 | transitionDelay: '0s'
|
54 | },
|
55 | '&$selected': {
|
56 | fontSize: theme.typography.pxToRem(14)
|
57 | }
|
58 | }
|
59 | });
|
60 | const BottomNavigationAction = React.forwardRef(function BottomNavigationAction(props, ref) {
|
61 | const {
|
62 | classes,
|
63 | className,
|
64 | icon,
|
65 | label,
|
66 | onChange,
|
67 | onClick,
|
68 | selected,
|
69 | showLabel,
|
70 | value
|
71 | } = props,
|
72 | other = _objectWithoutPropertiesLoose(props, ["classes", "className", "icon", "label", "onChange", "onClick", "selected", "showLabel", "value"]);
|
73 |
|
74 | const handleChange = event => {
|
75 | if (onChange) {
|
76 | onChange(event, value);
|
77 | }
|
78 |
|
79 | if (onClick) {
|
80 | onClick(event);
|
81 | }
|
82 | };
|
83 |
|
84 | return React.createElement(ButtonBase, _extends({
|
85 | ref: ref,
|
86 | className: clsx(classes.root, className, selected ? classes.selected : !showLabel && classes.iconOnly),
|
87 | focusRipple: true,
|
88 | onClick: handleChange
|
89 | }, other), React.createElement("span", {
|
90 | className: classes.wrapper
|
91 | }, icon, React.createElement("span", {
|
92 | className: clsx(classes.label, selected ? classes.selected : !showLabel && classes.iconOnly)
|
93 | }, label)));
|
94 | });
|
95 | process.env.NODE_ENV !== "production" ? BottomNavigationAction.propTypes = {
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | |
102 |
|
103 |
|
104 |
|
105 | children: unsupportedProp,
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 | classes: PropTypes.object,
|
112 |
|
113 | |
114 |
|
115 |
|
116 | className: PropTypes.string,
|
117 |
|
118 | |
119 |
|
120 |
|
121 | icon: PropTypes.node,
|
122 |
|
123 | |
124 |
|
125 |
|
126 | label: PropTypes.node,
|
127 |
|
128 | |
129 |
|
130 |
|
131 | onChange: PropTypes.func,
|
132 |
|
133 | |
134 |
|
135 |
|
136 | onClick: PropTypes.func,
|
137 |
|
138 | |
139 |
|
140 |
|
141 | selected: PropTypes.bool,
|
142 |
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 | showLabel: PropTypes.bool,
|
149 |
|
150 | |
151 |
|
152 |
|
153 | value: PropTypes.any
|
154 | } : void 0;
|
155 | export default withStyles(styles, {
|
156 | name: 'MuiBottomNavigationAction'
|
157 | })(BottomNavigationAction); |
\ | No newline at end of file |