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