@patternfly/documentation-framework 2.0.0-alpha.8 → 5.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +617 -0
  2. package/README.md +1 -1
  3. package/app.js +20 -14
  4. package/assets/Favicon-Light-16x16.png +0 -0
  5. package/assets/Favicon-Light-32x32.png +0 -0
  6. package/assets/Favicon-Light-48x48.png +0 -0
  7. package/assets/Favicon-Light.png +0 -0
  8. package/assets/android-chrome-36x36.png +0 -0
  9. package/assets/android-chrome-48x48.png +0 -0
  10. package/assets/android-chrome-96x96.png +0 -0
  11. package/components/autoLinkHeader/autoLinkHeader.css +2 -2
  12. package/components/autoLinkHeader/autoLinkHeader.js +18 -13
  13. package/components/cssVariables/cssSearch.js +3 -4
  14. package/components/cssVariables/cssVariables.css +4 -4
  15. package/components/cssVariables/cssVariables.js +83 -84
  16. package/components/example/example.css +29 -29
  17. package/components/example/example.js +34 -6
  18. package/components/footer/footer.css +16 -16
  19. package/components/footer/footer.js +16 -16
  20. package/components/functionsTable/functionsTable.js +57 -0
  21. package/components/gdprBanner/gdprBanner.css +2 -2
  22. package/components/gdprBanner/gdprBanner.js +3 -3
  23. package/components/inlineAlert/inlineAlert.js +1 -1
  24. package/components/link/link.js +1 -2
  25. package/components/propsTable/propsTable.js +85 -79
  26. package/components/sectionGallery/TextSummary.js +31 -0
  27. package/components/sectionGallery/sectionDataListLayout.js +51 -0
  28. package/components/sectionGallery/sectionGallery.css +53 -0
  29. package/components/sectionGallery/sectionGallery.js +76 -0
  30. package/components/sectionGallery/sectionGalleryLayout.js +41 -0
  31. package/components/sectionGallery/sectionGalleryToolbar.js +38 -0
  32. package/components/sectionGallery/sectionGalleryWrapper.js +110 -0
  33. package/components/sideNav/sideNav.css +12 -12
  34. package/components/sideNav/sideNav.js +44 -16
  35. package/components/tableOfContents/tableOfContents.css +17 -17
  36. package/helpers/codesandbox.js +3 -5
  37. package/helpers/getTitle.js +2 -2
  38. package/layouts/sideNavLayout/sideNavLayout.css +7 -11
  39. package/layouts/sideNavLayout/sideNavLayout.js +59 -45
  40. package/package.json +28 -29
  41. package/pages/404/404.css +2 -2
  42. package/pages/404/index.js +1 -1
  43. package/pages/global-css-variables.md +16 -16
  44. package/routes.js +20 -10
  45. package/scripts/cli/build.js +0 -1
  46. package/scripts/cli/cli.js +2 -1
  47. package/scripts/cli/generate.js +2 -2
  48. package/scripts/cli/start.js +6 -8
  49. package/scripts/md/parseMD.js +46 -11
  50. package/scripts/md/styled-tags.js +8 -4
  51. package/scripts/tsDocgen.js +119 -91
  52. package/scripts/typeDocGen.js +209 -0
  53. package/scripts/webpack/getHtmlWebpackPlugins.js +1 -2
  54. package/scripts/webpack/prerender.js +1 -2
  55. package/scripts/webpack/webpack.base.config.js +35 -35
  56. package/scripts/webpack/webpack.client.config.js +11 -8
  57. package/scripts/webpack/webpack.server.config.js +8 -5
  58. package/scripts/writeScreenshots.js +3 -3
  59. package/templates/html.ejs +6 -8
  60. package/templates/mdx.css +156 -161
  61. package/templates/mdx.js +122 -51
  62. package/templates/patternfly-docs/content/extensions/extension/design-guidelines/design-guidelines.md +2 -0
  63. package/templates/patternfly-docs/content/extensions/extension/examples/basic.md +2 -0
  64. package/templates/sitemap.ejs +1 -1
  65. package/versions.json +32 -13
  66. package/assets/favicon-16x16.png +0 -0
  67. package/assets/favicon-32x32.png +0 -0
  68. package/assets/favicon-48x48.png +0 -0
  69. package/assets/favicon.ico +0 -0
  70. package/components/topNav/topNav.css +0 -30
  71. package/pages/red-hat-font.md +0 -40
@@ -19,12 +19,12 @@ export const Footer = () => (
19
19
  sm={12}
20
20
  md={6}
21
21
  mdOffset={1}
22
- className="pf-u-mb-lg pf-u-mb-0-on-sm"
22
+ className="pf-v5-u-mb-lg pf-v5-u-mb-0-on-sm"
23
23
  >
24
- <Grid className="pf-u-py-xl">
25
- <GridItem sm={6} md={4} className="pf-u-ml-md pf-u-ml-0-on-md pf-u-mb-xl pf-u-mb-0-on-md">
24
+ <Grid className="pf-v5-u-py-xl">
25
+ <GridItem sm={6} md={4} className="pf-v5-u-ml-md pf-v5-u-ml-0-on-md pf-v5-u-mb-xl pf-v5-u-mb-0-on-md">
26
26
  <p
27
- className="pf-c-title ws-org-pfsite-footer-menu-list-title"
27
+ className="pf-v5-c-title ws-org-pfsite-footer-menu-list-title"
28
28
  >
29
29
  QUICKLINKS
30
30
  </p>
@@ -82,10 +82,10 @@ export const Footer = () => (
82
82
  <GridItem
83
83
  sm={6}
84
84
  md={4}
85
- className="pf-u-mt-lg pf-u-mt-0-on-sm pf-u-ml-md pf-u-ml-0-on-md pf-u-mb-xl pf-u-mb-0-on-md"
85
+ className="pf-v5-u-mt-lg pf-v5-u-mt-0-on-sm pf-v5-u-ml-md pf-v5-u-ml-0-on-md pf-v5-u-mb-xl pf-v5-u-mb-0-on-md"
86
86
  >
87
87
  <p
88
- className="pf-c-title ws-org-pfsite-footer-menu-list-title"
88
+ className="pf-v5-c-title ws-org-pfsite-footer-menu-list-title"
89
89
  >
90
90
  CONTRIBUTE
91
91
  </p>
@@ -125,7 +125,7 @@ export const Footer = () => (
125
125
  <GridItem
126
126
  sm={6}
127
127
  md={4}
128
- className="pf-u-mt-lg pf-u-mt-0-on-md pf-u-ml-md pf-u-ml-0-on-md"
128
+ className="pf-v5-u-mt-lg pf-v5-u-mt-0-on-md pf-v5-u-ml-md pf-v5-u-ml-0-on-md"
129
129
  >
130
130
  <p
131
131
  className="ws-org-pfsite-footer-menu-list-title"
@@ -147,11 +147,11 @@ export const Footer = () => (
147
147
  <li className="ws-org-pfsite-footer-menu-list-item">
148
148
  <Link
149
149
  className="ws-org-pfsite-footer-menu-link"
150
- to="//forum.patternfly.org"
150
+ to="//github.com/orgs/patternfly/discussions"
151
151
  target="top"
152
- aria-label="Visit the PatternFly 4 forum"
152
+ aria-label="Visit the PatternFly discussion forum"
153
153
  >
154
- Forum
154
+ Discussions
155
155
  </Link>
156
156
  </li>
157
157
  <li className="ws-org-pfsite-footer-menu-list-item">
@@ -180,10 +180,10 @@ export const Footer = () => (
180
180
  </Grid>
181
181
  </GridItem>
182
182
  <GridItem sm={12} md={4}>
183
- <Grid className="pf-u-pt-xl ws-org-pfsite-l-footer-column">
184
- <GridItem className="pf-u-px-xl">
183
+ <Grid className="pf-v5-u-pt-xl ws-org-pfsite-l-footer-column">
184
+ <GridItem className="pf-v5-u-px-xl">
185
185
  <Link
186
- className="pf-c-page__header-brand-link pf-c-brand ws-org-pfsite-footer-menu-about-logo pf-u-pb-md"
186
+ className="pf-v5-c-page__header-brand-link pf-v5-c-brand ws-org-pfsite-footer-menu-about-logo pf-v5-u-pb-md"
187
187
  to="/"
188
188
  >
189
189
  <Brand src={logo} alt="Patternfly Logo" />
@@ -192,7 +192,7 @@ export const Footer = () => (
192
192
  PatternFly is an open source design system built to drive consistency and unify teams. From documentation and components to code examples and tutorials, PatternFly is a place where design and development can thrive. We’re on a mission to help teams build consistent, accessible, and scalable enterprise product experiences—the open source way.
193
193
  </p>
194
194
  </GridItem>
195
- <GridItem className="ws-org-pfsite-footer-menu-social-links pf-u-px-xl">
195
+ <GridItem className="ws-org-pfsite-footer-menu-social-links pf-v5-u-px-xl">
196
196
  <Link
197
197
  to="//github.com/patternfly"
198
198
  target="top"
@@ -213,7 +213,7 @@ export const Footer = () => (
213
213
  </Grid>
214
214
  </PageSection>
215
215
  <PageSection key="footer-2" className="ws-org-pfsite-l-footer-dark pf-m-no-fill">
216
- <Grid className="pf-u-py-xl-on-sm pf-u-py-0-on-md pf-u-align-items-center">
216
+ <Grid className="pf-v5-u-py-xl-on-sm pf-v5-u-py-0-on-md pf-v5-u-align-items-center">
217
217
  <GridItem md={2} mdOffset={1}>
218
218
  <Link
219
219
  to="//www.redhat.com"
@@ -233,7 +233,7 @@ export const Footer = () => (
233
233
  Copyright &copy; 2022 Red Hat, Inc.
234
234
  </span>
235
235
  </GridItem>
236
- <GridItem md={4} lg={5} className="pf-u-ml-xl-on-xl">
236
+ <GridItem md={4} lg={5} className="pf-v5-u-ml-xl-on-xl">
237
237
  <Link
238
238
  to="//www.redhat.com/en/about/privacy-policy"
239
239
  target="top"
@@ -0,0 +1,57 @@
1
+ import React from "react";
2
+ import {
3
+ Table,
4
+ Caption,
5
+ Thead,
6
+ Tr,
7
+ Th,
8
+ Tbody,
9
+ Td,
10
+ } from "@patternfly/react-table";
11
+
12
+ export const FunctionsTable = ({ functionDescriptions }) => {
13
+ const columnNames = {
14
+ name: "Function name",
15
+ description: "Description",
16
+ signature: "Type signature",
17
+ defaultValues: "Default parameter values",
18
+ };
19
+
20
+ const formatDefaultValues = (parameters) =>
21
+ parameters.map((param) => `${param.name}: ${param.default}; `);
22
+
23
+ return (
24
+ <Table
25
+ aria-label="Function documentation table"
26
+ variant="compact"
27
+ >
28
+ <Caption>Table showing documentation for relevant functions</Caption>
29
+ <Thead>
30
+ <Tr>
31
+ <Th>{columnNames.name}</Th>
32
+ <Th>{columnNames.signature}</Th>
33
+ <Th>{columnNames.defaultValues}</Th>
34
+ <Th>{columnNames.description}</Th>
35
+ </Tr>
36
+ </Thead>
37
+ <Tbody>
38
+ {functionDescriptions.map((functionDescription) => (
39
+ <Tr key={functionDescription.functionName}>
40
+ <Td dataLabel={columnNames.name}>
41
+ {functionDescription.functionName}
42
+ </Td>
43
+ <Td dataLabel={columnNames.signature}>
44
+ {functionDescription.type}
45
+ </Td>
46
+ <Td dataLabel={columnNames.defaultValues}>
47
+ {formatDefaultValues(functionDescription.params)}
48
+ </Td>
49
+ <Td dataLabel={columnNames.description}>
50
+ {functionDescription.description}
51
+ </Td>
52
+ </Tr>
53
+ ))}
54
+ </Tbody>
55
+ </Table>
56
+ );
57
+ };
@@ -9,6 +9,6 @@
9
9
  #ws-gdpr-banner {
10
10
  max-width: 95vw;
11
11
  flex-wrap: nowrap;
12
- background: var(--pf-global--BackgroundColor--100);
13
- border: var(--pf-global--BorderWidth--sm) solid var(--pf-global--Color--100);
12
+ background: var(--pf-v5-global--BackgroundColor--100);
13
+ border: var(--pf-v5-global--BorderWidth--sm) solid var(--pf-v5-global--Color--100);
14
14
  }
@@ -13,9 +13,9 @@ export const GdprBanner = () => {
13
13
  }
14
14
 
15
15
  return !isBannerOpen ? null : (
16
- <div className="ws-gdpr-banner-container pf-l-flex">
17
- <div id="ws-gdpr-banner" className="pf-l-flex pf-u-py-md pf-m-align-items-center">
18
- <p id="ws-gdpr-banner-text" className="pf-u-ml-xl">
16
+ <div className="ws-gdpr-banner-container pf-v5-l-flex">
17
+ <div id="ws-gdpr-banner" className="pf-v5-l-flex pf-v5-u-py-md pf-m-align-items-center">
18
+ <p id="ws-gdpr-banner-text" className="pf-v5-u-ml-xl">
19
19
  We use cookies on our websites to deliver our online services.
20
20
  Details about how we use cookies and how you may disable them are set out in our <a href="//www.redhat.com/en/about/privacy-policy">Privacy Statement</a>.
21
21
  By using this website you agree to our use of cookies.
@@ -9,7 +9,7 @@ export const InlineAlert = ({
9
9
  <Alert
10
10
  variant={variant}
11
11
  title={title}
12
- className="pf-u-my-md"
12
+ className="pf-v5-u-my-md"
13
13
  style={{ marginBottom: '1rem' }}
14
14
  isInline
15
15
  component="h2"
@@ -39,8 +39,6 @@ export const Link = ({
39
39
  return <a href={url} onClick={onClick} {...props} />;
40
40
  }
41
41
  else if (url.startsWith('/')) {
42
- url = `${process.env.pathPrefix}/${url.substr(1)}`;
43
-
44
42
  if (!process.env.PRERENDER) {
45
43
  const Component = getAsyncComponent(url);
46
44
  if (Component) {
@@ -65,5 +63,6 @@ export const Link = ({
65
63
  }
66
64
  }
67
65
  }
66
+
68
67
  return <ReachLink to={url} {...props} />;
69
68
  }
@@ -2,90 +2,96 @@ import React from "react";
2
2
  import { Badge } from "@patternfly/react-core";
3
3
  import {
4
4
  Table,
5
- TableHeader,
6
- TableBody,
7
- cellWidth,
5
+ Caption,
6
+ Thead,
7
+ Th,
8
+ Tr,
9
+ Tbody,
10
+ Td,
11
+ TableText
8
12
  } from "@patternfly/react-table";
9
13
  import { AutoLinkHeader } from "../autoLinkHeader/autoLinkHeader";
10
14
  import { PropTypeWithLinks } from "./propTypeWithLinks";
11
15
  import { css } from "@patternfly/react-styles";
12
16
  import accessibleStyles from "@patternfly/react-styles/css/utilities/Accessibility/accessibility";
13
17
 
14
- export const PropsTable = ({ title, description, rows, allPropComponents }) => {
15
- const columns = [
16
- { title: "Name", transforms: [cellWidth(20)] },
17
- { title: "Type", transforms: [cellWidth(20)] },
18
- { title: "Default", transforms: [] },
19
- { title: "Description", transforms: [] },
20
- ];
21
-
22
- return (
23
- <React.Fragment>
24
- <AutoLinkHeader size="h3">{title}</AutoLinkHeader>
25
- <Table
26
- className="pf-u-mt-md pf-u-mb-lg"
27
- variant="compact"
28
- aria-label={title}
29
- caption={
30
- <div>
31
- {description && <div className="pf-u-mb-md">{description}</div>}
32
- <div>
33
- <span className="ws-prop-required">*</span>required
34
- </div>
35
- </div>
36
- }
37
- cells={columns}
38
- gridBreakPoint="grid-lg"
39
- rows={rows
40
- // Sort required rows first
18
+ export const PropsTable = ({ title, description, rows, allPropComponents }) => (
19
+ <React.Fragment>
20
+ <AutoLinkHeader size="h3">{title}</AutoLinkHeader>
21
+ <Table className="pf-v5-u-mt-md pf-v5-u-mb-lg" variant="compact" aria-label={title} gridBreakPoint="grid-lg">
22
+ <Caption>
23
+ {description && <div className="pf-v5-u-mb-md">{description}</div>}
24
+ <div>
25
+ <span className="ws-prop-required">*</span>required
26
+ </div>
27
+ </Caption>
28
+ <Thead>
29
+ <Tr>
30
+ <Th width={20}>Name</Th>
31
+ <Th width={20}>Type</Th>
32
+ <Th>Default</Th>
33
+ <Th>Description</Th>
34
+ </Tr>
35
+ </Thead>
36
+ <Tbody>
37
+ {rows
41
38
  .sort((a, b) => (a.required === b.required ? 0 : a.required ? -1 : 1))
42
- .map((row, idx) => ({
43
- cells: [
44
- <div className="pf-m-break-word">
45
- {row.deprecated && "Deprecated: "}
46
- {row.name}
47
- {row.required ? (
48
- <React.Fragment key={`${row.name}-required-prop`}>
49
- <span
50
- aria-hidden="true"
51
- key={`${row.name}-asterisk`}
52
- className="ws-prop-required"
53
- >
54
- *
55
- </span>
56
- <span
57
- key={`${row.name}-required`}
58
- className={css(accessibleStyles.screenReader)}
59
- >
60
- required
61
- </span>
62
- </React.Fragment>
63
- ) : (
64
- ""
65
- )}
66
- {row.beta && (
67
- <Badge
68
- key={`${row.name}-${idx}`}
69
- className="ws-beta-badge pf-u-ml-sm"
39
+ .map((row, idx) => (
40
+ <Tr key={idx}>
41
+ <Td>
42
+ <TableText wrapModifier="breakWord">
43
+ {row.deprecated && "Deprecated: "}
44
+ {row.name}
45
+ {row.required ? (
46
+ <React.Fragment key={`${row.name}-required-prop`}>
47
+ <span
48
+ aria-hidden="true"
49
+ key={`${row.name}-asterisk`}
50
+ className="ws-prop-required"
70
51
  >
71
- Beta
72
- </Badge>
73
- )}
74
- </div>,
75
- <div className="pf-m-break-word">
76
- <PropTypeWithLinks
77
- type={row.type}
78
- allPropComponents={allPropComponents}
79
- />
80
- </div>,
81
- <div className="pf-m-break-word">{row.defaultValue}</div>,
82
- <div className="pf-m-break-word">{row.description}</div>,
83
- ],
84
- }))}
85
- >
86
- <TableHeader />
87
- <TableBody />
88
- </Table>
89
- </React.Fragment>
90
- );
91
- };
52
+ *
53
+ </span>
54
+ <span
55
+ key={`${row.name}-required`}
56
+ className={css(accessibleStyles.screenReader)}
57
+ >
58
+ required
59
+ </span>
60
+ </React.Fragment>
61
+ ) : (
62
+ ""
63
+ )}
64
+ {row.beta && (
65
+ <Badge
66
+ key={`${row.name}-${idx}`}
67
+ className="ws-beta-badge pf-v5-u-ml-sm"
68
+ >
69
+ Beta
70
+ </Badge>
71
+ )}
72
+ </TableText>
73
+ </Td>
74
+ <Td>
75
+ <TableText wrapModifier="breakWord">
76
+ <PropTypeWithLinks
77
+ type={row.type}
78
+ allPropComponents={allPropComponents}
79
+ />
80
+ </TableText>
81
+ </Td>
82
+ <Td>
83
+ <TableText wrapModifier="breakWord">
84
+ {row.defaultValue}
85
+ </TableText>
86
+ </Td>
87
+ <Td>
88
+ <TableText wrapModifier="breakWord">
89
+ {row.description}
90
+ </TableText>
91
+ </Td>
92
+ </Tr>
93
+ ))}
94
+ </Tbody>
95
+ </Table>
96
+ </React.Fragment>
97
+ );
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { convertToReactComponent } from "@patternfly/ast-helpers";
3
+ import { TextContent, Text } from "@patternfly/react-core";
4
+
5
+ // convert summary text from string to jsx, remove links
6
+ export const SummaryComponent = ({ id, itemsData }) => {
7
+ const itemDasherized = id.split(' ').join('-').toLowerCase();
8
+ const summary = itemsData?.[itemDasherized]?.summary;
9
+ if (!summary) {
10
+ return null;
11
+ }
12
+ // Remove anchor tags to avoid <a> in summary nested within <a> of Link card/datalistitem
13
+ const summaryNoLinks = summary.replace(/<Link[^>]*>([^<]+)<\/Link>/gm, '$1');
14
+ const { code } = convertToReactComponent(`<>${summaryNoLinks}</>`);
15
+ const getSummaryComponent = new Function('React', code);
16
+ return getSummaryComponent(React);
17
+ }
18
+
19
+ export const TextSummary = ({ id, itemsData }) => {
20
+ if (!id) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <TextContent>
26
+ <Text>
27
+ <SummaryComponent id={id} itemsData={itemsData} />
28
+ </Text>
29
+ </TextContent>
30
+ )
31
+ };
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell, Split, SplitItem, TextContent, Text, TextVariants, Label } from "@patternfly/react-core";
3
+ import { Link } from '../link/link';
4
+ import { TextSummary } from './TextSummary';
5
+
6
+ export const SectionDataListLayout = ({ galleryItems, layoutView, hasListText, hasListImages }) => {
7
+ if (layoutView !== 'list') {
8
+ return null;
9
+ }
10
+
11
+ return (
12
+ <DataList onSelectDataListItem={() => {}}>
13
+ {galleryItems.map(({ idx, slug, illustration, itemName, title, isBeta, isDeprecated, isDemo, id, galleryItemsData }) => (
14
+ <Link to={slug} key={idx} className="ws-section-gallery-item">
15
+ <DataListItem>
16
+ <DataListItemRow>
17
+ <DataListItemCells dataListCells={[
18
+ hasListImages && illustration && (
19
+ <DataListCell width={1} key="illustration">
20
+ <div>
21
+ <img src={illustration} alt={`${itemName} illustration`} />
22
+ </div>
23
+ </DataListCell>
24
+ ),
25
+ <DataListCell width={5} key="text-description">
26
+ <Split className={ hasListText ? "pf-v5-u-mb-md" : null }>
27
+ <SplitItem isFilled>
28
+ <TextContent>
29
+ <Text component={TextVariants.h2}>
30
+ <span>
31
+ {title}
32
+ </span>
33
+ </Text>
34
+ </TextContent>
35
+ </SplitItem>
36
+ <SplitItem>
37
+ {isBeta && (<Label color="blue" isCompact>Beta</Label>)}
38
+ {!isBeta && isDeprecated && (<Label color="grey" isCompact>Deprecated</Label>)}
39
+ {!isBeta && !isDeprecated && isDemo && (<Label color="purple" isCompact>Demo</Label>)}
40
+ </SplitItem>
41
+ </Split>
42
+ { hasListText && <TextSummary id={id} itemsData={galleryItemsData} /> }
43
+ </DataListCell>
44
+ ]} />
45
+ </DataListItemRow>
46
+ </DataListItem>
47
+ </Link>
48
+ ))}
49
+ </DataList>
50
+ )
51
+ };
@@ -0,0 +1,53 @@
1
+ .ws-landing-page > * {
2
+ max-width: 832px;
3
+ }
4
+
5
+ .ws-landing-page > .ws-section-gallery-full-width {
6
+ max-width: initial;
7
+ }
8
+
9
+ .ws-section-gallery {
10
+ /* top placement */
11
+ margin-top: calc(var(--pf-v5-c-page__main-section--PaddingTop) * -1);
12
+ }
13
+
14
+ * + .ws-section-gallery {
15
+ /* top placement */
16
+ margin-top: unset;
17
+ }
18
+
19
+ /* Toolbar styles */
20
+ .ws-section-gallery .pf-v5-c-toolbar {
21
+ margin-left: calc(var(--pf-v5-c-page__main-section--PaddingLeft) * -1);
22
+ border-bottom: var(--pf-v5-c-page__sidebar--m-light--BorderRightWidth) solid var(--pf-v5-c-page__sidebar--m-light--BorderRightColor);
23
+ margin-bottom: var(--pf-v5-global--spacer--md);
24
+ width: calc(100% + var(--pf-v5-c-page__main-section--PaddingLeft) + var(--pf-v5-c-page__main-section--PaddingRight));
25
+ /* avoid hoverable data list items overlapping toolbar */
26
+ z-index: calc(var(--pf-v5-global--ZIndex--xs) + 2);
27
+ }
28
+
29
+ /* Match toolbar left-padding to gallery left-padding */
30
+ .ws-section-gallery .pf-v5-c-toolbar .pf-v5-c-toolbar__content {
31
+ --pf-v5-c-toolbar__content--PaddingLeft: var(--pf-v5-c-page__main-section--PaddingLeft);
32
+ }
33
+
34
+ /* Avoid toolbar wrap on smaller screens */
35
+ .ws-section-gallery .pf-v5-c-toolbar__content-section {
36
+ flex-wrap: nowrap;
37
+ }
38
+
39
+ /* Avoid link styling on gallery/data list item names */
40
+ .ws-section-gallery-item {
41
+ text-decoration: inherit;
42
+ color: inherit;
43
+ }
44
+
45
+ /* Ensure same height for all cards in a gallery row */
46
+ .ws-section-gallery .pf-v5-c-card {
47
+ height: 100%;
48
+ }
49
+
50
+ /* Limit width for data list view only */
51
+ .ws-section-gallery .pf-v5-c-data-list {
52
+ max-width: 956px;
53
+ }
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+
3
+ import './sectionGallery.css';
4
+ import { SectionGalleryToolbar } from "./sectionGalleryToolbar";
5
+ import { SectionGalleryLayout } from "./sectionGalleryLayout";
6
+ import { SectionDataListLayout } from "./sectionDataListLayout";
7
+ import { SectionGalleryWrapper } from "./sectionGalleryWrapper";
8
+
9
+ /**
10
+ * Helper component returns gallery of items with search toolbar and switchable gallery/data list views.
11
+ * @param {Object} illustrations - Object of preview images mapped to their snake_case item display name
12
+ * @param {string} section - Name of the navigation section to create the gallery within
13
+ * @param {Object} galleryItemsData - Object containing the image location & summary text mapped to the gallery item's hyphenated-name
14
+ * @param {string} [placeholderText=Search by name] - Optional text to be displayed as placeholder for SearchInput
15
+ * @param {string} [countText= items] - Optional text to be displayed after the number of search results
16
+ * @param {string} [initialLayout=grid] - Optional text to indicate whether to default to grid or list layout
17
+ * @param {Boolean} [hasGridText=false] - Optional boolean to toggle text on grid layout cards
18
+ * @param {Boolean} [hasGridImages=false] - Optional boolean to toggle images on grid layout cards
19
+ * @param {Boolean} [hasListText=false] - Optional boolean to toggle text on list layout rows
20
+ * @param {Boolean} [hasListImages=false] - Optional boolean to toggle images on list layout rows
21
+ * @param {Boolean} [isFullWidth=true] - Optional boolean to disable component from exceeding default max-width for page
22
+ */
23
+
24
+ export const SectionGallery = ({
25
+ illustrations,
26
+ section,
27
+ subsection = null,
28
+ includeSubsections = false,
29
+ parseSubsections = false,
30
+ galleryItemsData,
31
+ placeholderText,
32
+ countText,
33
+ initialLayout = "grid",
34
+ hasGridText = false,
35
+ hasGridImages = true,
36
+ hasListText = true,
37
+ hasListImages = true,
38
+ isFullWidth = true
39
+ }) => (
40
+ <SectionGalleryWrapper
41
+ illustrations={illustrations}
42
+ section={section}
43
+ subsection={subsection}
44
+ includeSubsections={includeSubsections}
45
+ parseSubsections={parseSubsections}
46
+ galleryItemsData={galleryItemsData}
47
+ initialLayout={initialLayout}
48
+ isFullWidth={isFullWidth}
49
+ >
50
+ {(sectionGalleryItems, searchTerm, setSearchTerm, layoutView, setLayoutView) => (
51
+ <>
52
+ <SectionGalleryToolbar
53
+ galleryItems={sectionGalleryItems}
54
+ searchTerm={searchTerm}
55
+ setSearchTerm={setSearchTerm}
56
+ layoutView={layoutView}
57
+ setLayoutView={setLayoutView}
58
+ placeholderText={placeholderText}
59
+ countText={countText}
60
+ />
61
+ <SectionGalleryLayout
62
+ galleryItems={sectionGalleryItems}
63
+ layoutView={layoutView}
64
+ hasGridText={hasGridText}
65
+ hasGridImages={hasGridImages}
66
+ />
67
+ <SectionDataListLayout
68
+ galleryItems={sectionGalleryItems}
69
+ layoutView={layoutView}
70
+ hasListText={hasListText}
71
+ hasListImages={hasListImages}
72
+ />
73
+ </>
74
+ )}
75
+ </SectionGalleryWrapper>
76
+ );
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { Gallery, GalleryItem, Card, CardTitle, CardBody, CardFooter, Label } from "@patternfly/react-core";
3
+ import { Link } from '../link/link';
4
+ import { TextSummary } from "./TextSummary";
5
+
6
+ export const SectionGalleryLayout = ({ galleryItems, layoutView, hasGridText, hasGridImages }) => {
7
+ if (layoutView !== 'grid') {
8
+ return null;
9
+ }
10
+
11
+ return (
12
+ <Gallery hasGutter>
13
+ {galleryItems.map(({idx, slug, id, itemName, illustration, isBeta, isDeprecated, isDemo, title, galleryItemsData}) => (
14
+ <GalleryItem span={4} key={idx}>
15
+ <Link to={slug} className="ws-section-gallery-item">
16
+ <Card
17
+ id={id}
18
+ key={idx}
19
+ isSelectableRaised
20
+ >
21
+ <CardTitle>{title}</CardTitle>
22
+ {(hasGridImages || hasGridText) && (
23
+ <CardBody>
24
+ { hasGridImages && illustration && <img src={illustration} alt={`${itemName} illustration`} /> }
25
+ { hasGridText && <TextSummary id={id} itemsData={galleryItemsData} /> }
26
+ </CardBody>
27
+ )}
28
+ {(isBeta || isDeprecated || isDemo) && (
29
+ <CardFooter>
30
+ {isBeta && (<Label color="blue" isCompact>Beta</Label>)}
31
+ {!isBeta && isDeprecated && (<Label color="grey" isCompact>Deprecated</Label>)}
32
+ {!isBeta && !isDeprecated && isDemo && (<Label color="purple" isCompact>Demo</Label>)}
33
+ </CardFooter>
34
+ )}
35
+ </Card>
36
+ </Link>
37
+ </GalleryItem>
38
+ ))}
39
+ </Gallery>
40
+ )
41
+ };