2019-06-19 14:40:52 +00:00
|
|
|
import Avatar from "@material-ui/core/Avatar";
|
|
|
|
import {
|
|
|
|
createStyles,
|
|
|
|
Theme,
|
|
|
|
withStyles,
|
|
|
|
WithStyles
|
|
|
|
} from "@material-ui/core/styles";
|
|
|
|
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-08-09 11:14:35 +00:00
|
|
|
export const AVATAR_MARGIN = 56;
|
|
|
|
|
2019-10-28 16:16:49 +00:00
|
|
|
const styles = theme =>
|
2019-06-19 14:40:52 +00:00
|
|
|
createStyles({
|
|
|
|
avatar: {
|
|
|
|
background: "none",
|
|
|
|
border: `1px solid ${theme.overrides.MuiCard.root.borderColor}`,
|
|
|
|
borderRadius: 2,
|
|
|
|
color: "#bdbdbd",
|
2019-08-09 11:14:35 +00:00
|
|
|
display: "inline-flex",
|
2019-10-28 16:16:49 +00:00
|
|
|
padding: theme.spacing(.5)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
2019-08-09 11:14:35 +00:00
|
|
|
children: {
|
|
|
|
alignSelf: "center",
|
2019-10-28 16:16:49 +00:00
|
|
|
marginLeft: theme.spacing(2),
|
2019-08-28 14:41:17 +00:00
|
|
|
width: "100%"
|
2019-08-09 11:14:35 +00:00
|
|
|
},
|
|
|
|
content: {
|
|
|
|
alignItems: "center",
|
|
|
|
display: "flex"
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
root: {
|
2019-10-28 16:16:49 +00:00
|
|
|
paddingRight: theme.spacing(3),
|
2019-06-19 14:40:52 +00:00
|
|
|
width: "1%"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
interface TableCellAvatarProps extends WithStyles<typeof styles> {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
const TableCellAvatar = withStyles(styles, { name: "TableCellAvatar" })(
|
2019-08-09 11:14:35 +00:00
|
|
|
({
|
|
|
|
classes,
|
|
|
|
children,
|
|
|
|
className,
|
|
|
|
thumbnail,
|
2019-09-27 13:42:16 +00:00
|
|
|
avatarProps,
|
|
|
|
...props
|
2019-08-09 11:14:35 +00:00
|
|
|
}: TableCellAvatarProps) => (
|
2019-09-27 13:42:16 +00:00
|
|
|
<TableCell className={classNames(classes.root, className)} {...props}>
|
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>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
TableCellAvatar.displayName = "TableCellAvatar";
|
|
|
|
export default TableCellAvatar;
|