diff --git a/packages/documentation-framework/components/cssVariables/cssVariables.js b/packages/documentation-framework/components/cssVariables/cssVariables.js
index 85af8b7d77..09f0fe9d0f 100644
--- a/packages/documentation-framework/components/cssVariables/cssVariables.js
+++ b/packages/documentation-framework/components/cssVariables/cssVariables.js
@@ -1,16 +1,9 @@
-import React from "react";
-import { List, ListItem, debounce } from "@patternfly/react-core";
-import {
- Table,
- Thead,
- Th,
- Tr,
- Tbody,
- Td
-} from "@patternfly/react-table";
-import { AutoLinkHeader } from "../autoLinkHeader/autoLinkHeader";
-import * as tokensModule from "@patternfly/react-tokens/dist/esm/componentIndex";
-import LevelUpAltIcon from "@patternfly/react-icons/dist/esm/icons/level-up-alt-icon";
+import React from 'react';
+import { List, ListItem, debounce } from '@patternfly/react-core';
+import { Table, Thead, Th, Tr, Tbody, Td } from '@patternfly/react-table';
+import { AutoLinkHeader } from '../autoLinkHeader/autoLinkHeader';
+import * as tokensModule from '@patternfly/react-tokens/dist/esm/componentIndex';
+import LevelUpAltIcon from '@patternfly/react-icons/dist/esm/icons/level-up-alt-icon';
import { CSSSearch } from './cssSearch';
const isColorRegex = /^(#|rgb)/;
@@ -19,27 +12,25 @@ const mappingAsList = (property, values) => (
{property}
{values.map((entry) => (
- }
- >
+ }>
{entry}
))}
);
-const flattenList = files => {
+const flattenList = (files) => {
let list = [];
- files.forEach(file => {
+ files.forEach((file) => {
Object.entries(file).forEach(([selector, values]) => {
- if(values !== undefined) {
+ if (values !== undefined) {
Object.entries(values).forEach(([key, val]) => {
list.push({
selector,
property: val.name,
token: key,
value: val.value,
- values: val.values
+ values: val.values,
});
});
}
@@ -51,15 +42,15 @@ const flattenList = files => {
export class CSSVariables extends React.Component {
constructor(props) {
super(props);
- const prefixToken = props.prefix.replace("pf-v6-", "").replace(/-+/g, "_");
+ const prefixToken = props.prefix.replace('pf-v6-', '').replace(/-+/g, '_');
const applicableFiles = Object.entries(tokensModule)
.filter(([key, val]) => prefixToken === key)
.sort(([key1], [key2]) => key1.localeCompare(key2))
.map(([key, val]) => {
if (props.selector) {
return {
- [props.selector]: val[props.selector]
- }
+ [props.selector]: val[props.selector],
+ };
}
return val;
});
@@ -69,15 +60,15 @@ export class CSSVariables extends React.Component {
this.state = {
searchRE: '',
rows: this.getFilteredRows(),
- allRowsExpanded: true
+ allRowsExpanded: true,
};
}
getFilteredRows = (searchRE) => {
let filteredRows = [];
let rowNumber = -1;
- this.flatList.forEach(row => {
- const { selector, property, token, value, values} = row;
+ this.flatList.forEach((row) => {
+ const { selector, property, token, value, values } = row;
const passes =
!searchRE ||
searchRE.test(selector) ||
@@ -88,7 +79,7 @@ export class CSSVariables extends React.Component {
const rowKey = `${selector}_${property}`;
const isColor = isColorRegex.test(value);
const cells = [
- ...this.props.hideSelectorColumn ? [] : [selector],
+ ...(this.props.hideSelectorColumn ? [] : [selector]),
property,
+ ,
];
filteredRows.push({
isOpen: values ? false : undefined,
cells,
- details: values ? {
- parent: rowNumber,
- fullWidth: true,
- data: mappingAsList(property, values)
- } : undefined
+ details: values
+ ? {
+ parent: rowNumber,
+ fullWidth: true,
+ data: mappingAsList(property, values),
+ }
+ : undefined,
});
rowNumber += 1;
if (values) {
- rowNumber += 1
+ rowNumber += 1;
}
}
});
@@ -136,28 +132,35 @@ export class CSSVariables extends React.Component {
let newRows = Array.from(rows);
if (collapseAll) {
- newRows = newRows.map(r => (r.isOpen === undefined ? r : { ...r, isOpen }));
+ newRows = newRows.map((r) =>
+ r.isOpen === undefined ? r : { ...r, isOpen }
+ );
} else {
newRows[rowKey] = { ...newRows[rowKey], isOpen };
}
- this.setState(prevState => ({
+ this.setState((prevState) => ({
rows: newRows,
- ...(collapseAll && {allRowsExpanded: !prevState.allRowsExpanded})
+ ...(collapseAll && { allRowsExpanded: !prevState.allRowsExpanded }),
}));
};
- getDebouncedFilteredRows = debounce(value => {
- const searchRE = new RegExp(value, "i");
+ getDebouncedFilteredRows = debounce((value) => {
+ const searchRE = new RegExp(value, 'i');
this.setState({
searchRE,
- rows: this.getFilteredRows(searchRE)
+ rows: this.getFilteredRows(searchRE),
});
}, 500);
render() {
return (
- {this.props.autoLinkHeader && {`Prefixed with '${this.props.prefix}'`}}
+ {this.props.autoLinkHeader && (
+ {`Prefixed with '${this.props.prefix}'`}
+ )}
@@ -198,19 +201,22 @@ export class CSSVariables extends React.Component {
{row.details ? (
{!row.details.fullWidth ? | : null}
- {row.details.data} |
+
+ {row.details.data}
+ |
) : null}
- ))) : (
-
- {this.state.rows.map((row, rowIndex) => (
-
- {row.cells[0]} |
- {row.cells[1]} |
-
- ))}
-
+ ))
+ ) : (
+
+ {this.state.rows.map((row, rowIndex) => (
+
+ {row.cells[0]} |
+ {row.cells[1]} |
+
+ ))}
+
)}
diff --git a/packages/documentation-framework/components/footer/footer.js b/packages/documentation-framework/components/footer/footer.js
index ce6afdbad3..1927003a10 100644
--- a/packages/documentation-framework/components/footer/footer.js
+++ b/packages/documentation-framework/components/footer/footer.js
@@ -1,4 +1,4 @@
-import React from "react";
+import React from 'react';
import {
Brand,
Grid,
@@ -7,11 +7,11 @@ import {
ListItem,
PageSection,
Content,
-} from "@patternfly/react-core";
-import { Link } from "@patternfly/documentation-framework/components";
-import { GithubIcon } from "@patternfly/react-icons";
-import redhatLogo from "./RHLogo.png";
-import redhatLogoDark from "./RHLogoDark.png";
+} from '@patternfly/react-core';
+import { Link } from '@patternfly/documentation-framework/components';
+import { GithubIcon } from '@patternfly/react-icons';
+import redhatLogo from './RHLogo.png';
+import redhatLogoDark from './RHLogoDark.png';
export const Footer = ({ isDarkTheme }) => (
@@ -36,7 +36,7 @@ export const Footer = ({ isDarkTheme }) => (
What's new
(
md={4}
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"
>
-
- Community
-
+ Community
@@ -140,7 +138,7 @@ export const Footer = ({ isDarkTheme }) => (
target="top"
aria-label="Read the PatternFly blog"
>
- Blog
+ Blog
@@ -171,7 +169,7 @@ export const Footer = ({ isDarkTheme }) => (
>
Discussions
-
+
@@ -268,9 +266,19 @@ export const Footer = ({ isDarkTheme }) => (
target="top"
aria-label="Link to PatternFly X page"
>
-
+
- {/* Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.*/}
+ {/* Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.*/}
diff --git a/packages/documentation-framework/components/sideNav/sideNav.js b/packages/documentation-framework/components/sideNav/sideNav.js
index 23a696f7e0..9f2d46421c 100644
--- a/packages/documentation-framework/components/sideNav/sideNav.js
+++ b/packages/documentation-framework/components/sideNav/sideNav.js
@@ -1,58 +1,88 @@
import React from 'react';
import { Link } from '../link/link';
-import { Label, Nav, NavList, NavExpandable, PageContextConsumer, capitalize, Flex, FlexItem } from '@patternfly/react-core';
+import {
+ Label,
+ Nav,
+ NavList,
+ NavExpandable,
+ PageContextConsumer,
+ capitalize,
+ Flex,
+ FlexItem,
+} from '@patternfly/react-core';
import { css } from '@patternfly/react-styles';
import { Location } from '@reach/router';
import { makeSlug } from '../../helpers';
-import globalBreakpointXl from "@patternfly/react-tokens/dist/esm/t_global_breakpoint_xl";
+import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/t_global_breakpoint_xl';
import { trackEvent } from '../../helpers';
const getIsActive = (location, section, subsection = null) => {
const slug = makeSlug(null, section, null, null, subsection);
return location.pathname.startsWith(slug);
-}
+};
const defaultValue = 50;
const NavItem = ({ text, href, isDeprecated, isBeta, isDemo }) => {
- const isMobileView = window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
+ const isMobileView =
+ window.innerWidth < Number.parseInt(globalBreakpointXl.value, 10);
return (
- {({onSidebarToggle, isSidebarOpen }) => (
- isMobileView && onSidebarToggle && onSidebarToggle()}>
- {
- const { pathname } = location;
- return {
- className: css(
- 'pf-v6-c-nav__link',
- (isCurrent || pathname.startsWith(href + '/')) && 'pf-m-current'
- )
- }}
- }
- tabIndex={isSidebarOpen ? undefined : -1}
- >
-
- {text}
- {(isBeta || isDemo || isDeprecated) && (
-
- {isBeta && ()}
- {!isBeta && isDeprecated && ()}
- {!isBeta && !isDeprecated && isDemo && ()}
-
- )}
-
-
-
-
-
+ {({ onSidebarToggle, isSidebarOpen }) => (
+ isMobileView && onSidebarToggle && onSidebarToggle()}
+ >
+ {
+ const { pathname } = location;
+ return {
+ className: css(
+ 'pf-v6-c-nav__link',
+ (isCurrent || pathname.startsWith(href + '/')) &&
+ 'pf-m-current'
+ ),
+ };
+ }}
+ tabIndex={isSidebarOpen ? undefined : -1}
+ >
+
+ {text}
+ {(isBeta || isDemo || isDeprecated) && (
+
+ {isBeta && (
+
+ )}
+ {!isBeta && isDeprecated && (
+
+ )}
+ {!isBeta && !isDeprecated && isDemo && (
+
+ )}
+
+ )}
+
+
+
)}
- )
+ );
};
-const ExpandableNav = ({groupedRoutes, location, section, subsection = null}) => {
+const ExpandableNav = ({
+ groupedRoutes,
+ location,
+ section,
+ subsection = null,
+}) => {
const isActive = getIsActive(location, section, subsection);
const isSubsection = subsection;
const routes = isSubsection
@@ -72,39 +102,97 @@ const ExpandableNav = ({groupedRoutes, location, section, subsection = null}) =>
event.stopPropagation();
// Don't trigger for bubbled events from NavItems
if (!event.target.href) {
- const isExpanded = event.currentTarget.classList.contains('pf-m-expanded');
+ const isExpanded =
+ event.currentTarget.classList.contains('pf-m-expanded');
// 1 === expand section, 0 === collapse section
- trackEvent('sidenav_section_click', 'click_event', analyticsName, isExpanded ? 0 : 1);
+ trackEvent(
+ 'sidenav_section_click',
+ 'click_event',
+ analyticsName,
+ isExpanded ? 0 : 1
+ );
}
}}
>
{Object.entries(routes || {})
- .filter(([id, navObj]) => !Boolean(navObj.hideNavItem) && (Object.entries(navObj).length > 0))
- .map(([id, { slug, isSubsection = false, sortValue = defaultValue, subsectionSortValue = defaultValue, sources }]) => ({ text: id, href: slug, isSubsection, sortValue: (isSubsection ? subsectionSortValue : sortValue), sources }))
- .sort(({text: text1, sortValue: sortValue1}, {text: text2, sortValue: sortValue2}) => {
- if (sortValue1 === sortValue2) {
- return text1.localeCompare(text2);
+ .filter(
+ ([id, navObj]) =>
+ !Boolean(navObj.hideNavItem) && Object.entries(navObj).length > 0
+ )
+ .map(
+ ([
+ id,
+ {
+ slug,
+ isSubsection = false,
+ sortValue = defaultValue,
+ subsectionSortValue = defaultValue,
+ sources,
+ },
+ ]) => ({
+ text: id,
+ href: slug,
+ isSubsection,
+ sortValue: isSubsection ? subsectionSortValue : sortValue,
+ sources,
+ })
+ )
+ .sort(
+ (
+ { text: text1, sortValue: sortValue1 },
+ { text: text2, sortValue: sortValue2 }
+ ) => {
+ if (sortValue1 === sortValue2) {
+ return text1.localeCompare(text2);
+ }
+ return sortValue1 > sortValue2 ? 1 : -1;
}
- return sortValue1 > sortValue2 ? 1 : -1;
- })
- .map(navObj => navObj.isSubsection
- ? ExpandableNav({groupedRoutes, location, section, subsection: navObj.text})
+ )
+ .map((navObj) => {
+ return navObj.isSubsection
+ ? ExpandableNav({
+ groupedRoutes,
+ location,
+ section,
+ subsection: navObj.text,
+ })
: NavItem({
- ...navObj,
- isDeprecated: navObj.href?.includes('components') && navObj.sources.some(source => (
- source.source === "react-deprecated" || source.source === "html-deprecated")
- && !navObj.sources.some(source => source.source === "react" || source.source === "html")
- ),
- isBeta: navObj.sources.some(source => source.beta && source.source !== 'react-next' && source.source !== 'react-templates'),
- isDemo: navObj.sources.some(source => (
- source.source === "react-demos" || source.source === "html-demos")
- && !navObj.sources.some(source => source.source === "react" || source.source === "html")
- )
- })
- )}
+ ...navObj,
+ isDeprecated:
+ navObj.href?.includes('components') &&
+ navObj.sources.some(
+ (source) =>
+ (source.source === 'react-deprecated' ||
+ source.source === 'html-deprecated') &&
+ // TODO: remove hardcoded Tile when Core PR merges
+ // https://github.com/patternfly/patternfly/pull/7178
+ (source.id === 'Tile' ||
+ !navObj.sources.some(
+ (source) =>
+ source.source === 'react' ||
+ source.source === 'html'
+ ))
+ ),
+ isBeta: navObj.sources.some(
+ (source) =>
+ source.beta &&
+ source.source !== 'react-next' &&
+ source.source !== 'react-templates'
+ ),
+ isDemo: navObj.sources.some(
+ (source) =>
+ (source.source === 'react-demos' ||
+ source.source === 'html-demos') &&
+ !navObj.sources.some(
+ (source) =>
+ source.source === 'react' || source.source === 'html'
+ )
+ ),
+ });
+ })}
);
-}
+};
export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
React.useEffect(() => {
@@ -115,7 +203,8 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
if (!overflowElement) {
return;
}
- const activeElements = overflowElement.getElementsByClassName('pf-m-current');
+ const activeElements =
+ overflowElement.getElementsByClassName('pf-m-current');
if (activeElements.length > 0) {
const lastElement = activeElements[activeElements.length - 1];
lastElement.scrollIntoView({ block: 'center' });
@@ -125,18 +214,22 @@ export const SideNav = ({ groupedRoutes = {}, navItems = [] }) => {
return (
- {navItems.map(({ section, text, href }) => section
- ? (
+ {navItems.map(({ section, text, href }) =>
+ section ? (
- {({ location }) => ExpandableNav({groupedRoutes, location, section})}
+ {({ location }) =>
+ ExpandableNav({ groupedRoutes, location, section })
+ }
- )
- : NavItem({
- text: text || capitalize(href.replace(/\//g, '').replace(/-/g, ' ')),
- href: href
+ ) : (
+ NavItem({
+ text:
+ text || capitalize(href.replace(/\//g, '').replace(/-/g, ' ')),
+ href: href,
})
+ )
)}
);
-}
+};
diff --git a/packages/documentation-framework/templates/mdx.js b/packages/documentation-framework/templates/mdx.js
index 6d24c71293..dbf51542a6 100644
--- a/packages/documentation-framework/templates/mdx.js
+++ b/packages/documentation-framework/templates/mdx.js
@@ -1,21 +1,37 @@
import React from 'react';
-import { PageSection, Title, Tooltip, PageSectionVariants, Button, BackToTop, Flex, FlexItem, PageGroup, Page, Content, Label, Stack, StackItem } from '@patternfly/react-core';
+import {
+ PageSection,
+ Title,
+ Tooltip,
+ PageSectionVariants,
+ Button,
+ BackToTop,
+ Flex,
+ FlexItem,
+ PageGroup,
+ Page,
+ Content,
+ Label,
+ Stack,
+ StackItem,
+} from '@patternfly/react-core';
import { css } from '@patternfly/react-styles';
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
import { Router, useLocation } from '@reach/router';
-import { CSSVariables, PropsTable, TableOfContents, Link, AutoLinkHeader, InlineAlert } from '../components';
+import {
+ CSSVariables,
+ PropsTable,
+ TableOfContents,
+ Link,
+ AutoLinkHeader,
+ InlineAlert,
+} from '../components';
import { capitalize, getTitle, slugger, trackEvent } from '../helpers';
import './mdx.css';
import { convertToReactComponent } from '@patternfly/ast-helpers';
import { FunctionsTable } from '../components/functionsTable/functionsTable';
-const MDXChildTemplate = ({
- Component,
- source,
- toc = [],
- index = 0,
- id
-}) => {
+const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
const {
propComponents = [],
sourceLink,
@@ -25,60 +41,107 @@ const MDXChildTemplate = ({
deprecated,
template,
newImplementationLink,
- functionDocumentation = []
+ functionDocumentation = [],
} = Component.getPageData();
const cssVarsTitle = cssPrefix.length > 0 && 'CSS variables';
const propsTitle = propComponents.length > 0 && 'Props';
- if (propsTitle && !toc.find(item => item.text === propsTitle)) {
+ if (propsTitle && !toc.find((item) => item.text === propsTitle)) {
toc.push({ text: propsTitle });
- toc.push(propComponents.map(propComponent => ({ text: propComponent.name })));
+ toc.push(
+ propComponents.map((propComponent) => ({ text: propComponent.name }))
+ );
}
- if (cssVarsTitle && !toc.find(item => item.text === cssVarsTitle)) {
+ if (cssVarsTitle && !toc.find((item) => item.text === cssVarsTitle)) {
toc.push({ text: cssVarsTitle });
if (cssPrefix.length > 1) {
- toc.push(cssPrefix.map(cssPrefix => ({ text: `Prefixed with '${cssPrefix}'` })));
+ toc.push(
+ cssPrefix.map((cssPrefix) => ({ text: `Prefixed with '${cssPrefix}'` }))
+ );
}
}
// We don't add `id`s in anchor-header.js for items where id === slugger(text)
// in order to save ~10KB bandwidth.
if (toc.length > 1) {
- const ensureID = tocItem => {
+ const ensureID = (tocItem) => {
if (Array.isArray(tocItem)) {
tocItem.forEach(ensureID);
+ } else if (!tocItem.id) {
+ tocItem.id = slugger(tocItem.text);
}
- else if (!tocItem.id) {
- tocItem.id = slugger(tocItem.text)
- }
- }
+ };
ensureID(toc);
}
- const isComponentCodeDocs = ['react', 'react-demos', 'html', 'html-demos', 'react-templates'].includes(source);
+ const isComponentCodeDocs = [
+ 'react',
+ 'react-demos',
+ 'html',
+ 'html-demos',
+ 'react-templates',
+ ].includes(source);
- const InlineAlerts = (optIn || beta || deprecated || source === 'react-deprecated' || source === 'html-deprecated' || template || source === 'react-template') && (
+ const InlineAlerts = (optIn ||
+ beta ||
+ deprecated ||
+ source === 'react-deprecated' ||
+ source === 'html-deprecated' ||
+ // TODO: remove hardcoded Tile when Core PR merges
+ // https://github.com/patternfly/patternfly/pull/7178
+ id === 'Tile' ||
+ template ||
+ source === 'react-template') && (
- {optIn && (
-
- {optIn}
-
- )}
+ {optIn && {optIn}}
{beta && (
- This beta component is currently under review and is still open for further evolution. It is available for use in product. Beta components are considered for promotion on a quarterly basis. Please join in and give us your feedback or submit any questions on the PatternFly forum or via Slack. To learn more about the process, visit our about page or our Beta components page on GitHub.
+ This beta component is currently under review and is still open for
+ further evolution. It is available for use in product. Beta components
+ are considered for promotion on a quarterly basis. Please join in and
+ give us your feedback or submit any questions on the{' '}
+ PatternFly forum or via{' '}
+
+ Slack
+
+ . To learn more about the process, visit our{' '}
+
+ about page
+ {' '}
+ or our{' '}
+
+ Beta components
+ {' '}
+ page on GitHub.
)}
- {(deprecated || source === 'react-deprecated' || source === 'html-deprecated') && (
+ {(deprecated ||
+ source === 'react-deprecated' ||
+ source === 'html-deprecated' ||
+ // TODO: remove hardcoded Tile when Core PR merges
+ // https://github.com/patternfly/patternfly/pull/7178
+ id === 'Tile') && (
- This component implementation has been deprecated in favor of a newer solution, and is no longer being maintained or enhanced.
+ This component implementation has been deprecated in favor of a newer
+ solution, and is no longer being maintained or enhanced.
{newImplementationLink && (
- You can find the updated implementation here.
+ You can find the{' '}
+
+ updated implementation here
+
+ .
- )}
- {' '}To learn more about deprecated components, visit about PatternFly.
+ )}{' '}
+ To learn more about deprecated components, visit{' '}
+
+ about PatternFly.
+
)}
- {(template || source === 'react-template') && (
+ {(template || source === 'react-template') && (
{`This page showcases templates for the ${id.toLowerCase()} component. A template combines a component with logic that supports a specific use case, with a streamlined API that offers additional, limited customization.`}
@@ -88,107 +151,164 @@ const MDXChildTemplate = ({
// Create dynamic component for @reach/router
const ChildComponent = () => (
);
ChildComponent.displayName = `MDXChildTemplate${Component.displayName}`;
return ;
-}
+};
export const MDXTemplate = ({
title,
sources = [],
path,
id,
- componentsData
+ componentsData,
}) => {
- const isDeprecated = sources.some(source => source.source === "react-deprecated" || source.source === "html-deprecated") && !sources.some(source => source.source === "react" || source.source === "html");
- const isBeta = sources.some(source => source.beta && source.source !== 'react-next' && source.source !== 'react-templates');
- const isDemo = sources.some(source => source.source === "react-demos" || source.source === "html-demos") && !sources.some(source => source.source === "react" || source.source === "html");
+ const isDeprecated =
+ sources.some(
+ (source) =>
+ source.source === 'react-deprecated' ||
+ source.source === 'html-deprecated'
+ ) &&
+ !sources.some(
+ (source) => source.source === 'react' || source.source === 'html'
+ );
+ const isBeta = sources.some(
+ (source) =>
+ source.beta &&
+ source.source !== 'react-next' &&
+ source.source !== 'react-templates'
+ );
+ const isDemo =
+ sources.some(
+ (source) =>
+ source.source === 'react-demos' || source.source === 'html-demos'
+ ) &&
+ !sources.some(
+ (source) => source.source === 'react' || source.source === 'html'
+ );
// Build obj mapping source names to text displayed on tabs
const tabNames = sources.reduce((acc, curSrc) => {
const { source, tabName } = curSrc;
// use tabName for tab name if present, otherwise default to source
- const tabLinkText = tabName || capitalize(source.replace('html', 'HTML').replace(/-/g, ' '));
+ const tabLinkText =
+ tabName || capitalize(source.replace('html', 'HTML').replace(/-/g, ' '));
acc[source] = tabLinkText;
return acc;
}, {});
const sourceKeys = Object.keys(tabNames);
const isSinglePage = sourceKeys.length === 1;
- let isDevResources, isComponent, isExtension, isChart, isPattern, isLayout, isUtility, isUpgrade;
+ let isDevResources,
+ isComponent,
+ isExtension,
+ isChart,
+ isPattern,
+ isLayout,
+ isUtility,
+ isUpgrade;
const getSection = () => {
return sources.some((source) => {
switch (source.section) {
- case "developer-resources":
+ case 'developer-resources':
isDevResources = true;
return;
- case "components":
+ case 'components':
isComponent = true;
return;
- case "extensions":
+ case 'extensions':
isExtension = true;
return;
- case "charts":
+ case 'charts':
isChart = true;
return;
- case "patterns":
+ case 'patterns':
isPattern = true;
return;
- case "layouts":
+ case 'layouts':
isLayout = true;
return;
- case "utilities":
+ case 'utilities':
isUtility = true;
return;
- case "get-started":
+ case 'get-started':
if (source.source.includes('upgrade')) {
isUpgrade = true;
}
@@ -199,7 +319,7 @@ export const MDXTemplate = ({
// hide tab if it doesn't include the strings below
const hideTabName = sourceKeys.some(
- (e) => e.includes("pages") || e.includes("training")
+ (e) => e.includes('pages') || e.includes('training')
);
const { pathname } = useLocation();
let activeSource = pathname.replace(/\/$/, '').split('/').pop();
@@ -225,34 +345,30 @@ export const MDXTemplate = ({
getSection();
if (isChart || isDevResources || isExtension) {
if (isSinglePage) {
- return "pf-m-light-100";
+ return 'pf-m-light-100';
}
- return "pf-m-light";
+ return 'pf-m-light';
} else if (isUtility || isPattern || isLayout || isComponent || isUpgrade) {
- return "pf-m-light";
+ return 'pf-m-light';
}
- return "pf-m-light-100";
+ return 'pf-m-light-100';
};
- const showTabs = (
- (!isSinglePage && !hideTabName) ||
- isComponent ||
- isUtility ||
- isPattern
- );
+ const showTabs =
+ (!isSinglePage && !hideTabName) || isComponent || isUtility || isPattern;
return (
-
+
-
+
{title}
@@ -288,11 +404,15 @@ export const MDXTemplate = ({
- {isComponent && summary && ()}
+ {isComponent && summary && }
- { showTabs && (
-
+ {showTabs && (
+
{sourceKeys.map((source, index) => (
@@ -303,9 +423,18 @@ export const MDXTemplate = ({
activeSource === source && 'pf-m-current'
)}
// Send clicked tab name for analytics
- onClick={() => trackEvent('tab_click', 'click_event', source.toUpperCase())}
+ onClick={() =>
+ trackEvent(
+ 'tab_click',
+ 'click_event',
+ source.toUpperCase()
+ )
+ }
>
-
+
{tabNames[source]}
@@ -315,7 +444,7 @@ export const MDXTemplate = ({
)}
- {isSinglePage && }
+ {isSinglePage && }
{!isSinglePage && (
{sources
@@ -327,8 +456,11 @@ export const MDXTemplate = ({
)}
-
+
);
-}
+};