You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ContextMenuItemGroup.tsx 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { ReactNode } from 'react';
  2. import { makeStyles } from 'tss-react/mui';
  3. import ContextMenuItem, { IProps as ItemProps } from './ContextMenuItem';
  4. interface IProps {
  5. /**
  6. * List of actions in this group.
  7. */
  8. actions?: Array<ItemProps>;
  9. /**
  10. * The children of the component.
  11. */
  12. children?: ReactNode;
  13. }
  14. const useStyles = makeStyles()(theme => {
  15. return {
  16. contextMenuItemGroup: {
  17. '&:not(:empty)': {
  18. padding: `${theme.spacing(2)} 0`
  19. },
  20. '& + &:not(:empty)': {
  21. borderTop: `1px solid ${theme.palette.ui03}`
  22. },
  23. '&:first-of-type': {
  24. paddingTop: 0
  25. },
  26. '&:last-of-type': {
  27. paddingBottom: 0
  28. }
  29. }
  30. };
  31. });
  32. const ContextMenuItemGroup = ({
  33. actions,
  34. children
  35. }: IProps) => {
  36. const { classes: styles } = useStyles();
  37. return (
  38. <div className = { styles.contextMenuItemGroup }>
  39. {children}
  40. {actions?.map(actionProps => (
  41. <ContextMenuItem
  42. key = { actionProps.text }
  43. { ...actionProps } />
  44. ))}
  45. </div>
  46. );
  47. };
  48. export default ContextMenuItemGroup;