@patternfly/documentation-framework 1.2.5 → 1.2.8

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,30 @@
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
+ ## 1.2.8 (2022-08-26)
7
+
8
+ **Note:** Version bump only for package @patternfly/documentation-framework
9
+
10
+
11
+
12
+
13
+
14
+ ## 1.2.7 (2022-08-24)
15
+
16
+ **Note:** Version bump only for package @patternfly/documentation-framework
17
+
18
+
19
+
20
+
21
+
22
+ ## 1.2.6 (2022-08-23)
23
+
24
+ **Note:** Version bump only for package @patternfly/documentation-framework
25
+
26
+
27
+
28
+
29
+
6
30
  ## 1.2.5 (2022-08-22)
7
31
 
8
32
  **Note:** Version bump only for package @patternfly/documentation-framework
package/app.js CHANGED
@@ -38,12 +38,13 @@ const AppRoute = ({ child, katacodaLayout, title, path }) => {
38
38
 
39
39
  const SideNavRouter = () => {
40
40
  const pathname = useLocation().pathname.replace(process.env.pathPrefix, '');
41
+ const componentsData = process?.env?.componentsData;
41
42
  const navOpen = !routes[pathname] || !routes[pathname].katacodaLayout;
42
43
  return (
43
44
  <SideNavLayout groupedRoutes={groupedRoutes} navOpen={navOpen} >
44
45
  <Router id="ws-page-content-router">
45
46
  {Object.entries(routes)
46
- .map(([path, { Component, title, sources, katacodaLayout }]) => Component
47
+ .map(([path, { Component, title, sources, katacodaLayout, id }]) => Component
47
48
  ? <AppRoute
48
49
  key={path}
49
50
  path={path}
@@ -60,6 +61,8 @@ const SideNavRouter = () => {
60
61
  path={path}
61
62
  title={title}
62
63
  sources={sources}
64
+ id={id}
65
+ componentsData={componentsData}
63
66
  />
64
67
  }
65
68
  katacodaLayout={katacodaLayout}
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": "1.2.5",
4
+ "version": "1.2.8",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -84,5 +84,5 @@
84
84
  "react": "^16.8.0 || ^17.0.0",
85
85
  "react-dom": "^16.8.0 || ^17.0.0"
86
86
  },
87
- "gitHead": "7e1dda7868f519789d354e8ddc3121cd42bbbd81"
87
+ "gitHead": "2942543cb4647ce220f5feeeadbd0ea91a359417"
88
88
  }
package/routes.js CHANGED
@@ -93,14 +93,6 @@ Object.entries(groupedRoutes)
93
93
  pageData.sources.forEach(({ slug }) => {
94
94
  delete routes[slug];
95
95
  });
96
- // Add design guidelines if doesn't exist
97
- if (
98
- ['components', 'charts', 'layouts', 'demos'].includes(section) &&
99
- !pageData.sources.map(({ source }) => source).includes('design-guidelines') &&
100
- process.env.hasDesignGuidelines
101
- ) {
102
- pageData.sources.push(getDefaultDesignGuidelines(pageData));
103
- }
104
96
  // Sort sources for tabs
105
97
  pageData.sources = pageData.sources.sort(sortSources);
106
98
  // Add grouped route
@@ -14,6 +14,7 @@ module.exports = (_env, argv) => {
14
14
  hasVersionSwitcher = false,
15
15
  hasDesignGuidelines = false,
16
16
  hasDarkThemeSwitcher = false,
17
+ componentsData = {},
17
18
  sideNavItems = [],
18
19
  topNavItems = [],
19
20
  includePaths = []
@@ -139,6 +140,7 @@ module.exports = (_env, argv) => {
139
140
  'process.env.hasVersionSwitcher': JSON.stringify(hasVersionSwitcher),
140
141
  'process.env.hasDesignGuidelines': JSON.stringify(hasDesignGuidelines),
141
142
  'process.env.hasDarkThemeSwitcher': JSON.stringify(hasDarkThemeSwitcher),
143
+ 'process.env.componentsData': JSON.stringify(componentsData),
142
144
  'process.env.sideNavItems': JSON.stringify(sideNavItems),
143
145
  'process.env.topNavItems': JSON.stringify(topNavItems),
144
146
  'process.env.prnum': JSON.stringify(process.env.CIRCLE_PR_NUMBER || process.env.PR_NUMBER || ''),
package/templates/mdx.js CHANGED
@@ -6,6 +6,7 @@ import { Router, useLocation } from '@reach/router';
6
6
  import { CSSVariables, PropsTable, TableOfContents, Link, AutoLinkHeader, InlineAlert } from '../components';
7
7
  import { capitalize, getTitle, slugger, trackEvent } from '../helpers';
8
8
  import './mdx.css';
9
+ import { convertToReactComponent } from '@patternfly/ast-helpers';
9
10
 
10
11
  const MDXChildTemplate = ({
11
12
  Component,
@@ -116,13 +117,26 @@ const MDXChildTemplate = ({
116
117
  export const MDXTemplate = ({
117
118
  title,
118
119
  sources = [],
119
- path
120
+ path,
121
+ id,
122
+ componentsData
120
123
  }) => {
121
124
  const sourceKeys = sources.map(v => v.source);
122
125
  const isSinglePage = sourceKeys.length === 1;
126
+ const isComponent = sources.some(source => source.section === 'components');
123
127
  const { pathname } = useLocation();
124
128
  const { katacodaLayout } = sources[0].Component.getPageData();
125
129
  let activeSource = pathname.replace(/\/$/, '').split('/').pop();
130
+ // get summary text, convert to JSX to display above tabs on component pages
131
+ const componentDasherized = id.split(' ').join('-').toLowerCase();
132
+ const summary = componentsData?.[componentDasherized]?.summary;
133
+ let SummaryComponent;
134
+ if (summary) {
135
+ const summaryCode = convertToReactComponent(`<p>${summary}</p>`).code;
136
+ const getSummaryComponent = new Function('React', 'Link', summaryCode);
137
+ SummaryComponent = getSummaryComponent(React, Link);
138
+ }
139
+
126
140
  if (!sourceKeys.includes(activeSource)) {
127
141
  activeSource = sourceKeys[0];
128
142
  }
@@ -141,7 +155,12 @@ export const MDXTemplate = ({
141
155
  {title}
142
156
  </Title>}
143
157
  </PageSection>
144
- {!isSinglePage && (
158
+ {isComponent && summary && (
159
+ <PageSection variant={PageSectionVariants.light} className="pf-u-pt-0">
160
+ <SummaryComponent />
161
+ </PageSection>
162
+ )}
163
+ {(!isSinglePage || isComponent) && (
145
164
  <PageSection type="tabs">
146
165
  <div className="pf-c-tabs pf-m-page-insets pf-m-no-border-bottom">
147
166
  <ul className="pf-c-tabs__list">