UNPKG

2.66 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 ButtonBase from '../ButtonBase';
8export const styles = theme => ({
9 /* Styles applied to the root element. */
10 root: {
11 display: 'block',
12 textAlign: 'inherit',
13 width: '100%',
14 '&:hover $focusHighlight': {
15 opacity: theme.palette.action.hoverOpacity
16 },
17 '&$focusVisible $focusHighlight': {
18 opacity: 0.12
19 }
20 },
21
22 /* Pseudo-class applied to the ButtonBase root element if the action area is keyboard focused. */
23 focusVisible: {},
24
25 /* Styles applied to the overlay that covers the action area when it is keyboard focused. */
26 focusHighlight: {
27 overflow: 'hidden',
28 pointerEvents: 'none',
29 position: 'absolute',
30 top: 0,
31 right: 0,
32 bottom: 0,
33 left: 0,
34 borderRadius: 'inherit',
35 opacity: 0,
36 backgroundColor: 'currentcolor',
37 transition: theme.transitions.create('opacity', {
38 duration: theme.transitions.duration.short
39 })
40 }
41});
42const CardActionArea = /*#__PURE__*/React.forwardRef(function CardActionArea(props, ref) {
43 const {
44 children,
45 classes,
46 className,
47 focusVisibleClassName
48 } = props,
49 other = _objectWithoutPropertiesLoose(props, ["children", "classes", "className", "focusVisibleClassName"]);
50
51 return /*#__PURE__*/React.createElement(ButtonBase, _extends({
52 className: clsx(classes.root, className),
53 focusVisibleClassName: clsx(focusVisibleClassName, classes.focusVisible),
54 ref: ref
55 }, other), children, /*#__PURE__*/React.createElement("span", {
56 className: classes.focusHighlight
57 }));
58});
59process.env.NODE_ENV !== "production" ? CardActionArea.propTypes = {
60 // ----------------------------- Warning --------------------------------
61 // | These PropTypes are generated from the TypeScript type definitions |
62 // | To update them edit the d.ts file and run "yarn proptypes" |
63 // ----------------------------------------------------------------------
64
65 /**
66 * The content of the component.
67 */
68 children: PropTypes.node,
69
70 /**
71 * Override or extend the styles applied to the component.
72 * See [CSS API](#css) below for more details.
73 */
74 classes: PropTypes.object,
75
76 /**
77 * @ignore
78 */
79 className: PropTypes.string,
80
81 /**
82 * @ignore
83 */
84 focusVisibleClassName: PropTypes.string
85} : void 0;
86export default withStyles(styles, {
87 name: 'MuiCardActionArea'
88})(CardActionArea);
\No newline at end of file