| 1 |
import { css } from '@patternfly/react-styles'; |
| 2 |
import styles from '@patternfly/react-styles/css/components/OverflowMenu/overflow-menu'; |
| 3 |
import { OverflowMenuContext } from './OverflowMenuContext'; |
| 4 |
|
| 5 |
export interface OverflowMenuGroupProps extends React.HTMLProps<HTMLDivElement> { |
| 6 |
/** Any elements that can be rendered in the menu */ |
| 7 |
children?: any; |
| 8 |
/** Additional classes added to the OverflowMenuGroup */ |
| 9 |
className?: string; |
| 10 |
/** Modifies the overflow menu group visibility */ |
| 11 |
isPersistent?: boolean; |
| 12 |
/** Indicates a button or icon group */ |
| 13 |
groupType?: 'button' | 'icon'; |
| 14 |
} |
| 15 |
|
| 16 |
export const OverflowMenuGroup: React.FunctionComponent<OverflowMenuGroupProps> = ({ |
| 17 |
className, |
| 18 |
children, |
| 19 |
isPersistent = false, |
| 20 |
groupType, |
| 21 |
...props |
| 22 |
}: OverflowMenuGroupProps) => ( |
| 23 |
<OverflowMenuContext.Consumer> |
| 24 |
{(value) => |
| 25 |
(isPersistent || !value.isBelowBreakpoint) && ( |
| 26 |
<div |
| 27 |
className={css( |
| 28 |
styles.overflowMenuGroup, |
| 29 |
groupType === 'button' && styles.modifiers.buttonGroup, |
| 30 |
groupType === 'icon' && styles.modifiers.iconButtonGroup, |
| 31 |
className |
| 32 |
)} |
| 33 |
{...props} |
| 34 |
> |
| 35 |
{children} |
| 36 |
</div> |
| 37 |
) |
| 38 |
} |
| 39 |
</OverflowMenuContext.Consumer> |
| 40 |
); |
| 41 |
OverflowMenuGroup.displayName = 'OverflowMenuGroup'; |