ActionBar.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { FC } from 'react';
  2. import { IconButton, makeStyles, Theme, createStyles } from '@material-ui/core';
  3. import Icons from '../icons/Icons';
  4. import { ActionBarType } from './Types';
  5. import CustomToolTip from '../customToolTip/CustomToolTip';
  6. const useStyles = makeStyles((theme: Theme) =>
  7. createStyles({
  8. root: {
  9. position: 'relative',
  10. display: 'inline-block',
  11. marginRight: theme.spacing(1),
  12. },
  13. tip: {
  14. position: 'absolute',
  15. left: 0,
  16. bottom: '-10px',
  17. fontSize: '10px',
  18. textTransform: 'capitalize',
  19. textAlign: 'center',
  20. width: '100%',
  21. },
  22. disabled: {
  23. color: theme.palette.common.black,
  24. opacity: 0.15,
  25. },
  26. })
  27. );
  28. const ActionBar: FC<ActionBarType> = props => {
  29. const classes = useStyles();
  30. const { configs, row } = props;
  31. return (
  32. <>
  33. {configs.map(v => (
  34. <span className={`${classes.root} ${v.className}`} key={v.icon}>
  35. <CustomToolTip title={v.label || ''} placement="top">
  36. <IconButton
  37. aria-label={v.label || ''}
  38. onClickCapture={e => {
  39. e.stopPropagation();
  40. v.onClick(e, row);
  41. }}
  42. disabled={v.disabled ? v.disabled(row) : false}
  43. classes={{ disabled: classes.disabled }}
  44. >
  45. {Icons[v.icon]()}
  46. </IconButton>
  47. </CustomToolTip>
  48. </span>
  49. ))}
  50. </>
  51. );
  52. };
  53. export default ActionBar;