saleor-dashboard/src/components/IconButtonTableCell/IconButtonTableCell.tsx

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import IconButton from "@material-ui/core/IconButton";
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";
2019-08-09 10:26:22 +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;
disabled?: boolean;
onClick: () => void;
}
2019-10-30 14:34:24 +00:00
const useStyles = makeStyles(theme => ({
root: {
"&:last-child": {
paddingRight: 0
},
paddingRight: 0,
width: ICONBUTTON_SIZE + theme.spacing(0.5)
}
}));
const IconButtonTableCell: React.FC<IconButtonTableCellProps> = props => {
const {
2019-06-19 14:40:52 +00:00
children,
2019-10-30 14:34:24 +00:00
2019-06-19 14:40:52 +00:00
disabled,
onClick
2019-10-30 14:34:24 +00:00
} = props;
const classes = useStyles(props);
return (
2019-06-19 14:40:52 +00:00
<TableCell className={classes.root}>
<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;