| 1 |
import { useState } from 'react'; |
| 2 |
import { Menu, MenuContent, MenuList, MenuItem } from '@patternfly/react-core'; |
| 3 |
import RhUiBranchFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-branch-fill-icon'; |
| 4 |
import RhUiServerStackFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-server-stack-fill-icon'; |
| 5 |
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; |
| 6 |
|
| 7 |
export const MenuWithIcons: React.FunctionComponent = () => { |
| 8 |
const [activeItem, setActiveItem] = useState(0); |
| 9 |
|
| 10 |
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, itemId: number | string | undefined) => { |
| 11 |
const item = itemId as number; // eslint-disable-next-line no-console |
| 12 |
console.log(`clicked ${item}`); |
| 13 |
setActiveItem(item); |
| 14 |
}; |
| 15 |
|
| 16 |
return ( |
| 17 |
<Menu onSelect={onSelect} activeItemId={activeItem}> |
| 18 |
<MenuContent> |
| 19 |
<MenuList> |
| 20 |
<MenuItem icon={<RhUiBranchFillIcon />} itemId={0}> |
| 21 |
From git |
| 22 |
</MenuItem> |
| 23 |
<MenuItem icon={<RhUiServerStackFillIcon />} itemId={1}> |
| 24 |
Container image |
| 25 |
</MenuItem> |
| 26 |
<MenuItem icon={<CubeIcon />} itemId={2}> |
| 27 |
Docker file |
| 28 |
</MenuItem> |
| 29 |
</MenuList> |
| 30 |
</MenuContent> |
| 31 |
</Menu> |
| 32 |
); |
| 33 |
}; |