| 1 |
import { useState } from 'react'; |
| 2 |
import { Nav, NavExpandable, NavItem, NavItemSeparator, NavList } from '@patternfly/react-core'; |
| 3 |
|
| 4 |
export const NavMixed: React.FunctionComponent = () => { |
| 5 |
const [activeGroup, setActiveGroup] = useState(''); |
| 6 |
const [activeItem, setActiveItem] = useState('ungrouped_item-1'); |
| 7 |
|
| 8 |
const onSelect = ( |
| 9 |
_event: React.FormEvent<HTMLInputElement>, |
| 10 |
result: { itemId: number | string; groupId: number | string | null } |
| 11 |
) => { |
| 12 |
setActiveGroup(result.groupId as string); |
| 13 |
setActiveItem(result.itemId as string); |
| 14 |
}; |
| 15 |
|
| 16 |
return ( |
| 17 |
<Nav onSelect={onSelect} aria-label="Mixed global"> |
| 18 |
<NavList> |
| 19 |
<NavItem |
| 20 |
preventDefault |
| 21 |
id="mixed-1" |
| 22 |
to="#mixed-1" |
| 23 |
itemId="ungrouped_item-1" |
| 24 |
isActive={activeItem === 'ungrouped_item-1'} |
| 25 |
> |
| 26 |
Link 1 (not expandable) |
| 27 |
</NavItem> |
| 28 |
<NavExpandable |
| 29 |
title="Expandable section title 1" |
| 30 |
groupId="nav-mixed-group-1" |
| 31 |
isActive={activeGroup === 'nav-mixed-group-1'} |
| 32 |
> |
| 33 |
<NavItem |
| 34 |
preventDefault |
| 35 |
id="mixed-2" |
| 36 |
to="#mixed-2" |
| 37 |
groupId="nav-mixed-group-1" |
| 38 |
itemId="nav-mixed-group-1_item-1" |
| 39 |
isActive={activeItem === 'nav-mixed-group-1_item-1'} |
| 40 |
> |
| 41 |
Mixed Link 1 |
| 42 |
</NavItem> |
| 43 |
<NavItemSeparator /> |
| 44 |
<NavItem |
| 45 |
preventDefault |
| 46 |
id="mixed-3" |
| 47 |
to="#mixed-3" |
| 48 |
groupId="nav-mixed-group-1" |
| 49 |
itemId="nav-mixed-group-1_item-2" |
| 50 |
isActive={activeItem === 'nav-mixed-group-1_item-2'} |
| 51 |
> |
| 52 |
Mixed Link 2 |
| 53 |
</NavItem> |
| 54 |
<NavItem |
| 55 |
preventDefault |
| 56 |
id="mixed-4" |
| 57 |
to="#mixed-4" |
| 58 |
groupId="nav-mixed-group-1" |
| 59 |
itemId="nav-mixed-group-1_item-3" |
| 60 |
isActive={activeItem === 'nav-mixed-group-1_item-3'} |
| 61 |
> |
| 62 |
Mixed Link 3 |
| 63 |
</NavItem> |
| 64 |
</NavExpandable> |
| 65 |
<NavExpandable |
| 66 |
title="Expandable section title 2" |
| 67 |
groupId="nav-mixed-group-2" |
| 68 |
isActive={activeGroup === 'nav-mixed-group-2'} |
| 69 |
> |
| 70 |
<NavItem |
| 71 |
preventDefault |
| 72 |
id="mixed-5" |
| 73 |
to="#mixed-5" |
| 74 |
groupId="nav-mixed-group-2" |
| 75 |
itemId="nav-mixed-group-2_item-1" |
| 76 |
isActive={activeItem === 'nav-mixed-group-2_item-1'} |
| 77 |
> |
| 78 |
Mixed 2 Link 1 |
| 79 |
</NavItem> |
| 80 |
<NavItem |
| 81 |
preventDefault |
| 82 |
id="mixed-6" |
| 83 |
to="#mixed-6" |
| 84 |
groupId="nav-mixed-group-2" |
| 85 |
itemId="nav-mixed-group-2_item-2" |
| 86 |
isActive={activeItem === 'nav-mixed-group-2_item-2'} |
| 87 |
> |
| 88 |
Mixed 2 Link 2 |
| 89 |
</NavItem> |
| 90 |
<NavItem |
| 91 |
preventDefault |
| 92 |
id="mixed-7" |
| 93 |
to="#mixed-7" |
| 94 |
groupId="nav-mixed-group-2" |
| 95 |
itemId="nav-mixed-group-2_item-3" |
| 96 |
isActive={activeItem === 'nav-mixed-group-2_item-3'} |
| 97 |
> |
| 98 |
Mixed 2 Link 3 |
| 99 |
</NavItem> |
| 100 |
</NavExpandable> |
| 101 |
</NavList> |
| 102 |
</Nav> |
| 103 |
); |
| 104 |
}; |