1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
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 capitalize from '../utils/capitalize';
|
9 | export const styles = theme => ({
|
10 |
|
11 | root: _extends({}, theme.typography.button, {
|
12 | boxSizing: 'border-box',
|
13 | minHeight: 36,
|
14 | transition: theme.transitions.create(['background-color', 'box-shadow', 'border'], {
|
15 | duration: theme.transitions.duration.short
|
16 | }),
|
17 | borderRadius: '50%',
|
18 | padding: 0,
|
19 | minWidth: 0,
|
20 | width: 56,
|
21 | height: 56,
|
22 | boxShadow: theme.shadows[6],
|
23 | '&:active': {
|
24 | boxShadow: theme.shadows[12]
|
25 | },
|
26 | color: theme.palette.getContrastText(theme.palette.grey[300]),
|
27 | backgroundColor: theme.palette.grey[300],
|
28 | '&:hover': {
|
29 | backgroundColor: theme.palette.grey.A100,
|
30 |
|
31 | '@media (hover: none)': {
|
32 | backgroundColor: theme.palette.grey[300]
|
33 | },
|
34 | '&$disabled': {
|
35 | backgroundColor: theme.palette.action.disabledBackground
|
36 | },
|
37 | textDecoration: 'none'
|
38 | },
|
39 | '&$focusVisible': {
|
40 | boxShadow: theme.shadows[6]
|
41 | },
|
42 | '&$disabled': {
|
43 | color: theme.palette.action.disabled,
|
44 | boxShadow: theme.shadows[0],
|
45 | backgroundColor: theme.palette.action.disabledBackground
|
46 | }
|
47 | }),
|
48 |
|
49 |
|
50 | label: {
|
51 | width: '100%',
|
52 |
|
53 | display: 'inherit',
|
54 | alignItems: 'inherit',
|
55 | justifyContent: 'inherit'
|
56 | },
|
57 |
|
58 |
|
59 | primary: {
|
60 | color: theme.palette.primary.contrastText,
|
61 | backgroundColor: theme.palette.primary.main,
|
62 | '&:hover': {
|
63 | backgroundColor: theme.palette.primary.dark,
|
64 |
|
65 | '@media (hover: none)': {
|
66 | backgroundColor: theme.palette.primary.main
|
67 | }
|
68 | }
|
69 | },
|
70 |
|
71 |
|
72 | secondary: {
|
73 | color: theme.palette.secondary.contrastText,
|
74 | backgroundColor: theme.palette.secondary.main,
|
75 | '&:hover': {
|
76 | backgroundColor: theme.palette.secondary.dark,
|
77 |
|
78 | '@media (hover: none)': {
|
79 | backgroundColor: theme.palette.secondary.main
|
80 | }
|
81 | }
|
82 | },
|
83 |
|
84 |
|
85 | extended: {
|
86 | borderRadius: 48 / 2,
|
87 | padding: '0 16px',
|
88 | width: 'auto',
|
89 | minHeight: 'auto',
|
90 | minWidth: 48,
|
91 | height: 48,
|
92 | '&$sizeSmall': {
|
93 | width: 'auto',
|
94 | padding: '0 8px',
|
95 | borderRadius: 34 / 2,
|
96 | minWidth: 34,
|
97 | height: 34
|
98 | },
|
99 | '&$sizeMedium': {
|
100 | width: 'auto',
|
101 | padding: '0 16px',
|
102 | borderRadius: 40 / 2,
|
103 | minWidth: 40,
|
104 | height: 40
|
105 | }
|
106 | },
|
107 |
|
108 |
|
109 | focusVisible: {},
|
110 |
|
111 |
|
112 | disabled: {},
|
113 |
|
114 |
|
115 | colorInherit: {
|
116 | color: 'inherit'
|
117 | },
|
118 |
|
119 |
|
120 | sizeSmall: {
|
121 | width: 40,
|
122 | height: 40
|
123 | },
|
124 |
|
125 |
|
126 | sizeMedium: {
|
127 | width: 48,
|
128 | height: 48
|
129 | }
|
130 | });
|
131 | const Fab = React.forwardRef(function Fab(props, ref) {
|
132 | const {
|
133 | children,
|
134 | classes,
|
135 | className,
|
136 | color = 'default',
|
137 | component = 'button',
|
138 | disabled = false,
|
139 | disableFocusRipple = false,
|
140 | focusVisibleClassName,
|
141 | size = 'large',
|
142 | variant = 'round'
|
143 | } = props,
|
144 | other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "color", "component", "disabled", "disableFocusRipple", "focusVisibleClassName", "size", "variant"]);
|
145 |
|
146 | return React.createElement(ButtonBase, _extends({
|
147 | className: clsx(classes.root, className, variant !== "round" && classes.extended, size !== 'large' && classes[`size${capitalize(size)}`], disabled && classes.disabled, {
|
148 | 'primary': classes.primary,
|
149 | 'secondary': classes.secondary,
|
150 | 'inherit': classes.colorInherit
|
151 | }[color]),
|
152 | component: component,
|
153 | disabled: disabled,
|
154 | focusRipple: !disableFocusRipple,
|
155 | focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
|
156 | ref: ref
|
157 | }, other), React.createElement("span", {
|
158 | className: classes.label
|
159 | }, children));
|
160 | });
|
161 | process.env.NODE_ENV !== "production" ? Fab.propTypes = {
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | |
168 |
|
169 |
|
170 | children: PropTypes
|
171 |
|
172 | .node.isRequired,
|
173 |
|
174 | |
175 |
|
176 |
|
177 |
|
178 | classes: PropTypes.object,
|
179 |
|
180 | |
181 |
|
182 |
|
183 | className: PropTypes.string,
|
184 |
|
185 | |
186 |
|
187 |
|
188 | color: PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary']),
|
189 |
|
190 | |
191 |
|
192 |
|
193 |
|
194 | component: PropTypes
|
195 |
|
196 | .elementType,
|
197 |
|
198 | |
199 |
|
200 |
|
201 | disabled: PropTypes.bool,
|
202 |
|
203 | |
204 |
|
205 |
|
206 | disableFocusRipple: PropTypes.bool,
|
207 |
|
208 | |
209 |
|
210 |
|
211 | disableRipple: PropTypes.bool,
|
212 |
|
213 | |
214 |
|
215 |
|
216 | focusVisibleClassName: PropTypes.string,
|
217 |
|
218 | |
219 |
|
220 |
|
221 |
|
222 | href: PropTypes.string,
|
223 |
|
224 | |
225 |
|
226 |
|
227 |
|
228 | size: PropTypes.oneOf(['large', 'medium', 'small']),
|
229 |
|
230 | |
231 |
|
232 |
|
233 | variant: PropTypes.oneOf(['extended', 'round'])
|
234 | } : void 0;
|
235 | export default withStyles(styles, {
|
236 | name: 'MuiFab'
|
237 | })(Fab); |
\ | No newline at end of file |