-
Notifications
You must be signed in to change notification settings - Fork 392
Expand file tree
/
Copy pathTabsHelp.tsx
More file actions
60 lines (55 loc) · 1.94 KB
/
Copy pathTabsHelp.tsx
File metadata and controls
60 lines (55 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { createRef, useState } from 'react';
import { Tabs, Tab, TabTitleText, TabAction, Popover } from '@patternfly/react-core';
import RhUiQuestionMarkCircleIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-icon';
export const TabsHelp: React.FunctionComponent = () => {
const [activeTabKey, setActiveTabKey] = useState<number>(0);
const tabs = ['Users', 'Containers', 'Database', 'Disabled', 'ARIA disabled', 'Help disabled'];
const helpPopover = (header: string, popoverRef: React.RefObject<any>) => (
<Popover
headerContent={<div>{header}</div>}
bodyContent={
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
</div>
}
footerContent="Popover footer"
triggerRef={popoverRef}
/>
);
return (
<Tabs
activeKey={activeTabKey}
onSelect={(event: any, tabIndex: string | number) => setActiveTabKey(tabIndex as number)}
aria-label="Tabs in the help action example"
role="region"
>
{tabs.map((tab, index) => {
const ref = createRef<HTMLElement>();
return (
<Tab
key={index}
eventKey={index}
aria-label={`Help action content - ${tab}`}
title={<TabTitleText>{tab}</TabTitleText>}
{...(tab === 'Disabled' && { isDisabled: true })}
{...(tab === 'ARIA disabled' && { isAriaDisabled: true })}
actions={
<>
<TabAction
aria-label={`Help action for ${tab}`}
ref={ref}
{...(tab === 'Help disabled' && { isDisabled: true })}
>
<RhUiQuestionMarkCircleIcon />
</TabAction>
{helpPopover(`Help popover for ${tab}`, ref)}
</>
}
>
{tab}
</Tab>
);
})}
</Tabs>
);
};