| 1 |
import { Component } from 'react'; |
| 2 |
import styles from '@patternfly/react-styles/css/components/MenuToggle/menu-toggle'; |
| 3 |
import { css } from '@patternfly/react-styles'; |
| 4 |
|
| 5 |
export interface MenuToggleActionProps { |
| 6 |
/** Additional classes added to the MenuToggleAction */ |
| 7 |
className?: string; |
| 8 |
/** Flag to show if the action button is disabled */ |
| 9 |
isDisabled?: boolean; |
| 10 |
/** A callback for when the action button is clicked */ |
| 11 |
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void; |
| 12 |
/** Element to be rendered inside the <button> */ |
| 13 |
children?: React.ReactNode; |
| 14 |
/** Id of the action button */ |
| 15 |
id?: string; |
| 16 |
} |
| 17 |
|
| 18 |
class MenuToggleAction extends Component<MenuToggleActionProps> { |
| 19 |
static displayName = 'MenuToggleAction'; |
| 20 |
static defaultProps: MenuToggleActionProps = { |
| 21 |
className: '', |
| 22 |
isDisabled: false, |
| 23 |
onClick: () => {} |
| 24 |
}; |
| 25 |
|
| 26 |
render() { |
| 27 |
const { id, className, onClick, isDisabled, children, ...props } = this.props; |
| 28 |
|
| 29 |
return ( |
| 30 |
<button |
| 31 |
id={id} |
| 32 |
className={css(styles.menuToggleButton, className)} |
| 33 |
onClick={onClick} |
| 34 |
type="button" |
| 35 |
disabled={isDisabled} |
| 36 |
{...props} |
| 37 |
> |
| 38 |
{children} |
| 39 |
</button> |
| 40 |
); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
export { MenuToggleAction }; |