| 1 |
import { useState } from 'react'; |
| 2 |
import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core'; |
| 3 |
|
| 4 |
export const TabsDefaultOverflow: React.FunctionComponent = () => { |
| 5 |
const [activeTabKey, setActiveTabKey] = useState<string | number>(0); |
| 6 |
const [isBox, setIsBox] = useState<boolean>(false); |
| 7 |
// Toggle currently active tab |
| 8 |
const handleTabClick = ( |
| 9 |
event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent, |
| 10 |
tabIndex: string | number |
| 11 |
) => { |
| 12 |
setActiveTabKey(tabIndex); |
| 13 |
}; |
| 14 |
|
| 15 |
const toggleBox = (checked: boolean) => { |
| 16 |
setIsBox(checked); |
| 17 |
}; |
| 18 |
|
| 19 |
return ( |
| 20 |
<div> |
| 21 |
<Tabs |
| 22 |
activeKey={activeTabKey} |
| 23 |
onSelect={handleTabClick} |
| 24 |
isBox={isBox} |
| 25 |
aria-label="Tabs in the default overflow example" |
| 26 |
role="region" |
| 27 |
> |
| 28 |
<Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Default overflow content users"> |
| 29 |
Users |
| 30 |
</Tab> |
| 31 |
<Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}> |
| 32 |
Containers |
| 33 |
</Tab> |
| 34 |
<Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}> |
| 35 |
Database |
| 36 |
</Tab> |
| 37 |
<Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}> |
| 38 |
Server |
| 39 |
</Tab> |
| 40 |
<Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}> |
| 41 |
System |
| 42 |
</Tab> |
| 43 |
<Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}> |
| 44 |
Network |
| 45 |
</Tab> |
| 46 |
<Tab eventKey={7} title={<TabTitleText>Tab item 7</TabTitleText>}> |
| 47 |
Tab 7 section |
| 48 |
</Tab> |
| 49 |
<Tab eventKey={8} title={<TabTitleText>Tab item 8</TabTitleText>}> |
| 50 |
Tab 8 section |
| 51 |
</Tab> |
| 52 |
<Tab eventKey={9} title={<TabTitleText>Tab item 9</TabTitleText>}> |
| 53 |
Tab 9 section |
| 54 |
</Tab> |
| 55 |
<Tab eventKey={10} title={<TabTitleText>Tab item 10</TabTitleText>}> |
| 56 |
Tab 10 section |
| 57 |
</Tab> |
| 58 |
<Tab eventKey={11} title={<TabTitleText>Tab item 11</TabTitleText>}> |
| 59 |
Tab 11 section |
| 60 |
</Tab> |
| 61 |
</Tabs> |
| 62 |
<div style={{ marginTop: '20px' }}> |
| 63 |
<Checkbox |
| 64 |
label="isBox" |
| 65 |
isChecked={isBox} |
| 66 |
onChange={(_event, checked) => toggleBox(checked)} |
| 67 |
aria-label="show box variation checkbox on overflow" |
| 68 |
id="toggle-box-overflow" |
| 69 |
name="toggle-box-overflow" |
| 70 |
/> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
); |
| 74 |
}; |