@krowdy-ui/views
Version:
React components that implement Google's Material Design.
72 lines (70 loc) • 2.3 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { makeStyles, Tooltip, Typography } from '@krowdy-ui/core';
var Circle = function Circle(props) {
var _props$firstName = props.firstName,
firstName = _props$firstName === void 0 ? '' : _props$firstName,
_props$lastName = props.lastName,
lastName = _props$lastName === void 0 ? '' : _props$lastName,
subtitle = props.subtitle,
_props$max = props.max,
max = _props$max === void 0 ? 4 : _props$max,
_props$size = props.size,
size = _props$size === void 0 ? 4 : _props$size,
_props$selected = props.selected,
selected = _props$selected === void 0 ? false : _props$selected;
var classes = useStyles({
max: max,
size: size
});
return /*#__PURE__*/React.createElement(Tooltip, {
arrow: true,
placement: "top",
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
className: classes.tooltipTitle
}, firstName, " ", lastName), /*#__PURE__*/React.createElement(Typography, null, subtitle))
}, /*#__PURE__*/React.createElement("div", {
className: clsx(classes.root, selected ? classes.select : [classes.hover, classes.unselect])
}));
};
process.env.NODE_ENV !== "production" ? Circle.propTypes = {
firstName: PropTypes.string,
lastName: PropTypes.string,
max: PropTypes.number,
selected: PropTypes.bool,
size: PropTypes.number,
subtitle: PropTypes.string
} : void 0;
var useStyles = makeStyles(function (theme) {
return {
hover: {
'&:hover': {
backgroundColor: theme.palette.primary[300]
}
},
root: {
borderRadius: '50%',
height: function height(_ref) {
var size = _ref.size,
max = _ref.max;
return 6 / (max - 1) * size * 4;
},
width: function width(_ref2) {
var size = _ref2.size,
max = _ref2.max;
return 6 / (max - 1) * size * 4;
}
},
select: {
backgroundColor: theme.palette.primary[500]
},
unselect: {
backgroundColor: function backgroundColor(_ref3) {
var size = _ref3.size;
return theme.palette.secondary[size > 1 ? 100 : 0];
}
}
};
});
export default Circle;