saleor-dashboard/src/components/IconButtonTableCell/IconButtonTableCell.tsx
Dominik Żegleń 935a6f4542
Reduce bundle size (#1103)
* Add analysis tools

* Use deep imports to reduce bundle size

* Remove tslint config

* Remove unused packages

* Remove lodash-es references

* Use root level mui imports

* Remove mui from restricted imports
2021-05-14 10:15:15 +02:00

46 lines
1.1 KiB
TypeScript

import { IconButton, TableCell } from "@material-ui/core";
import { makeStyles } from "@saleor/theme";
import classNames from "classnames";
import React from "react";
import { stopPropagation } from "../../misc";
import { ICONBUTTON_SIZE } from "../../theme";
export interface IconButtonTableCellProps {
children: React.ReactNode;
className?: string;
disabled?: boolean;
onClick: () => void;
}
const useStyles = makeStyles(
theme => ({
root: {
"&:last-child": {
paddingRight: 0
},
paddingRight: 0,
width: ICONBUTTON_SIZE + theme.spacing(0.5)
}
}),
{ name: "IconButtonTableCell" }
);
const IconButtonTableCell: React.FC<IconButtonTableCellProps> = props => {
const { children, className, disabled, onClick } = props;
const classes = useStyles(props);
return (
<TableCell className={classNames(classes.root, className)}>
<IconButton
color="primary"
disabled={disabled}
onClick={stopPropagation(onClick)}
>
{children}
</IconButton>
</TableCell>
);
};
IconButtonTableCell.displayName = "IconButtonTableCell";
export default IconButtonTableCell;