Skip to content

Commit 99aee19

Browse files
authored
chore(docs): remove harded-coded tile deprecation (patternfly#4378)
* chore(docs): remove harded-coded tile deprecation * fix docs-framework version
1 parent c73692f commit 99aee19

File tree

5 files changed

+147
-284
lines changed

5 files changed

+147
-284
lines changed

packages/documentation-framework/components/sideNav/sideNav.js

+26-79
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
PageContextConsumer,
99
capitalize,
1010
Flex,
11-
FlexItem,
11+
FlexItem
1212
} from '@patternfly/react-core';
1313
import { css } from '@patternfly/react-styles';
1414
import { Location } from '@reach/router';
@@ -24,8 +24,7 @@ const getIsActive = (location, section, subsection = null) => {
2424
const defaultValue = 50;
2525

2626
const NavItem = ({ text, href, isDeprecated, isBeta, isDemo }) => {
27-
const isMobileView =
28-
window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
27+
const isMobileView = window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
2928
return (
3029
<PageContextConsumer key={href + text}>
3130
{({ onSidebarToggle, isSidebarOpen }) => (
@@ -39,11 +38,7 @@ const NavItem = ({ text, href, isDeprecated, isBeta, isDemo }) => {
3938
getProps={({ isCurrent, href, location }) => {
4039
const { pathname } = location;
4140
return {
42-
className: css(
43-
'pf-v6-c-nav__link',
44-
(isCurrent || pathname.startsWith(href + '/')) &&
45-
'pf-m-current'
46-
),
41+
className: css('pf-v6-c-nav__link', (isCurrent || pathname.startsWith(href + '/')) && 'pf-m-current')
4742
};
4843
}}
4944
tabIndex={isSidebarOpen ? undefined : -1}
@@ -77,17 +72,10 @@ const NavItem = ({ text, href, isDeprecated, isBeta, isDemo }) => {
7772
);
7873
};
7974

80-
const ExpandableNav = ({
81-
groupedRoutes,
82-
location,
83-
section,
84-
subsection = null,
85-
}) => {
75+
const ExpandableNav = ({ groupedRoutes, location, section, subsection = null }) => {
8676
const isActive = getIsActive(location, section, subsection);
8777
const isSubsection = subsection;
88-
const routes = isSubsection
89-
? groupedRoutes[section][subsection]
90-
: groupedRoutes[section];
78+
const routes = isSubsection ? groupedRoutes[section][subsection] : groupedRoutes[section];
9179
const currentSection = isSubsection ? subsection : section;
9280
const analyticsName = isSubsection ? `${section}/${subsection}` : section;
9381

@@ -102,92 +90,57 @@ const ExpandableNav = ({
10290
event.stopPropagation();
10391
// Don't trigger for bubbled events from NavItems
10492
if (!event.target.href) {
105-
const isExpanded =
106-
event.currentTarget.classList.contains('pf-m-expanded');
93+
const isExpanded = event.currentTarget.classList.contains('pf-m-expanded');
10794
// 1 === expand section, 0 === collapse section
108-
trackEvent(
109-
'sidenav_section_click',
110-
'click_event',
111-
analyticsName,
112-
isExpanded ? 0 : 1
113-
);
95+
trackEvent('sidenav_section_click', 'click_event', analyticsName, isExpanded ? 0 : 1);
11496
}
11597
}}
11698
>
11799
{Object.entries(routes || {})
118-
.filter(
119-
([id, navObj]) =>
120-
!Boolean(navObj.hideNavItem) && Object.entries(navObj).length > 0
121-
)
100+
.filter(([id, navObj]) => !Boolean(navObj.hideNavItem) && Object.entries(navObj).length > 0)
122101
.map(
123102
([
124103
id,
125-
{
126-
slug,
127-
isSubsection = false,
128-
sortValue = defaultValue,
129-
subsectionSortValue = defaultValue,
130-
sources,
131-
},
104+
{ slug, isSubsection = false, sortValue = defaultValue, subsectionSortValue = defaultValue, sources }
132105
]) => ({
133106
text: id,
134107
href: slug,
135108
isSubsection,
136109
sortValue: isSubsection ? subsectionSortValue : sortValue,
137-
sources,
110+
sources
138111
})
139112
)
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;
113+
.sort(({ text: text1, sortValue: sortValue1 }, { text: text2, sortValue: sortValue2 }) => {
114+
if (sortValue1 === sortValue2) {
115+
return text1.localeCompare(text2);
149116
}
150-
)
117+
return sortValue1 > sortValue2 ? 1 : -1;
118+
})
151119
.map((navObj) => {
152120
return navObj.isSubsection
153121
? ExpandableNav({
154122
groupedRoutes,
155123
location,
156124
section,
157-
subsection: navObj.text,
125+
subsection: navObj.text
158126
})
159127
: NavItem({
160128
...navObj,
161129
isDeprecated:
162130
navObj.href?.includes('components') &&
163131
navObj.sources.some(
164132
(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-
))
133+
(source.source === 'react-deprecated' || source.source === 'html-deprecated') &&
134+
!navObj.sources.some((source) => source.source === 'react' || source.source === 'html')
175135
),
176136
isBeta: navObj.sources.some(
177-
(source) =>
178-
source.beta &&
179-
source.source !== 'react-next' &&
180-
source.source !== 'react-templates'
137+
(source) => source.beta && source.source !== 'react-next' && source.source !== 'react-templates'
181138
),
182139
isDemo: navObj.sources.some(
183140
(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-
),
141+
(source.source === 'react-demos' || source.source === 'html-demos') &&
142+
!navObj.sources.some((source) => source.source === 'react' || source.source === 'html')
143+
)
191144
});
192145
})}
193146
</NavExpandable>
@@ -203,8 +156,7 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
203156
if (!overflowElement) {
204157
return;
205158
}
206-
const activeElements =
207-
overflowElement.getElementsByClassName('pf-m-current');
159+
const activeElements = overflowElement.getElementsByClassName('pf-m-current');
208160
if (activeElements.length > 0) {
209161
const lastElement = activeElements[activeElements.length - 1];
210162
lastElement.scrollIntoView({ block: 'center' });
@@ -216,16 +168,11 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
216168
<NavList className="ws-side-nav-list">
217169
{navItems.map(({ section, text, href }) =>
218170
section ? (
219-
<Location key={section}>
220-
{({ location }) =>
221-
ExpandableNav({ groupedRoutes, location, section })
222-
}
223-
</Location>
171+
<Location key={section}>{({ location }) => ExpandableNav({ groupedRoutes, location, section })}</Location>
224172
) : (
225173
NavItem({
226-
text:
227-
text || capitalize(href.replace(/\//g, '').replace(/-/g, ' ')),
228-
href: href,
174+
text: text || capitalize(href.replace(/\//g, '').replace(/-/g, ' ')),
175+
href: href
229176
})
230177
)
231178
)}

0 commit comments

Comments
 (0)