@patternfly/documentation-framework 6.0.0-alpha.99 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +271 -0
- package/components/autoLinkHeader/autoLinkHeader.js +1 -0
- package/components/cssVariables/cssVariables.js +63 -57
- package/components/footer/footer.js +52 -34
- package/components/sectionGallery/TextSummary.js +6 -6
- package/components/sectionGallery/sectionDataListLayout.js +7 -7
- package/components/sectionGallery/sectionGalleryToolbar.js +14 -14
- package/components/sideNav/sideNav.js +161 -71
- package/layouts/sideNavLayout/sideNavLayout.js +42 -93
- package/package.json +8 -8
- package/scripts/md/parseMD.js +3 -3
- package/scripts/md/styled-tags.js +1 -1
- package/scripts/md/typecheck.js +4 -0
- package/templates/mdx.js +248 -116
- package/versions.json +165 -20
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
Content,
|
|
10
10
|
} from '@patternfly/react-core';
|
|
11
11
|
import { Link } from '@patternfly/documentation-framework/components';
|
|
12
|
-
import { GithubIcon
|
|
12
|
+
import { GithubIcon } from '@patternfly/react-icons';
|
|
13
13
|
import redhatLogo from './RHLogo.png';
|
|
14
14
|
import redhatLogoDark from './RHLogoDark.png';
|
|
15
15
|
|
|
@@ -33,43 +33,43 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
33
33
|
md={4}
|
|
34
34
|
className="pf-v6-u-ml-md pf-v6-u-ml-0-on-md pf-v6-u-mb-xl pf-v6-u-mb-0-on-md"
|
|
35
35
|
>
|
|
36
|
-
<p className="ws-org-pfsite-footer-menu-list-title">
|
|
36
|
+
<p className="ws-org-pfsite-footer-menu-list-title">What's new</p>
|
|
37
37
|
<nav aria-label="Quick Links">
|
|
38
38
|
<List isPlain className="ws-org-pfsite-footer-menu-list">
|
|
39
39
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
40
40
|
<Link
|
|
41
41
|
className="ws-org-pfsite-footer-menu-link"
|
|
42
|
-
to=
|
|
43
|
-
aria-label="
|
|
42
|
+
to="/get-started/upgrade"
|
|
43
|
+
aria-label="Latest PatternFly upgrade guide"
|
|
44
44
|
>
|
|
45
|
-
|
|
45
|
+
Upgrade
|
|
46
46
|
</Link>
|
|
47
47
|
</ListItem>
|
|
48
48
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
49
49
|
<Link
|
|
50
50
|
className="ws-org-pfsite-footer-menu-link"
|
|
51
|
-
to="/
|
|
52
|
-
aria-label="PatternFly
|
|
51
|
+
to="/get-started/release-highlights/"
|
|
52
|
+
aria-label="PatternFly release highlights"
|
|
53
53
|
>
|
|
54
|
-
|
|
54
|
+
Releases
|
|
55
55
|
</Link>
|
|
56
56
|
</ListItem>
|
|
57
57
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
58
58
|
<Link
|
|
59
59
|
className="ws-org-pfsite-footer-menu-link"
|
|
60
|
-
to="/
|
|
61
|
-
aria-label="PatternFly
|
|
60
|
+
to="/patternfly-ai/about-ai"
|
|
61
|
+
aria-label="PatternFly's new AI resources"
|
|
62
62
|
>
|
|
63
|
-
|
|
63
|
+
PatternFly AI
|
|
64
64
|
</Link>
|
|
65
65
|
</ListItem>
|
|
66
66
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
67
67
|
<Link
|
|
68
68
|
className="ws-org-pfsite-footer-menu-link"
|
|
69
|
-
to="/
|
|
70
|
-
aria-label="PatternFly
|
|
69
|
+
to="/tokens/about-tokens"
|
|
70
|
+
aria-label="PatternFly's new token system"
|
|
71
71
|
>
|
|
72
|
-
|
|
72
|
+
Tokens
|
|
73
73
|
</Link>
|
|
74
74
|
</ListItem>
|
|
75
75
|
</List>
|
|
@@ -86,29 +86,28 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
86
86
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
87
87
|
<Link
|
|
88
88
|
className="ws-org-pfsite-footer-menu-link"
|
|
89
|
-
to="/get-started/
|
|
90
|
-
aria-label="
|
|
89
|
+
to="/get-started/about-patternfly"
|
|
90
|
+
aria-label="Learn about PatternFly"
|
|
91
91
|
>
|
|
92
|
-
|
|
92
|
+
About PatternFly
|
|
93
93
|
</Link>
|
|
94
94
|
</ListItem>
|
|
95
95
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
96
96
|
<Link
|
|
97
97
|
className="ws-org-pfsite-footer-menu-link"
|
|
98
|
-
to="/
|
|
99
|
-
aria-label="
|
|
98
|
+
to="https://github.com/patternfly/patternfly/blob/main/CODE_OF_CONDUCT.md"
|
|
99
|
+
aria-label="Our code of conduct for contributions"
|
|
100
100
|
>
|
|
101
|
-
|
|
101
|
+
Code of conduct
|
|
102
102
|
</Link>
|
|
103
103
|
</ListItem>
|
|
104
104
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
105
105
|
<Link
|
|
106
106
|
className="ws-org-pfsite-footer-menu-link"
|
|
107
|
-
to="
|
|
108
|
-
|
|
109
|
-
aria-label="PatternFly Code of Conduct"
|
|
107
|
+
to="/get-started/contribute"
|
|
108
|
+
aria-label="Learn how to contribute to PatternFly"
|
|
110
109
|
>
|
|
111
|
-
|
|
110
|
+
Contribute
|
|
112
111
|
</Link>
|
|
113
112
|
</ListItem>
|
|
114
113
|
</List>
|
|
@@ -119,9 +118,7 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
119
118
|
md={4}
|
|
120
119
|
className="pf-v6-u-mt-lg pf-v6-u-mt-0-on-md pf-v6-u-ml-md pf-v6-u-ml-0-on-md"
|
|
121
120
|
>
|
|
122
|
-
<p className="ws-org-pfsite-footer-menu-list-title">
|
|
123
|
-
Stay in touch
|
|
124
|
-
</p>
|
|
121
|
+
<p className="ws-org-pfsite-footer-menu-list-title">Community</p>
|
|
125
122
|
<nav aria-label="Stay in touch">
|
|
126
123
|
<List isPlain className="ws-org-pfsite-footer-menu-list">
|
|
127
124
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
@@ -137,11 +134,11 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
137
134
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
138
135
|
<Link
|
|
139
136
|
className="ws-org-pfsite-footer-menu-link"
|
|
140
|
-
to="//
|
|
137
|
+
to="//medium.com/patternfly"
|
|
141
138
|
target="top"
|
|
142
|
-
aria-label="
|
|
139
|
+
aria-label="Read the PatternFly blog"
|
|
143
140
|
>
|
|
144
|
-
|
|
141
|
+
Blog
|
|
145
142
|
</Link>
|
|
146
143
|
</ListItem>
|
|
147
144
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
@@ -157,11 +154,20 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
157
154
|
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
158
155
|
<Link
|
|
159
156
|
className="ws-org-pfsite-footer-menu-link"
|
|
160
|
-
to="
|
|
157
|
+
to="https://github.com/patternfly/patternfly/blob/main/CODE_OF_CONDUCT.md"
|
|
158
|
+
aria-label="Join PatternFly meetings"
|
|
159
|
+
>
|
|
160
|
+
Calendar
|
|
161
|
+
</Link>
|
|
162
|
+
</ListItem>
|
|
163
|
+
<ListItem className="ws-org-pfsite-footer-menu-list-item">
|
|
164
|
+
<Link
|
|
165
|
+
className="ws-org-pfsite-footer-menu-link"
|
|
166
|
+
to="//github.com/orgs/patternfly/discussions"
|
|
161
167
|
target="top"
|
|
162
|
-
aria-label="
|
|
168
|
+
aria-label="Visit the PatternFly discussion forum"
|
|
163
169
|
>
|
|
164
|
-
|
|
170
|
+
Discussions
|
|
165
171
|
</Link>
|
|
166
172
|
</ListItem>
|
|
167
173
|
</List>
|
|
@@ -237,6 +243,7 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
237
243
|
<Content
|
|
238
244
|
component="p"
|
|
239
245
|
className="ws-org-pfsite-footer-menu-about-description"
|
|
246
|
+
isEditorial
|
|
240
247
|
>
|
|
241
248
|
PatternFly is an open source design system built to drive
|
|
242
249
|
consistency and unify teams. From documentation and components
|
|
@@ -259,8 +266,19 @@ export const Footer = ({ isDarkTheme }) => (
|
|
|
259
266
|
target="top"
|
|
260
267
|
aria-label="Link to PatternFly X page"
|
|
261
268
|
>
|
|
262
|
-
<
|
|
269
|
+
<svg
|
|
270
|
+
className="pf-v6-svg"
|
|
271
|
+
viewBox="0 0 512 512"
|
|
272
|
+
fill="currentColor"
|
|
273
|
+
aria-hidden="true"
|
|
274
|
+
role="img"
|
|
275
|
+
width="1em"
|
|
276
|
+
height="1em"
|
|
277
|
+
>
|
|
278
|
+
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"></path>
|
|
279
|
+
</svg>
|
|
263
280
|
</Link>
|
|
281
|
+
{/* Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.*/}
|
|
264
282
|
</GridItem>
|
|
265
283
|
</Grid>
|
|
266
284
|
</GridItem>
|
|
@@ -4,17 +4,17 @@ import { Content } from "@patternfly/react-core";
|
|
|
4
4
|
|
|
5
5
|
// convert summary text from string to jsx, remove links
|
|
6
6
|
export const SummaryComponent = ({ id, itemsData }) => {
|
|
7
|
-
const itemDasherized = id.split(
|
|
7
|
+
const itemDasherized = id.split(" ").join("-").toLowerCase();
|
|
8
8
|
const summary = itemsData?.[itemDasherized]?.summary;
|
|
9
9
|
if (!summary) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
// Remove anchor tags to avoid <a> in summary nested within <a> of Link card/datalistitem
|
|
13
|
-
const summaryNoLinks = summary.replace(/<Link[^>]*>([^<]+)<\/Link>/gm,
|
|
13
|
+
const summaryNoLinks = summary.replace(/<Link[^>]*>([^<]+)<\/Link>/gm, "$1");
|
|
14
14
|
const { code } = convertToReactComponent(`<>${summaryNoLinks}</>`);
|
|
15
|
-
const getSummaryComponent = new Function(
|
|
15
|
+
const getSummaryComponent = new Function("React", code);
|
|
16
16
|
return getSummaryComponent(React);
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
19
|
export const TextSummary = ({ id, itemsData }) => {
|
|
20
20
|
if (!id) {
|
|
@@ -22,10 +22,10 @@ export const TextSummary = ({ id, itemsData }) => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<Content>
|
|
25
|
+
<Content isEditorial>
|
|
26
26
|
<Content component="p">
|
|
27
27
|
<SummaryComponent id={id} itemsData={itemsData} />
|
|
28
28
|
</Content>
|
|
29
29
|
</Content>
|
|
30
|
-
)
|
|
30
|
+
);
|
|
31
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
DataList,
|
|
4
4
|
DataListItem,
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
Content,
|
|
11
11
|
ContentVariants,
|
|
12
12
|
Label,
|
|
13
|
-
} from
|
|
14
|
-
import { Link } from
|
|
15
|
-
import { TextSummary } from
|
|
13
|
+
} from "@patternfly/react-core";
|
|
14
|
+
import { Link } from "../link/link";
|
|
15
|
+
import { TextSummary } from "./TextSummary";
|
|
16
16
|
|
|
17
17
|
export const SectionDataListLayout = ({
|
|
18
18
|
galleryItems,
|
|
@@ -20,7 +20,7 @@ export const SectionDataListLayout = ({
|
|
|
20
20
|
hasListText,
|
|
21
21
|
hasListImages,
|
|
22
22
|
}) => {
|
|
23
|
-
if (layoutView !==
|
|
23
|
+
if (layoutView !== "list") {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -55,9 +55,9 @@ export const SectionDataListLayout = ({
|
|
|
55
55
|
</DataListCell>
|
|
56
56
|
),
|
|
57
57
|
<DataListCell width={5} key="text-description">
|
|
58
|
-
<Split className={hasListText ?
|
|
58
|
+
<Split className={hasListText ? "pf-v6-u-mb-md" : null}>
|
|
59
59
|
<SplitItem isFilled>
|
|
60
|
-
<Content>
|
|
60
|
+
<Content isEditorial>
|
|
61
61
|
<Content component={ContentVariants.h2}>
|
|
62
62
|
<span>{title}</span>
|
|
63
63
|
</Content>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
4
|
SearchInput,
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
ContentVariants,
|
|
11
11
|
ToggleGroup,
|
|
12
12
|
ToggleGroupItem,
|
|
13
|
-
} from
|
|
14
|
-
import ListIcon from
|
|
15
|
-
import ThIcon from
|
|
13
|
+
} from "@patternfly/react-core";
|
|
14
|
+
import ListIcon from "@patternfly/react-icons/dist/esm/icons/list-icon";
|
|
15
|
+
import ThIcon from "@patternfly/react-icons/dist/esm/icons/th-icon";
|
|
16
16
|
|
|
17
17
|
export const SectionGalleryToolbar = ({
|
|
18
18
|
galleryItems,
|
|
@@ -20,8 +20,8 @@ export const SectionGalleryToolbar = ({
|
|
|
20
20
|
setSearchTerm,
|
|
21
21
|
layoutView,
|
|
22
22
|
setLayoutView,
|
|
23
|
-
placeholderText =
|
|
24
|
-
countText =
|
|
23
|
+
placeholderText = "Search by name",
|
|
24
|
+
countText = " items",
|
|
25
25
|
}) => (
|
|
26
26
|
<Toolbar isSticky>
|
|
27
27
|
<ToolbarContent>
|
|
@@ -35,7 +35,7 @@ export const SectionGalleryToolbar = ({
|
|
|
35
35
|
</ToolbarItem>
|
|
36
36
|
{searchTerm && (
|
|
37
37
|
<ToolbarItem>
|
|
38
|
-
<Button variant="link" onClick={() => setSearchTerm(
|
|
38
|
+
<Button variant="link" onClick={() => setSearchTerm("")}>
|
|
39
39
|
Reset
|
|
40
40
|
</Button>
|
|
41
41
|
</ToolbarItem>
|
|
@@ -46,25 +46,25 @@ export const SectionGalleryToolbar = ({
|
|
|
46
46
|
<ToggleGroupItem
|
|
47
47
|
icon={<ThIcon />}
|
|
48
48
|
aria-label="grid icon button"
|
|
49
|
-
isSelected={layoutView ===
|
|
50
|
-
onChange={() => setLayoutView(
|
|
49
|
+
isSelected={layoutView === "grid"}
|
|
50
|
+
onChange={() => setLayoutView("grid")}
|
|
51
51
|
></ToggleGroupItem>
|
|
52
52
|
<ToggleGroupItem
|
|
53
53
|
icon={<ListIcon />}
|
|
54
54
|
aria-label="list icon button"
|
|
55
|
-
isSelected={layoutView ===
|
|
56
|
-
onChange={() => setLayoutView(
|
|
55
|
+
isSelected={layoutView === "list"}
|
|
56
|
+
onChange={() => setLayoutView("list")}
|
|
57
57
|
></ToggleGroupItem>
|
|
58
58
|
</ToggleGroup>
|
|
59
59
|
</ToolbarItem>
|
|
60
60
|
</ToolbarGroup>
|
|
61
61
|
<ToolbarItem
|
|
62
62
|
variant="pagination"
|
|
63
|
-
gap={{ default:
|
|
64
|
-
style={{
|
|
63
|
+
gap={{ default: "gapMd", md: "gapNone" }}
|
|
64
|
+
style={{ "--pf-v6-c-toolbar__item--MinWidth": "max-content" }}
|
|
65
65
|
className="pf-m-align-self-center"
|
|
66
66
|
>
|
|
67
|
-
<Content component={ContentVariants.small}>
|
|
67
|
+
<Content isEditorial component={ContentVariants.small}>
|
|
68
68
|
{galleryItems.length}
|
|
69
69
|
{countText}
|
|
70
70
|
</Content>
|
|
@@ -1,61 +1,88 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Link } from '../link/link';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Label,
|
|
5
|
+
Nav,
|
|
6
|
+
NavList,
|
|
7
|
+
NavExpandable,
|
|
8
|
+
PageContextConsumer,
|
|
9
|
+
capitalize,
|
|
10
|
+
Flex,
|
|
11
|
+
FlexItem,
|
|
12
|
+
} from '@patternfly/react-core';
|
|
4
13
|
import { css } from '@patternfly/react-styles';
|
|
5
14
|
import { Location } from '@reach/router';
|
|
6
15
|
import { makeSlug } from '../../helpers';
|
|
7
|
-
|
|
8
|
-
//import globalBreakpointXl from "@patternfly/react-tokens/dist/esm/global_breakpoint_xl";
|
|
16
|
+
import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/t_global_breakpoint_xl';
|
|
9
17
|
import { trackEvent } from '../../helpers';
|
|
10
18
|
|
|
11
19
|
const getIsActive = (location, section, subsection = null) => {
|
|
12
20
|
const slug = makeSlug(null, section, null, null, subsection);
|
|
13
21
|
return location.pathname.startsWith(slug);
|
|
14
|
-
}
|
|
22
|
+
};
|
|
15
23
|
|
|
16
24
|
const defaultValue = 50;
|
|
17
25
|
|
|
18
26
|
const NavItem = ({ text, href, isDeprecated, isBeta, isDemo }) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const isMobileView = window.innerWidth < Number.parseInt("75rem", 10);
|
|
27
|
+
const isMobileView =
|
|
28
|
+
window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
|
|
22
29
|
return (
|
|
23
30
|
<PageContextConsumer key={href + text}>
|
|
24
|
-
{({onSidebarToggle, isSidebarOpen }) => (
|
|
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
|
-
|
|
31
|
+
{({ onSidebarToggle, isSidebarOpen }) => (
|
|
32
|
+
<li
|
|
33
|
+
key={href + text}
|
|
34
|
+
className="pf-v6-c-nav__item"
|
|
35
|
+
onClick={() => isMobileView && onSidebarToggle && onSidebarToggle()}
|
|
36
|
+
>
|
|
37
|
+
<Link
|
|
38
|
+
to={href}
|
|
39
|
+
getProps={({ isCurrent, href, location }) => {
|
|
40
|
+
const { pathname } = location;
|
|
41
|
+
return {
|
|
42
|
+
className: css(
|
|
43
|
+
'pf-v6-c-nav__link',
|
|
44
|
+
(isCurrent || pathname.startsWith(href + '/')) &&
|
|
45
|
+
'pf-m-current'
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
}}
|
|
49
|
+
tabIndex={isSidebarOpen ? undefined : -1}
|
|
50
|
+
>
|
|
51
|
+
<Flex spaceItems={{ default: 'spaceItemsSm' }}>
|
|
52
|
+
<FlexItem>{text}</FlexItem>
|
|
53
|
+
{(isBeta || isDemo || isDeprecated) && (
|
|
54
|
+
<FlexItem>
|
|
55
|
+
{isBeta && (
|
|
56
|
+
<Label color="blue" isCompact>
|
|
57
|
+
Beta
|
|
58
|
+
</Label>
|
|
59
|
+
)}
|
|
60
|
+
{!isBeta && isDeprecated && (
|
|
61
|
+
<Label color="grey" isCompact>
|
|
62
|
+
Deprecated
|
|
63
|
+
</Label>
|
|
64
|
+
)}
|
|
65
|
+
{!isBeta && !isDeprecated && isDemo && (
|
|
66
|
+
<Label color="purple" isCompact>
|
|
67
|
+
Demo
|
|
68
|
+
</Label>
|
|
69
|
+
)}
|
|
70
|
+
</FlexItem>
|
|
71
|
+
)}
|
|
72
|
+
</Flex>
|
|
73
|
+
</Link>
|
|
74
|
+
</li>
|
|
53
75
|
)}
|
|
54
76
|
</PageContextConsumer>
|
|
55
|
-
)
|
|
77
|
+
);
|
|
56
78
|
};
|
|
57
79
|
|
|
58
|
-
const ExpandableNav = ({
|
|
80
|
+
const ExpandableNav = ({
|
|
81
|
+
groupedRoutes,
|
|
82
|
+
location,
|
|
83
|
+
section,
|
|
84
|
+
subsection = null,
|
|
85
|
+
}) => {
|
|
59
86
|
const isActive = getIsActive(location, section, subsection);
|
|
60
87
|
const isSubsection = subsection;
|
|
61
88
|
const routes = isSubsection
|
|
@@ -75,39 +102,97 @@ const ExpandableNav = ({groupedRoutes, location, section, subsection = null}) =>
|
|
|
75
102
|
event.stopPropagation();
|
|
76
103
|
// Don't trigger for bubbled events from NavItems
|
|
77
104
|
if (!event.target.href) {
|
|
78
|
-
const isExpanded =
|
|
105
|
+
const isExpanded =
|
|
106
|
+
event.currentTarget.classList.contains('pf-m-expanded');
|
|
79
107
|
// 1 === expand section, 0 === collapse section
|
|
80
|
-
trackEvent(
|
|
108
|
+
trackEvent(
|
|
109
|
+
'sidenav_section_click',
|
|
110
|
+
'click_event',
|
|
111
|
+
analyticsName,
|
|
112
|
+
isExpanded ? 0 : 1
|
|
113
|
+
);
|
|
81
114
|
}
|
|
82
115
|
}}
|
|
83
116
|
>
|
|
84
117
|
{Object.entries(routes || {})
|
|
85
|
-
.filter(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
118
|
+
.filter(
|
|
119
|
+
([id, navObj]) =>
|
|
120
|
+
!Boolean(navObj.hideNavItem) && Object.entries(navObj).length > 0
|
|
121
|
+
)
|
|
122
|
+
.map(
|
|
123
|
+
([
|
|
124
|
+
id,
|
|
125
|
+
{
|
|
126
|
+
slug,
|
|
127
|
+
isSubsection = false,
|
|
128
|
+
sortValue = defaultValue,
|
|
129
|
+
subsectionSortValue = defaultValue,
|
|
130
|
+
sources,
|
|
131
|
+
},
|
|
132
|
+
]) => ({
|
|
133
|
+
text: id,
|
|
134
|
+
href: slug,
|
|
135
|
+
isSubsection,
|
|
136
|
+
sortValue: isSubsection ? subsectionSortValue : sortValue,
|
|
137
|
+
sources,
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
.sort(
|
|
141
|
+
(
|
|
142
|
+
{ text: text1, sortValue: sortValue1 },
|
|
143
|
+
{ text: text2, sortValue: sortValue2 }
|
|
144
|
+
) => {
|
|
145
|
+
if (sortValue1 === sortValue2) {
|
|
146
|
+
return text1.localeCompare(text2);
|
|
147
|
+
}
|
|
148
|
+
return sortValue1 > sortValue2 ? 1 : -1;
|
|
90
149
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
? ExpandableNav({
|
|
150
|
+
)
|
|
151
|
+
.map((navObj) => {
|
|
152
|
+
return navObj.isSubsection
|
|
153
|
+
? ExpandableNav({
|
|
154
|
+
groupedRoutes,
|
|
155
|
+
location,
|
|
156
|
+
section,
|
|
157
|
+
subsection: navObj.text,
|
|
158
|
+
})
|
|
95
159
|
: NavItem({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
...navObj,
|
|
161
|
+
isDeprecated:
|
|
162
|
+
navObj.href?.includes('components') &&
|
|
163
|
+
navObj.sources.some(
|
|
164
|
+
(source) =>
|
|
165
|
+
(source.source === 'react-deprecated' ||
|
|
166
|
+
source.source === 'html-deprecated') &&
|
|
167
|
+
// TODO: remove hardcoded Tile when Core PR merges
|
|
168
|
+
// https://github.com/patternfly/patternfly/pull/7178
|
|
169
|
+
(source.id === 'Tile' ||
|
|
170
|
+
!navObj.sources.some(
|
|
171
|
+
(source) =>
|
|
172
|
+
source.source === 'react' ||
|
|
173
|
+
source.source === 'html'
|
|
174
|
+
))
|
|
175
|
+
),
|
|
176
|
+
isBeta: navObj.sources.some(
|
|
177
|
+
(source) =>
|
|
178
|
+
source.beta &&
|
|
179
|
+
source.source !== 'react-next' &&
|
|
180
|
+
source.source !== 'react-templates'
|
|
181
|
+
),
|
|
182
|
+
isDemo: navObj.sources.some(
|
|
183
|
+
(source) =>
|
|
184
|
+
(source.source === 'react-demos' ||
|
|
185
|
+
source.source === 'html-demos') &&
|
|
186
|
+
!navObj.sources.some(
|
|
187
|
+
(source) =>
|
|
188
|
+
source.source === 'react' || source.source === 'html'
|
|
189
|
+
)
|
|
190
|
+
),
|
|
191
|
+
});
|
|
192
|
+
})}
|
|
108
193
|
</NavExpandable>
|
|
109
194
|
);
|
|
110
|
-
}
|
|
195
|
+
};
|
|
111
196
|
|
|
112
197
|
export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
|
|
113
198
|
React.useEffect(() => {
|
|
@@ -118,7 +203,8 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
|
|
|
118
203
|
if (!overflowElement) {
|
|
119
204
|
return;
|
|
120
205
|
}
|
|
121
|
-
const activeElements =
|
|
206
|
+
const activeElements =
|
|
207
|
+
overflowElement.getElementsByClassName('pf-m-current');
|
|
122
208
|
if (activeElements.length > 0) {
|
|
123
209
|
const lastElement = activeElements[activeElements.length - 1];
|
|
124
210
|
lastElement.scrollIntoView({ block: 'center' });
|
|
@@ -128,18 +214,22 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
|
|
|
128
214
|
return (
|
|
129
215
|
<Nav aria-label="Side Nav" theme="light">
|
|
130
216
|
<NavList className="ws-side-nav-list">
|
|
131
|
-
{navItems.map(({ section, text, href }) =>
|
|
132
|
-
? (
|
|
217
|
+
{navItems.map(({ section, text, href }) =>
|
|
218
|
+
section ? (
|
|
133
219
|
<Location key={section}>
|
|
134
|
-
{({ location }) =>
|
|
220
|
+
{({ location }) =>
|
|
221
|
+
ExpandableNav({ groupedRoutes, location, section })
|
|
222
|
+
}
|
|
135
223
|
</Location>
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
text:
|
|
139
|
-
|
|
224
|
+
) : (
|
|
225
|
+
NavItem({
|
|
226
|
+
text:
|
|
227
|
+
text || capitalize(href.replace(/\//g, '').replace(/-/g, ' ')),
|
|
228
|
+
href: href,
|
|
140
229
|
})
|
|
230
|
+
)
|
|
141
231
|
)}
|
|
142
232
|
</NavList>
|
|
143
233
|
</Nav>
|
|
144
234
|
);
|
|
145
|
-
}
|
|
235
|
+
};
|