/
PageLayoutLightNav.js
208 lines (198 loc) · 5.94 KB
/
PageLayoutLightNav.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import React from 'react';
import {
Avatar,
Brand,
Button,
ButtonVariant,
Card,
CardBody,
Dropdown,
DropdownToggle,
DropdownItem,
DropdownSeparator,
Gallery,
GalleryItem,
KebabToggle,
Nav,
NavItem,
NavList,
NavVariants,
Page,
PageHeader,
PageSection,
PageSectionVariants,
PageSidebar,
SkipToContent,
TextContent,
Text,
Toolbar,
ToolbarGroup,
ToolbarItem
} from '@patternfly/react-core';
// make sure you've installed @patternfly/patternfly
import accessibleStyles from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
import spacingStyles from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import { css } from '@patternfly/react-styles';
import { BellIcon, CogIcon } from '@patternfly/react-icons';
import imgBrand from './imgBrand.png';
import imgAvatar from './imgAvatar.svg';
class PageLayoutLightNav extends React.Component {
constructor(props) {
super(props);
this.state = {
isDropdownOpen: false,
isKebabDropdownOpen: false,
activeItem: 0
};
}
onDropdownToggle = isDropdownOpen => {
this.setState({
isDropdownOpen
});
};
onDropdownSelect = event => {
this.setState({
isDropdownOpen: !this.state.isDropdownOpen
});
};
onKebabDropdownToggle = isKebabDropdownOpen => {
this.setState({
isKebabDropdownOpen
});
};
onKebabDropdownSelect = event => {
this.setState({
isKebabDropdownOpen: !this.state.isKebabDropdownOpen
});
};
onNavSelect = result => {
this.setState({
activeItem: result.itemId
});
};
render() {
const { isDropdownOpen, isKebabDropdownOpen, activeItem } = this.state;
const PageNav = (
<Nav onSelect={this.onNavSelect} aria-label="Nav">
<NavList variant={NavVariants.simple}>
<NavItem itemId={0} isActive={activeItem === 0}>
System Panel
</NavItem>
<NavItem itemId={1} isActive={activeItem === 1}>
Policy
</NavItem>
<NavItem itemId={2} isActive={activeItem === 2}>
Authentication
</NavItem>
<NavItem itemId={3} isActive={activeItem === 3}>
Network Services
</NavItem>
<NavItem itemId={4} isActive={activeItem === 4}>
Server
</NavItem>
</NavList>
</Nav>
);
const kebabDropdownItems = [
<DropdownItem>
<BellIcon /> Notifications
</DropdownItem>,
<DropdownItem>
<CogIcon /> Settings
</DropdownItem>
];
const userDropdownItems = [
<DropdownItem>Link</DropdownItem>,
<DropdownItem component="button">Action</DropdownItem>,
<DropdownItem isDisabled>Disabled Link</DropdownItem>,
<DropdownItem isDisabled component="button">
Disabled Action
</DropdownItem>,
<DropdownSeparator />,
<DropdownItem>Separated Link</DropdownItem>,
<DropdownItem component="button">Separated Action</DropdownItem>
];
const PageToolbar = (
<Toolbar>
<ToolbarGroup className={css(accessibleStyles.screenReader, accessibleStyles.visibleOnLg)}>
<ToolbarItem>
<Button id="simple-example-uid-01" aria-label="Notifications actions" variant={ButtonVariant.plain}>
<BellIcon />
</Button>
</ToolbarItem>
<ToolbarItem>
<Button id="simple-example-uid-02" aria-label="Settings actions" variant={ButtonVariant.plain}>
<CogIcon />
</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarGroup>
<ToolbarItem className={css(accessibleStyles.hiddenOnLg, spacingStyles.mr_0)}>
<Dropdown
isPlain
position="right"
onSelect={this.onKebabDropdownSelect}
toggle={<KebabToggle onToggle={this.onKebabDropdownToggle} />}
isOpen={isKebabDropdownOpen}
dropdownItems={kebabDropdownItems}
/>
</ToolbarItem>
<ToolbarItem className={css(accessibleStyles.screenReader, accessibleStyles.visibleOnMd)}>
<Dropdown
isPlain
position="right"
onSelect={this.onDropdownSelect}
isOpen={isDropdownOpen}
toggle={<DropdownToggle onToggle={this.onDropdownToggle}>Kyle Baker</DropdownToggle>}
dropdownItems={userDropdownItems}
/>
</ToolbarItem>
</ToolbarGroup>
</Toolbar>
);
const Header = (
<PageHeader
logo={<Brand src={imgBrand} alt="Patternfly Logo" />}
toolbar={PageToolbar}
avatar={<Avatar src={imgAvatar} alt="Avatar image" />}
showNavToggle
/>
);
const Sidebar = <PageSidebar nav={PageNav} />;
const pageId = 'main-content-page-layout-simple-nav';
const PageSkipToContent = <SkipToContent href={`#${pageId}`}>Skip to Content</SkipToContent>;
return (
<React.Fragment>
<Page
header={Header}
sidebar={Sidebar}
isManagedSidebar
skipToContent={PageSkipToContent}
mainContainerId={pageId}
>
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Main Title</Text>
<Text component="p">
Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
of it’s relative line height of 1.5.
</Text>
</TextContent>
</PageSection>
<PageSection>
<Gallery gutter="md">
{Array.apply(0, Array(10)).map((x, i) => (
<GalleryItem key={i}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
</GalleryItem>
))}
</Gallery>
</PageSection>
</Page>
</React.Fragment>
);
}
}
export default PageLayoutLightNav;