@patternfly/documentation-framework 2.0.0-alpha.52 → 2.0.0-alpha.54

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 CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 2.0.0-alpha.54 (2023-06-09)
7
+
8
+ **Note:** Version bump only for package @patternfly/documentation-framework
9
+
10
+
11
+
12
+
13
+
14
+ # 2.0.0-alpha.53 (2023-06-09)
15
+
16
+ **Note:** Version bump only for package @patternfly/documentation-framework
17
+
18
+
19
+
20
+
21
+
6
22
  # 2.0.0-alpha.52 (2023-06-07)
7
23
 
8
24
  **Note:** Version bump only for package @patternfly/documentation-framework
@@ -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
+ };
@@ -1,23 +1,9 @@
1
1
  import React from "react";
2
2
  import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell, Split, SplitItem, TextContent, Text, TextVariants, Label } from "@patternfly/react-core";
3
3
  import { Link } from '../link/link';
4
- import { convertToReactComponent } from "@patternfly/ast-helpers";
4
+ import { TextSummary } from './TextSummary';
5
5
 
6
- // convert summary text in drawer from string to jsx
7
- const SummaryComponent = ({ id, itemsData }) => {
8
- const itemDasherized = id.split(' ').join('-').toLowerCase();
9
- const summary = itemsData?.[itemDasherized]?.summary;
10
- if (!summary) {
11
- return null;
12
- }
13
- // Remove anchor tags to avoid <a> in summary nested within <a> of Link card/datalistitem
14
- const summaryNoLinks = summary.replace(/<Link[^>]*>([^<]+)<\/Link>/gm, '$1');
15
- const { code } = convertToReactComponent(`<>${summaryNoLinks}</>`);
16
- const getSummaryComponent = new Function('React', code);
17
- return getSummaryComponent(React);
18
- }
19
-
20
- export const SectionDataListLayout = ({ galleryItems, layoutView }) => {
6
+ export const SectionDataListLayout = ({ galleryItems, layoutView, hasListText, hasListImages }) => {
21
7
  if (layoutView !== 'list') {
22
8
  return null;
23
9
  }
@@ -29,15 +15,15 @@ export const SectionDataListLayout = ({ galleryItems, layoutView }) => {
29
15
  <DataListItem>
30
16
  <DataListItemRow>
31
17
  <DataListItemCells dataListCells={[
32
- <DataListCell width={1} key="illustration">
33
- {illustration && (
18
+ hasListImages && illustration && (
19
+ <DataListCell width={1} key="illustration">
34
20
  <div>
35
21
  <img src={illustration} alt={`${itemName} illustration`} />
36
22
  </div>
37
- )}
38
- </DataListCell>,
23
+ </DataListCell>
24
+ ),
39
25
  <DataListCell width={5} key="text-description">
40
- <Split className="pf-v5-u-mb-md">
26
+ <Split className={ hasListText ? "pf-v5-u-mb-md" : null }>
41
27
  <SplitItem isFilled>
42
28
  <TextContent>
43
29
  <Text component={TextVariants.h2}>
@@ -51,11 +37,7 @@ export const SectionDataListLayout = ({ galleryItems, layoutView }) => {
51
37
  {isBeta && <Label color="gold">Beta feature</Label>}
52
38
  </SplitItem>
53
39
  </Split>
54
- <TextContent>
55
- <Text>
56
- { id ? <SummaryComponent id={id} itemsData={galleryItemsData} /> : null }
57
- </Text>
58
- </TextContent>
40
+ { hasListText && <TextSummary id={id} itemsData={galleryItemsData} /> }
59
41
  </DataListCell>
60
42
  ]} />
61
43
  </DataListItemRow>
@@ -1,4 +1,4 @@
1
- ..ws-mdx-content-content {
1
+ .ws-mdx-content-content {
2
2
  max-width: initial !important;
3
3
  }
4
4
 
@@ -7,6 +7,11 @@
7
7
  margin-top: calc(var(--pf-v5-c-page__main-section--PaddingTop) * -1);
8
8
  }
9
9
 
10
+ * + .ws-section-gallery {
11
+ /* top placement */
12
+ margin-top: unset;
13
+ }
14
+
10
15
  /* Toolbar styles */
11
16
  .ws-section-gallery .pf-v5-c-toolbar {
12
17
  margin-left: calc(var(--pf-v5-c-page__main-section--PaddingLeft) * -1);
@@ -13,6 +13,11 @@ import { SectionGalleryWrapper } from "./sectionGalleryWrapper";
13
13
  * @param {Object} galleryItemsData - Object containing the image location & summary text mapped to the gallery item's hyphenated-name
14
14
  * @param {string} [placeholderText=Search by name] - Optional text to be displayed as placeholder for SearchInput
15
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
16
21
  */
17
22
 
18
23
  export const SectionGallery = ({
@@ -23,7 +28,12 @@ export const SectionGallery = ({
23
28
  parseSubsections = false,
24
29
  galleryItemsData,
25
30
  placeholderText,
26
- countText
31
+ countText,
32
+ initialLayout = "grid",
33
+ hasGridText = false,
34
+ hasGridImages = true,
35
+ hasListText = true,
36
+ hasListImages = true
27
37
  }) => (
28
38
  <SectionGalleryWrapper
29
39
  illustrations={illustrations}
@@ -32,9 +42,9 @@ export const SectionGallery = ({
32
42
  includeSubsections={includeSubsections}
33
43
  parseSubsections={parseSubsections}
34
44
  galleryItemsData={galleryItemsData}
45
+ initialLayout={initialLayout}
35
46
  >
36
- {(sectionGalleryItems, searchTerm, setSearchTerm, layoutView, setLayoutView) => {
37
- return (
47
+ {(sectionGalleryItems, searchTerm, setSearchTerm, layoutView, setLayoutView) => (
38
48
  <>
39
49
  <SectionGalleryToolbar
40
50
  galleryItems={sectionGalleryItems}
@@ -45,9 +55,19 @@ export const SectionGallery = ({
45
55
  placeholderText={placeholderText}
46
56
  countText={countText}
47
57
  />
48
- <SectionGalleryLayout galleryItems={sectionGalleryItems} layoutView={layoutView} />
49
- <SectionDataListLayout galleryItems={sectionGalleryItems} layoutView={layoutView} />
58
+ <SectionGalleryLayout
59
+ galleryItems={sectionGalleryItems}
60
+ layoutView={layoutView}
61
+ hasGridText={hasGridText}
62
+ hasGridImages={hasGridImages}
63
+ />
64
+ <SectionDataListLayout
65
+ galleryItems={sectionGalleryItems}
66
+ layoutView={layoutView}
67
+ hasListText={hasListText}
68
+ hasListImages={hasListImages}
69
+ />
50
70
  </>
51
- )}}
71
+ )}
52
72
  </SectionGalleryWrapper>
53
73
  );
@@ -1,15 +1,16 @@
1
1
  import React from "react";
2
2
  import { Gallery, GalleryItem, Card, CardTitle, CardBody, CardFooter, Label } from "@patternfly/react-core";
3
3
  import { Link } from '../link/link';
4
+ import { TextSummary } from "./TextSummary";
4
5
 
5
- export const SectionGalleryLayout = ({ galleryItems, layoutView }) => {
6
+ export const SectionGalleryLayout = ({ galleryItems, layoutView, hasGridText, hasGridImages }) => {
6
7
  if (layoutView !== 'grid') {
7
8
  return null;
8
9
  }
9
10
 
10
11
  return (
11
12
  <Gallery hasGutter>
12
- {galleryItems.map(({idx, slug, id, itemName, illustration, isBeta}) => (
13
+ {galleryItems.map(({idx, slug, id, itemName, illustration, isBeta, title, galleryItemsData}) => (
13
14
  <GalleryItem span={4} key={idx}>
14
15
  <Link to={slug} className="ws-section-gallery-item">
15
16
  <Card
@@ -17,10 +18,11 @@ export const SectionGalleryLayout = ({ galleryItems, layoutView }) => {
17
18
  key={idx}
18
19
  isSelectableRaised
19
20
  >
20
- <CardTitle>{itemName}</CardTitle>
21
- {illustration && (
21
+ <CardTitle>{title}</CardTitle>
22
+ {(hasGridImages || hasGridText) && (
22
23
  <CardBody>
23
- <img src={illustration} alt={`${itemName} illustration`} />
24
+ { hasGridImages && illustration && <img src={illustration} alt={`${itemName} illustration`} /> }
25
+ { hasGridText && <TextSummary id={id} itemsData={galleryItemsData} /> }
24
26
  </CardBody>
25
27
  )}
26
28
  {isBeta && (
@@ -3,7 +3,15 @@ import { Button, SearchInput, Toolbar, ToolbarContent, ToolbarGroup, ToolbarItem
3
3
  import ListIcon from '@patternfly/react-icons/dist/esm/icons/list-icon';
4
4
  import ThIcon from'@patternfly/react-icons/dist/esm/icons/th-icon';
5
5
 
6
- export const SectionGalleryToolbar = ({ galleryItems, searchTerm, setSearchTerm, layoutView, setLayoutView, placeholderText ="Search by name", countText=" items" }) => (
6
+ export const SectionGalleryToolbar = ({
7
+ galleryItems,
8
+ searchTerm,
9
+ setSearchTerm,
10
+ layoutView,
11
+ setLayoutView,
12
+ placeholderText ="Search by name",
13
+ countText=" items"
14
+ }) => (
7
15
  <Toolbar isSticky>
8
16
  <ToolbarContent>
9
17
  <ToolbarItem variant="search-filter" widths={{default: '100%', md: '320px'}}>
@@ -1,7 +1,16 @@
1
1
  import React from "react";
2
2
  import { groupedRoutes } from '../../routes';
3
3
 
4
- export const SectionGalleryWrapper = ({section, subsection, galleryItemsData, illustrations, includeSubsections, parseSubsections, children }) => {
4
+ export const SectionGalleryWrapper = ({
5
+ section,
6
+ subsection,
7
+ galleryItemsData,
8
+ illustrations,
9
+ includeSubsections,
10
+ parseSubsections,
11
+ initialLayout,
12
+ children
13
+ }) => {
5
14
  let sectionRoutes = subsection ? groupedRoutes[section][subsection] : groupedRoutes[section];
6
15
  if (!includeSubsections || parseSubsections) {
7
16
  const sectionRoutesArr = Object.entries(sectionRoutes);
@@ -29,7 +38,7 @@ export const SectionGalleryWrapper = ({section, subsection, galleryItemsData, il
29
38
  }
30
39
 
31
40
  const [searchTerm, setSearchTerm] = React.useState('');
32
- const [layoutView, setLayoutView] = React.useState('grid');
41
+ const [layoutView, setLayoutView] = React.useState(initialLayout);
33
42
  const filteredItems = Object.entries(sectionRoutes)
34
43
  .filter(([itemName, { slug }]) => (
35
44
  // exclude current gallery page from results
@@ -41,15 +50,21 @@ export const SectionGalleryWrapper = ({section, subsection, galleryItemsData, il
41
50
  const sectionGalleryItems = filteredItems
42
51
  .sort(([itemName1], [itemName2]) => itemName1.localeCompare(itemName2))
43
52
  .map(([itemName, itemData], idx) => {
44
- // Convert to lowercase-camelcase ex: File upload - multiple ==> file_upload_multiple
45
- const illustrationName = itemName
46
- .replace('-', '')
47
- .replace(' ',' ')
48
- .split(' ')
49
- .join('_')
50
- .toLowerCase();
51
- const illustration = illustrations[illustrationName] || illustrations.default_placeholder;
52
- const { title, id, sources, isSubsection = false } = itemData;
53
+ let illustration = null;
54
+ if (illustrations) {
55
+ // Convert to lowercase-camelcase ex: File upload - multiple ==> file_upload_multiple
56
+ const illustrationName = itemName
57
+ .replace('-', '')
58
+ .replace(' ',' ')
59
+ .split(' ')
60
+ .join('_')
61
+ .toLowerCase();
62
+ illustration = illustrations[illustrationName] || illustrations.default_placeholder;
63
+ }
64
+ const { sources, isSubsection = false } = itemData;
65
+ // Subsections don't have title or id, default to itemName aka sidenav text
66
+ const title = itemData.title || itemName;
67
+ const id = itemData.id || title;
53
68
  // Display beta label if tab other than a '-next' tab is marked Beta
54
69
  const isBeta = !isSubsection && sources && sources.some(src => src.beta && !src.source.includes('-next'));
55
70
  let slug = itemData.slug;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@patternfly/documentation-framework",
3
3
  "description": "A framework to build documentation for PatternFly.",
4
- "version": "2.0.0-alpha.52",
4
+ "version": "2.0.0-alpha.54",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -91,5 +91,5 @@
91
91
  "react": "^17.0.0 || ^18.0.0",
92
92
  "react-dom": "^17.0.0 || ^18.0.0"
93
93
  },
94
- "gitHead": "a31454d8349dec1c5f8b5a15a7121b7b2d9435b2"
94
+ "gitHead": "8d1f88aa9a0c9318d65e4db4113418628fd5b795"
95
95
  }