Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ContextMenuItemGroup.tsx 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { makeStyles } from '@material-ui/core';
  2. import React, { ReactNode } from 'react';
  3. import ContextMenuItem, { Props as ItemProps } from './ContextMenuItem';
  4. type Props = {
  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: any) => {
  15. return {
  16. contextMenuItemGroup: {
  17. '&:not(:empty)': {
  18. padding: `${theme.spacing(2)}px 0`
  19. },
  20. '& + &:not(:empty)': {
  21. borderTop: `1px solid ${theme.palette.ui04}`
  22. }
  23. }
  24. };
  25. });
  26. const ContextMenuItemGroup = ({
  27. actions,
  28. children
  29. }: Props) => {
  30. const styles = useStyles();
  31. return (
  32. <div className = { styles.contextMenuItemGroup }>
  33. {children}
  34. {actions && actions.map(actionProps => (
  35. <ContextMenuItem
  36. key = { actionProps.text }
  37. { ...actionProps } />
  38. ))}
  39. </div>
  40. );
  41. };
  42. export default ContextMenuItemGroup;