@patternfly/documentation-framework 1.2.6 → 1.2.9
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 +27 -0
- package/app.js +4 -1
- package/components/example/example.css +5 -1
- package/components/example/exampleToolbar.js +44 -39
- package/package.json +2 -2
- package/routes.js +0 -8
- package/scripts/webpack/webpack.base.config.js +2 -0
- package/templates/mdx.js +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.9 (2022-08-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **example:** increase code editor button tooltip size, other cleanup ([#3162](https://github.com/patternfly/patternfly-org/issues/3162)) ([fab30f5](https://github.com/patternfly/patternfly-org/commit/fab30f5b94b648605fd9efb980fc6eea2e772a79))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 1.2.8 (2022-08-26)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @patternfly/documentation-framework
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 1.2.7 (2022-08-24)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @patternfly/documentation-framework
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## 1.2.6 (2022-08-23)
|
|
7
34
|
|
|
8
35
|
**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}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--ws-code-editor--tooltip--MaxWidth: 16ch;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.ws-example {
|
|
2
6
|
margin-top: var(--pf-global--spacer--lg);
|
|
3
7
|
margin-bottom: var(--pf-global--spacer--lg);
|
|
@@ -128,4 +132,4 @@
|
|
|
128
132
|
|
|
129
133
|
.pf-theme-dark .ws-theme-switch-full-page::before {
|
|
130
134
|
background-color: var(--pf-global--BackgroundColor--300);
|
|
131
|
-
}
|
|
135
|
+
}
|
|
@@ -42,16 +42,6 @@ export const ExampleToolbar = ({
|
|
|
42
42
|
const [isEditorOpen, setIsEditorOpen] = React.useState(false);
|
|
43
43
|
const [isCopied, setCopied] = React.useState(false);
|
|
44
44
|
|
|
45
|
-
const copyCode = () => {
|
|
46
|
-
copy(code);
|
|
47
|
-
|
|
48
|
-
setCopied(true);
|
|
49
|
-
// Reset isCopied after Tooltip fades out
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
setCopied(false);
|
|
52
|
-
}, 2500);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
45
|
const copyLabel = 'Copy code to clipboard';
|
|
56
46
|
const languageLabel = `Toggle ${lang.toUpperCase()} code`;
|
|
57
47
|
const codesandboxLabel = 'Open example in CodeSandbox';
|
|
@@ -66,6 +56,22 @@ export const ExampleToolbar = ({
|
|
|
66
56
|
const convertAriaLabel = `Convert ${exampleTitle} example from Typescript to JavaScript`;
|
|
67
57
|
const undoAllAriaLabel = `Undo all changes to ${exampleTitle}`;
|
|
68
58
|
|
|
59
|
+
const editorControlProps = {
|
|
60
|
+
maxWidth: 'var(--ws-code-editor--tooltip--MaxWidth)',
|
|
61
|
+
className: "ws-code-editor-control",
|
|
62
|
+
exitDelay: 300
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const copyCode = () => {
|
|
66
|
+
copy(code);
|
|
67
|
+
|
|
68
|
+
setCopied(true);
|
|
69
|
+
// Reset isCopied after Tooltip fades out
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
setCopied(false);
|
|
72
|
+
}, 2500);
|
|
73
|
+
};
|
|
74
|
+
|
|
69
75
|
const customControls = (
|
|
70
76
|
<React.Fragment>
|
|
71
77
|
<CodeEditorControl
|
|
@@ -83,38 +89,37 @@ export const ExampleToolbar = ({
|
|
|
83
89
|
aria-label={languageAriaLabel}
|
|
84
90
|
toolTipText={languageLabel}
|
|
85
91
|
aria-expanded={isEditorOpen}
|
|
86
|
-
|
|
92
|
+
{...editorControlProps}
|
|
87
93
|
/>
|
|
88
94
|
<Tooltip
|
|
89
95
|
trigger="mouseenter"
|
|
90
96
|
content={<div>{isCopied ? 'Code copied' : copyLabel}</div>}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
maxWidth="100px"
|
|
94
|
-
position="top"
|
|
97
|
+
{...(isCopied && {exitDelay: 1600})}
|
|
98
|
+
maxWidth={editorControlProps.maxWidth}
|
|
95
99
|
>
|
|
96
|
-
<Button
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
<Button
|
|
101
|
+
onClick={() => {
|
|
102
|
+
copyCode();
|
|
103
|
+
trackEvent('code_editor_control_click', 'click_event', 'COPY_CODE');
|
|
104
|
+
}}
|
|
105
|
+
variant="control"
|
|
106
|
+
aria-label={copyAriaLabel}
|
|
107
|
+
className={editorControlProps.className}
|
|
108
|
+
>
|
|
100
109
|
<CopyIcon />
|
|
101
110
|
</Button>
|
|
102
111
|
</Tooltip>
|
|
103
112
|
{codeBoxParams &&
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
position="top"
|
|
113
|
+
<Form
|
|
114
|
+
aria-label={`${codesandboxAriaLabel} form` }
|
|
115
|
+
action="https://codesandbox.io/api/v1/sandboxes/define"
|
|
116
|
+
method="POST"
|
|
117
|
+
target="_blank"
|
|
118
|
+
style={{ display: "inline-block" }}
|
|
111
119
|
>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
method="POST"
|
|
116
|
-
target="_blank"
|
|
117
|
-
style={{ display: "inline-block" }}
|
|
120
|
+
<Tooltip
|
|
121
|
+
content={codesandboxLabel}
|
|
122
|
+
maxWidth={editorControlProps.maxWidth}
|
|
118
123
|
>
|
|
119
124
|
<Button
|
|
120
125
|
aria-label={codesandboxAriaLabel}
|
|
@@ -123,13 +128,13 @@ export const ExampleToolbar = ({
|
|
|
123
128
|
onClick={() => {
|
|
124
129
|
trackEvent('code_editor_control_click', 'click_event', 'CODESANDBOX_LINK');
|
|
125
130
|
}}
|
|
126
|
-
className=
|
|
131
|
+
className={editorControlProps.className}
|
|
127
132
|
>
|
|
128
|
-
<input type="hidden" name="parameters" value={codeBoxParams} />
|
|
129
133
|
<CodepenIcon />
|
|
130
134
|
</Button>
|
|
131
|
-
</
|
|
132
|
-
|
|
135
|
+
</Tooltip>
|
|
136
|
+
<input type="hidden" name="parameters" value={codeBoxParams} />
|
|
137
|
+
</Form>
|
|
133
138
|
}
|
|
134
139
|
{fullscreenLink &&
|
|
135
140
|
<CodeEditorControl
|
|
@@ -143,7 +148,7 @@ export const ExampleToolbar = ({
|
|
|
143
148
|
onClick={() => {
|
|
144
149
|
trackEvent('code_editor_control_click', 'click_event', 'FULLSCREEN_LINK');
|
|
145
150
|
}}
|
|
146
|
-
|
|
151
|
+
{...editorControlProps}
|
|
147
152
|
/>
|
|
148
153
|
}
|
|
149
154
|
{isEditorOpen && lang === 'ts' &&
|
|
@@ -159,7 +164,7 @@ export const ExampleToolbar = ({
|
|
|
159
164
|
setCode(convertToJSX(code).code);
|
|
160
165
|
trackEvent('code_editor_control_click', 'click_event', 'TS_TO_JS');
|
|
161
166
|
}}
|
|
162
|
-
|
|
167
|
+
{...editorControlProps}
|
|
163
168
|
/>
|
|
164
169
|
}
|
|
165
170
|
{code !== originalCode &&
|
|
@@ -171,7 +176,7 @@ export const ExampleToolbar = ({
|
|
|
171
176
|
setCode(originalCode);
|
|
172
177
|
trackEvent('code_editor_control_click', 'click_event', 'RESET_CODE');
|
|
173
178
|
}}
|
|
174
|
-
|
|
179
|
+
{...editorControlProps}
|
|
175
180
|
/>
|
|
176
181
|
}
|
|
177
182
|
</React.Fragment>
|
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.
|
|
4
|
+
"version": "1.2.9",
|
|
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": "
|
|
87
|
+
"gitHead": "d57187e286ba282527a77a189f47319f0fc3afd2"
|
|
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
|
-
{
|
|
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">
|