| 1 |
/* eslint-disable no-console */ |
| 2 |
|
| 3 |
import { useRef, useState } from 'react'; |
| 4 |
import { |
| 5 |
Compass, |
| 6 |
CompassHeader, |
| 7 |
CompassHero, |
| 8 |
CompassContent, |
| 9 |
CompassMainHeader, |
| 10 |
Panel, |
| 11 |
PanelMain, |
| 12 |
PanelMainBody, |
| 13 |
CompassMessageBar, |
| 14 |
CompassNavContent, |
| 15 |
CompassNavHome, |
| 16 |
CompassNavMain, |
| 17 |
CompassNavSearch, |
| 18 |
Hero, |
| 19 |
Tabs, |
| 20 |
TabsComponent, |
| 21 |
Tab, |
| 22 |
TabContent, |
| 23 |
TabTitleText, |
| 24 |
ActionList, |
| 25 |
ActionListGroup, |
| 26 |
ActionListItem, |
| 27 |
Button, |
| 28 |
Title, |
| 29 |
Tooltip |
| 30 |
} from '@patternfly/react-core'; |
| 31 |
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon'; |
| 32 |
import OutlinedPlusSquare from '@patternfly/react-icons/dist/esm/icons/outlined-plus-square-icon'; |
| 33 |
import RhUiCopyIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-copy-icon'; |
| 34 |
import RhUiQuestionMarkCircleIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-icon'; |
| 35 |
|
| 36 |
export const CompassBasic: React.FunctionComponent = () => { |
| 37 |
const [activeTab, setActiveTab] = useState<number>(0); |
| 38 |
const [activeSubtab, setActiveSubtab] = useState<number>(0); |
| 39 |
const subTabsRef = useRef<HTMLDivElement>(null); |
| 40 |
|
| 41 |
const navContent = ( |
| 42 |
<> |
| 43 |
<Panel isPill isGlass> |
| 44 |
<PanelMain> |
| 45 |
<PanelMainBody> |
| 46 |
<CompassNavContent> |
| 47 |
<CompassNavHome onClick={() => console.log('Home')} /> |
| 48 |
<CompassNavMain> |
| 49 |
<Tabs |
| 50 |
activeKey={activeTab} |
| 51 |
isNav |
| 52 |
onSelect={(_event, tabIndex) => setActiveTab(tabIndex as number)} |
| 53 |
component={TabsComponent.nav} |
| 54 |
aria-label="Compass navigation tabs" |
| 55 |
> |
| 56 |
<Tab |
| 57 |
tabContentId="subtabs" |
| 58 |
tabContentRef={subTabsRef} |
| 59 |
eventKey={0} |
| 60 |
title={<TabTitleText>Tab 1</TabTitleText>} |
| 61 |
aria-label="Compass tab with subtabs" |
| 62 |
/> |
| 63 |
<Tab eventKey={1} title={<TabTitleText>Tab 2</TabTitleText>} /> |
| 64 |
<Tab eventKey={2} title={<TabTitleText>Tab 3</TabTitleText>} /> |
| 65 |
<Tab eventKey={3} title={<TabTitleText>Disabled Tab 4</TabTitleText>} isDisabled /> |
| 66 |
</Tabs> |
| 67 |
</CompassNavMain> |
| 68 |
<CompassNavSearch onClick={() => console.log('Search')} /> |
| 69 |
</CompassNavContent> |
| 70 |
</PanelMainBody> |
| 71 |
</PanelMain> |
| 72 |
</Panel> |
| 73 |
<Panel isPill isGlass> |
| 74 |
<PanelMain> |
| 75 |
<PanelMainBody style={{ padding: 0 }}> |
| 76 |
<TabContent id="subtabs" ref={subTabsRef}> |
| 77 |
<CompassNavContent> |
| 78 |
<CompassNavMain> |
| 79 |
<Tabs |
| 80 |
activeKey={activeSubtab} |
| 81 |
isSubtab |
| 82 |
isNav |
| 83 |
onSelect={(_event, tabIndex) => setActiveSubtab(tabIndex as number)} |
| 84 |
aria-label="Compass navigation subtabs" |
| 85 |
> |
| 86 |
<Tab |
| 87 |
tabContentId="subtab-1" |
| 88 |
eventKey={0} |
| 89 |
title={ |
| 90 |
<TabTitleText> |
| 91 |
<div id="subtab-1">Subtab 1</div> |
| 92 |
</TabTitleText> |
| 93 |
} |
| 94 |
/> |
| 95 |
<Tab eventKey={1} title={<TabTitleText>Subtab 2</TabTitleText>} /> |
| 96 |
<Tab eventKey={2} title={<TabTitleText>Disabled Subtab 3</TabTitleText>} isDisabled /> |
| 97 |
</Tabs> |
| 98 |
</CompassNavMain> |
| 99 |
</CompassNavContent> |
| 100 |
</TabContent> |
| 101 |
</PanelMainBody> |
| 102 |
</PanelMain> |
| 103 |
</Panel> |
| 104 |
</> |
| 105 |
); |
| 106 |
|
| 107 |
const sidebarContent = ( |
| 108 |
<Panel isPill isGlass> |
| 109 |
<PanelMain> |
| 110 |
<PanelMainBody> |
| 111 |
<ActionList isIconList isVertical> |
| 112 |
<ActionListGroup> |
| 113 |
<ActionListItem> |
| 114 |
<Tooltip content="Play"> |
| 115 |
<Button isCircle variant="plain" icon={<PlayIcon />} aria-label="Play" /> |
| 116 |
</Tooltip> |
| 117 |
</ActionListItem> |
| 118 |
<ActionListItem> |
| 119 |
<Tooltip content="Add"> |
| 120 |
<Button isCircle variant="plain" icon={<OutlinedPlusSquare />} aria-label="Add" /> |
| 121 |
</Tooltip> |
| 122 |
</ActionListItem> |
| 123 |
</ActionListGroup> |
| 124 |
<ActionListItem> |
| 125 |
<Tooltip content="Copy"> |
| 126 |
<Button isCircle variant="plain" icon={<RhUiCopyIcon />} aria-label="Copy" /> |
| 127 |
</Tooltip> |
| 128 |
</ActionListItem> |
| 129 |
<ActionListGroup> |
| 130 |
<ActionListItem> |
| 131 |
<Tooltip content="Help"> |
| 132 |
<Button isCircle variant="plain" icon={<RhUiQuestionMarkCircleIcon />} aria-label="Help" /> |
| 133 |
</Tooltip> |
| 134 |
</ActionListItem> |
| 135 |
<ActionListItem> |
| 136 |
<Tooltip content="Second copy"> |
| 137 |
<Button isCircle variant="plain" icon={<RhUiCopyIcon />} aria-label="Copy2" /> |
| 138 |
</Tooltip> |
| 139 |
</ActionListItem> |
| 140 |
</ActionListGroup> |
| 141 |
</ActionList> |
| 142 |
</PanelMainBody> |
| 143 |
</PanelMain> |
| 144 |
</Panel> |
| 145 |
); |
| 146 |
|
| 147 |
const headerContent = <CompassHeader logo={<div>logo</div>} nav={navContent} profile={<div>Profile</div>} />; |
| 148 |
const sidebarStartContent = sidebarContent; |
| 149 |
const mainContent = ( |
| 150 |
<> |
| 151 |
<CompassHero> |
| 152 |
<Hero isGlass gradientDark={{ stop1: '#000', stop2: '#1b0d33', stop3: '#3d2785' }}> |
| 153 |
Hero |
| 154 |
</Hero> |
| 155 |
</CompassHero> |
| 156 |
<CompassMainHeader title={<Title headingLevel="h1">Content title</Title>} panelProps={{ isGlass: true }} /> |
| 157 |
<CompassContent> |
| 158 |
<Panel isScrollable isAutoHeight isGlass> |
| 159 |
<PanelMain> |
| 160 |
<PanelMainBody>Content</PanelMainBody> |
| 161 |
</PanelMain> |
| 162 |
</Panel> |
| 163 |
</CompassContent> |
| 164 |
</> |
| 165 |
); |
| 166 |
const sidebarEndContent = sidebarContent; |
| 167 |
const footerContent = ( |
| 168 |
<CompassMessageBar> |
| 169 |
<Panel isPill isGlass> |
| 170 |
<PanelMain> |
| 171 |
<PanelMainBody style={{ padding: 0 }}>Message bar</PanelMainBody> |
| 172 |
</PanelMain> |
| 173 |
</Panel> |
| 174 |
</CompassMessageBar> |
| 175 |
); |
| 176 |
|
| 177 |
return ( |
| 178 |
<Compass |
| 179 |
header={headerContent} |
| 180 |
sidebarStart={sidebarStartContent} |
| 181 |
main={mainContent} |
| 182 |
sidebarEnd={sidebarEndContent} |
| 183 |
footer={footerContent} |
| 184 |
backgroundSrcDark="/assets/images/pf-background.svg" |
| 185 |
backgroundSrcLight="/assets/images/pf-background.svg" |
| 186 |
/> |
| 187 |
); |
| 188 |
}; |