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

47 lines
1.1 KiB
TypeScript
Raw Normal View History

import { IconButton, TableCell } from "@material-ui/core";
import { makeStyles } from "@saleor/theme";
import classNames from "classnames";
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;
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 => {
const { children, className, disabled, onClick } = props;
2019-10-30 14:34:24 +00:00
const classes = useStyles(props);
return (
<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;