jiti-meet/react/features/base/ui/components/web/ContextMenuItemGroup.tsx

62 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-09-13 07:36:00 +00:00
import { Theme } from '@mui/material';
import React, { ReactNode } from 'react';
2022-09-13 07:36:00 +00:00
import { makeStyles } from 'tss-react/mui';
import ContextMenuItem, { Props as ItemProps } from './ContextMenuItem';
2022-01-07 10:54:42 +00:00
type Props = {
/**
* List of actions in this group.
*/
actions?: Array<ItemProps>;
/**
2021-11-04 21:10:43 +00:00
* The children of the component.
*/
children?: ReactNode;
};
2022-09-13 07:36:00 +00:00
const useStyles = makeStyles()((theme: Theme) => {
return {
contextMenuItemGroup: {
'&:not(:empty)': {
2022-09-13 07:36:00 +00:00
padding: `${theme.spacing(2)} 0`
},
'& + &:not(:empty)': {
borderTop: `1px solid ${theme.palette.ui04}`
},
'&:first-of-type': {
paddingTop: 0
},
'&:last-of-type': {
paddingBottom: 0
}
}
};
});
const ContextMenuItemGroup = ({
actions,
children
}: Props) => {
2022-09-13 07:36:00 +00:00
const { classes: styles } = useStyles();
return (
<div className = { styles.contextMenuItemGroup }>
{children}
{actions?.map(actionProps => (
<ContextMenuItem
key = { actionProps.text }
{ ...actionProps } />
))}
</div>
);
};
export default ContextMenuItemGroup;