2019-06-19 14:40:52 +00:00
|
|
|
import IconButton from "@material-ui/core/IconButton";
|
|
|
|
import TableCell from "@material-ui/core/TableCell";
|
2021-03-30 07:40:18 +00:00
|
|
|
import { makeStyles } from "@saleor/theme";
|
2020-04-23 15:43:08 +00:00
|
|
|
import classNames from "classnames";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import { stopPropagation } from "../../misc";
|
|
|
|
import { ICONBUTTON_SIZE } from "../../theme";
|
|
|
|
|
|
|
|
export interface IconButtonTableCellProps {
|
|
|
|
children: React.ReactNode;
|
2020-04-23 15:43:08 +00:00
|
|
|
className?: string;
|
2019-06-19 14:40:52 +00:00
|
|
|
disabled?: boolean;
|
|
|
|
onClick: () => void;
|
|
|
|
}
|
|
|
|
|
2019-12-03 15:28:40 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
theme => ({
|
|
|
|
root: {
|
|
|
|
"&:last-child": {
|
|
|
|
paddingRight: 0
|
|
|
|
},
|
|
|
|
paddingRight: 0,
|
|
|
|
width: ICONBUTTON_SIZE + theme.spacing(0.5)
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{ name: "IconButtonTableCell" }
|
|
|
|
);
|
2019-10-30 14:34:24 +00:00
|
|
|
const IconButtonTableCell: React.FC<IconButtonTableCellProps> = props => {
|
2020-04-23 15:43:08 +00:00
|
|
|
const { children, className, disabled, onClick } = props;
|
2019-10-30 14:34:24 +00:00
|
|
|
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
2020-04-23 15:43:08 +00:00
|
|
|
<TableCell className={classNames(classes.root, className)}>
|
2019-06-19 14:40:52 +00:00
|
|
|
<IconButton
|
|
|
|
color="primary"
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={stopPropagation(onClick)}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</IconButton>
|
|
|
|
</TableCell>
|
2019-10-30 14:34:24 +00:00
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
IconButtonTableCell.displayName = "IconButtonTableCell";
|
|
|
|
export default IconButtonTableCell;
|