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.1KB

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