| 1 |
import { useState } from 'react'; |
| 2 |
import { Tabs, Tab, TabTitleText, TabTitleIcon } from '@patternfly/react-core'; |
| 3 |
import RhUiUsersFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-users-fill-icon'; |
| 4 |
import RhUiContainerFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-container-fill-icon'; |
| 5 |
import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon'; |
| 6 |
import RhUiServerStackFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-server-stack-fill-icon'; |
| 7 |
import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon'; |
| 8 |
import RhUiInfrastructureFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-infrastructure-fill-icon'; |
| 9 |
|
| 10 |
export const TabsIconAndText: React.FunctionComponent = () => { |
| 11 |
const [activeTabKey, setActiveTabKey] = useState<string | number>(0); |
| 12 |
// Toggle currently active tab |
| 13 |
const handleTabClick = ( |
| 14 |
event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent, |
| 15 |
tabIndex: string | number |
| 16 |
) => { |
| 17 |
setActiveTabKey(tabIndex); |
| 18 |
}; |
| 19 |
|
| 20 |
return ( |
| 21 |
<Tabs |
| 22 |
activeKey={activeTabKey} |
| 23 |
onSelect={handleTabClick} |
| 24 |
aria-label="Tabs in the icons and text example" |
| 25 |
role="region" |
| 26 |
> |
| 27 |
<Tab |
| 28 |
eventKey={0} |
| 29 |
title={ |
| 30 |
<> |
| 31 |
<TabTitleIcon> |
| 32 |
<RhUiUsersFillIcon /> |
| 33 |
</TabTitleIcon>{' '} |
| 34 |
<TabTitleText>Users</TabTitleText>{' '} |
| 35 |
</> |
| 36 |
} |
| 37 |
aria-label="icons and text content" |
| 38 |
> |
| 39 |
Users |
| 40 |
</Tab> |
| 41 |
<Tab |
| 42 |
eventKey={1} |
| 43 |
title={ |
| 44 |
<> |
| 45 |
<TabTitleIcon> |
| 46 |
<RhUiContainerFillIcon /> |
| 47 |
</TabTitleIcon>{' '} |
| 48 |
<TabTitleText>Containers</TabTitleText>{' '} |
| 49 |
</> |
| 50 |
} |
| 51 |
> |
| 52 |
Containers |
| 53 |
</Tab> |
| 54 |
<Tab |
| 55 |
eventKey={2} |
| 56 |
title={ |
| 57 |
<> |
| 58 |
<TabTitleIcon> |
| 59 |
<DatabaseIcon /> |
| 60 |
</TabTitleIcon>{' '} |
| 61 |
<TabTitleText>Database</TabTitleText>{' '} |
| 62 |
</> |
| 63 |
} |
| 64 |
> |
| 65 |
Database |
| 66 |
</Tab> |
| 67 |
<Tab |
| 68 |
eventKey={3} |
| 69 |
title={ |
| 70 |
<> |
| 71 |
<TabTitleIcon> |
| 72 |
<RhUiServerStackFillIcon /> |
| 73 |
</TabTitleIcon>{' '} |
| 74 |
<TabTitleText>Server</TabTitleText>{' '} |
| 75 |
</> |
| 76 |
} |
| 77 |
> |
| 78 |
Server |
| 79 |
</Tab> |
| 80 |
<Tab |
| 81 |
eventKey={4} |
| 82 |
title={ |
| 83 |
<> |
| 84 |
<TabTitleIcon> |
| 85 |
<LaptopIcon /> |
| 86 |
</TabTitleIcon>{' '} |
| 87 |
<TabTitleText>System</TabTitleText>{' '} |
| 88 |
</> |
| 89 |
} |
| 90 |
> |
| 91 |
System |
| 92 |
</Tab> |
| 93 |
<Tab |
| 94 |
eventKey={6} |
| 95 |
title={ |
| 96 |
<> |
| 97 |
<TabTitleIcon> |
| 98 |
<RhUiInfrastructureFillIcon /> |
| 99 |
</TabTitleIcon>{' '} |
| 100 |
<TabTitleText>Network</TabTitleText>{' '} |
| 101 |
</> |
| 102 |
} |
| 103 |
> |
| 104 |
Network |
| 105 |
</Tab> |
| 106 |
</Tabs> |
| 107 |
); |
| 108 |
}; |