2019-06-19 14:40:52 +00:00
|
|
|
import Avatar from "@material-ui/core/Avatar";
|
2019-10-30 14:34:24 +00:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2019-06-19 14:40:52 +00:00
|
|
|
import TableCell from "@material-ui/core/TableCell";
|
|
|
|
import Cached from "@material-ui/icons/Cached";
|
2019-08-09 11:14:35 +00:00
|
|
|
import classNames from "classnames";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import Image from "../../icons/Image";
|
|
|
|
|
2019-11-04 13:36:25 +00:00
|
|
|
export const AVATAR_MARGIN = 32;
|
2019-08-09 11:14:35 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const useStyles = makeStyles(theme => ({
|
|
|
|
avatar: {
|
|
|
|
background: "none",
|
2019-11-04 13:36:25 +00:00
|
|
|
border: `1px solid ${theme.palette.divider}`,
|
2019-10-30 14:34:24 +00:00
|
|
|
borderRadius: 2,
|
|
|
|
color: "#bdbdbd",
|
|
|
|
display: "inline-flex",
|
|
|
|
padding: theme.spacing(0.5)
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
alignSelf: "center",
|
|
|
|
marginLeft: theme.spacing(2),
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
alignItems: "center",
|
|
|
|
display: "flex"
|
|
|
|
},
|
|
|
|
root: {
|
2019-11-04 13:36:25 +00:00
|
|
|
"&:not(first-child)": {
|
|
|
|
paddingLeft: 0
|
|
|
|
},
|
2019-10-30 14:34:24 +00:00
|
|
|
paddingRight: theme.spacing(3),
|
|
|
|
width: "1%"
|
|
|
|
}
|
|
|
|
}));
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
interface TableCellAvatarProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
className?: string;
|
|
|
|
thumbnail?: string;
|
|
|
|
avatarProps?: string;
|
2019-08-09 11:14:35 +00:00
|
|
|
children?: React.ReactNode | React.ReactNodeArray;
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const TableCellAvatar: React.FC<TableCellAvatarProps> = props => {
|
|
|
|
const { children, className, thumbnail, avatarProps, ...rest } = props;
|
|
|
|
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TableCell className={classNames(classes.root, className)} {...rest}>
|
2019-08-09 11:14:35 +00:00
|
|
|
<div className={classes.content}>
|
|
|
|
{thumbnail === undefined ? (
|
|
|
|
<Avatar className={classNames(classes.avatar, avatarProps)}>
|
|
|
|
<Cached color="primary" />
|
|
|
|
</Avatar>
|
|
|
|
) : thumbnail === null ? (
|
|
|
|
<Avatar className={classNames(classes.avatar, avatarProps)}>
|
|
|
|
<Image color="primary" />
|
|
|
|
</Avatar>
|
|
|
|
) : (
|
|
|
|
<Avatar
|
|
|
|
className={classNames(classes.avatar, avatarProps)}
|
|
|
|
src={thumbnail}
|
|
|
|
/>
|
|
|
|
)}
|
2019-08-28 14:41:17 +00:00
|
|
|
<div className={classes.children}>{children}</div>
|
2019-08-09 11:14:35 +00:00
|
|
|
</div>
|
2019-06-19 14:40:52 +00:00
|
|
|
</TableCell>
|
2019-10-30 14:34:24 +00:00
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
TableCellAvatar.displayName = "TableCellAvatar";
|
|
|
|
export default TableCellAvatar;
|