Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ContextMenuItemGroup.tsx 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. '&:first-of-type': {
  25. paddingTop: 0
  26. },
  27. '&:last-of-type': {
  28. paddingBottom: 0
  29. }
  30. }
  31. };
  32. });
  33. const ContextMenuItemGroup = ({
  34. actions,
  35. children
  36. }: Props) => {
  37. const { classes: styles } = useStyles();
  38. return (
  39. <div className = { styles.contextMenuItemGroup }>
  40. {children}
  41. {actions?.map(actionProps => (
  42. <ContextMenuItem
  43. key = { actionProps.text }
  44. { ...actionProps } />
  45. ))}
  46. </div>
  47. );
  48. };
  49. export default ContextMenuItemGroup;