@krowdy-ui/core
Version:
React components that implement Google's Material Design.
74 lines (69 loc) • 2.39 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "classes", "hoverable", "selected"];
import React from 'react';
import MuiCard from '@material-ui/core/Card';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { withStyles } from '@krowdy-ui/styles';
export var styles = function styles(theme) {
return {
hoverable: {
'&:hover': {
border: "1px solid ".concat(theme.palette.primary.main),
boxShadow: '0px 4px 5px rgba(0, 39, 102, 0.08), 0px 3px 14px rgba(0, 39, 102, 0.04), 0px 8px 10px rgba(0, 39, 102, 0.05)',
cursor: 'pointer',
margin: function margin(props) {
return props.variant !== 'outlined' ? -1 : '';
}
}
},
selected: {
border: "1px solid ".concat(theme.palette.primary.main),
boxShadow: '0px 4px 5px rgba(0, 39, 102, 0.08), 0px 3px 14px rgba(0, 39, 102, 0.04), 0px 8px 10px rgba(0, 39, 102, 0.05)',
cursor: 'pointer',
margin: function margin(props) {
return props.variant !== 'outlined' ? -1 : '';
}
}
};
};
var Card = React.forwardRef(function Card(props, ref) {
var classNameProps = props.className,
classes = props.classes,
_props$hoverable = props.hoverable,
hoverable = _props$hoverable === void 0 ? false : _props$hoverable,
_props$selected = props.selected,
selected = _props$selected === void 0 ? false : _props$selected,
otherProps = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/React.createElement(MuiCard, _extends({
className: clsx(classNameProps, hoverable && classes.hoverable, selected && classes.selected),
ref: ref
}, otherProps));
});
process.env.NODE_ENV !== "production" ? Card.propTypes = {
/**
* The content of the Card.
*/
children: PropTypes.node.isRequired,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
className: PropTypes.string,
/**
* @ignore
*/
classes: PropTypes.object,
/**
* If `true`, the Card will be hover.
*/
hoverable: PropTypes.bool,
/**
* if `true`, the Card will be selected.
*/
selected: PropTypes.bool
} : void 0;
export default withStyles(styles, {
name: 'KrowdyCard'
})(Card);