@patternfly/documentation-framework 6.0.0-alpha.27 → 6.0.0-alpha.28
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 +8 -0
- package/components/example/example.js +118 -52
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
# 6.0.0-alpha.28 (2024-05-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/documentation-framework
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# 6.0.0-alpha.27 (2024-05-14)
|
|
7
15
|
|
|
8
16
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { useLocation } from '@reach/router';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
CodeBlock,
|
|
6
|
+
Flex,
|
|
7
|
+
CodeBlockCode,
|
|
8
|
+
debounce,
|
|
9
|
+
Label,
|
|
10
|
+
Switch,
|
|
11
|
+
Tooltip,
|
|
12
|
+
} from '@patternfly/react-core';
|
|
4
13
|
import * as reactCoreModule from '@patternfly/react-core';
|
|
5
14
|
import * as reactCoreNextModule from '@patternfly/react-core/next';
|
|
6
15
|
import * as reactCoreDeprecatedModule from '@patternfly/react-core/deprecated';
|
|
@@ -16,13 +25,13 @@ import {
|
|
|
16
25
|
getReactParams,
|
|
17
26
|
getExampleClassName,
|
|
18
27
|
getExampleId,
|
|
19
|
-
liveCodeTypes
|
|
28
|
+
liveCodeTypes,
|
|
20
29
|
} from '../../helpers';
|
|
21
30
|
import { convertToReactComponent } from '@patternfly/ast-helpers';
|
|
22
31
|
import missingThumbnail from './missing-thumbnail.jpg';
|
|
23
32
|
import { RtlContext } from '../../layouts';
|
|
24
33
|
|
|
25
|
-
const errorComponent = err => <pre>{err.toString()}</pre>;
|
|
34
|
+
const errorComponent = (err) => <pre>{err.toString()}</pre>;
|
|
26
35
|
|
|
27
36
|
class ErrorBoundary extends React.Component {
|
|
28
37
|
constructor(props) {
|
|
@@ -34,7 +43,7 @@ class ErrorBoundary extends React.Component {
|
|
|
34
43
|
errorInfo._suppressLogging = true;
|
|
35
44
|
this.setState({
|
|
36
45
|
error: error,
|
|
37
|
-
errorInfo: errorInfo
|
|
46
|
+
errorInfo: errorInfo,
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -94,15 +103,24 @@ export const Example = ({
|
|
|
94
103
|
// md file location in node_modules, used to resolve relative import paths in examples
|
|
95
104
|
relPath = '',
|
|
96
105
|
// absolute url to hosted file
|
|
97
|
-
sourceLink = ''
|
|
106
|
+
sourceLink = '',
|
|
98
107
|
}) => {
|
|
99
108
|
if (isFullscreenPreview) {
|
|
100
109
|
isFullscreen = false;
|
|
101
|
-
window.addEventListener('load', () => {
|
|
102
|
-
//append a class to the document body to indicate to screenshot/automated visual regression tools that the page has loaded
|
|
103
|
-
document.body.classList.add('page-loaded');
|
|
104
|
-
});
|
|
105
110
|
}
|
|
111
|
+
|
|
112
|
+
//append a class to the document body on fullscreen examples to indicate to screenshot/automated visual regression tools that the page has loaded
|
|
113
|
+
const addPageLoadedClass = () => document.body.classList.add('page-loaded');
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!isFullscreenPreview) return;
|
|
116
|
+
|
|
117
|
+
document.readyState === 'complete'
|
|
118
|
+
? addPageLoadedClass()
|
|
119
|
+
: window.addEventListener('load', addPageLoadedClass);
|
|
120
|
+
|
|
121
|
+
return () => window.removeEventListener('load', addPageLoadedClass);
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
106
124
|
if (!lang) {
|
|
107
125
|
// Inline code
|
|
108
126
|
return <code className="ws-code">{code}</code>;
|
|
@@ -124,20 +142,26 @@ export const Example = ({
|
|
|
124
142
|
...reactCoreModule,
|
|
125
143
|
...reactTableModule,
|
|
126
144
|
...(source === 'react-next' ? reactCoreNextModule : {}),
|
|
127
|
-
...(source === 'react-deprecated'
|
|
145
|
+
...(source === 'react-deprecated'
|
|
146
|
+
? { ...reactCoreDeprecatedModule, ...reactTableDeprecatedModule }
|
|
147
|
+
: {}),
|
|
128
148
|
};
|
|
129
149
|
|
|
130
150
|
let livePreview = null;
|
|
131
151
|
if (lang === 'html') {
|
|
132
152
|
livePreview = (
|
|
133
153
|
<div
|
|
134
|
-
className={css(
|
|
154
|
+
className={css(
|
|
155
|
+
'ws-preview-html',
|
|
156
|
+
isFullscreenPreview && 'pf-v6-u-h-100'
|
|
157
|
+
)}
|
|
135
158
|
dangerouslySetInnerHTML={{ __html: editorCode }}
|
|
136
159
|
/>
|
|
137
160
|
);
|
|
138
161
|
} else {
|
|
139
162
|
try {
|
|
140
|
-
const { code: transformedCode, hasTS } =
|
|
163
|
+
const { code: transformedCode, hasTS } =
|
|
164
|
+
convertToReactComponent(editorCode);
|
|
141
165
|
if (hasTS) {
|
|
142
166
|
lang = 'ts';
|
|
143
167
|
} else {
|
|
@@ -147,7 +171,11 @@ export const Example = ({
|
|
|
147
171
|
const componentNames = Object.keys(scope);
|
|
148
172
|
const componentValues = Object.values(scope);
|
|
149
173
|
|
|
150
|
-
const getPreviewComponent = new Function(
|
|
174
|
+
const getPreviewComponent = new Function(
|
|
175
|
+
'React',
|
|
176
|
+
...componentNames,
|
|
177
|
+
transformedCode
|
|
178
|
+
);
|
|
151
179
|
const PreviewComponent = getPreviewComponent(React, ...componentValues);
|
|
152
180
|
|
|
153
181
|
livePreview = (
|
|
@@ -167,17 +195,34 @@ export const Example = ({
|
|
|
167
195
|
<div id={previewId} className={css(className, 'pf-v6-u-h-100')}>
|
|
168
196
|
{livePreview}
|
|
169
197
|
{(hasDarkThemeSwitcher || hasRTLSwitcher) && (
|
|
170
|
-
<Flex
|
|
198
|
+
<Flex
|
|
199
|
+
direction={{ default: 'column' }}
|
|
200
|
+
gap={{ default: 'gapLg' }}
|
|
201
|
+
className="ws-full-page-utils pf-v6-m-dir-ltr "
|
|
202
|
+
>
|
|
171
203
|
{hasDarkThemeSwitcher && (
|
|
172
|
-
<Switch
|
|
173
|
-
|
|
204
|
+
<Switch
|
|
205
|
+
id="ws-example-theme-switch"
|
|
206
|
+
label="Dark theme"
|
|
207
|
+
defaultChecked={false}
|
|
208
|
+
onChange={() =>
|
|
209
|
+
document
|
|
210
|
+
.querySelector('html')
|
|
211
|
+
.classList.toggle('pf-v6-theme-dark')
|
|
212
|
+
}
|
|
213
|
+
/>
|
|
174
214
|
)}
|
|
175
215
|
{hasRTLSwitcher && (
|
|
176
|
-
<Switch
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
216
|
+
<Switch
|
|
217
|
+
id="ws-example-rtl-switch"
|
|
218
|
+
label="RTL"
|
|
219
|
+
defaultChecked={false}
|
|
220
|
+
onChange={() => {
|
|
221
|
+
const html = document.querySelector('html');
|
|
222
|
+
const curDir = html.dir;
|
|
223
|
+
html.dir = curDir !== 'rtl' ? 'rtl' : 'ltr';
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
181
226
|
)}
|
|
182
227
|
</Flex>
|
|
183
228
|
)}
|
|
@@ -188,12 +233,21 @@ export const Example = ({
|
|
|
188
233
|
const codeBoxParams = getParameters(
|
|
189
234
|
lang === 'html'
|
|
190
235
|
? getStaticParams(title, editorCode)
|
|
191
|
-
: getReactParams(
|
|
236
|
+
: getReactParams(
|
|
237
|
+
title,
|
|
238
|
+
editorCode,
|
|
239
|
+
scope,
|
|
240
|
+
lang,
|
|
241
|
+
relativeImports,
|
|
242
|
+
relPath,
|
|
243
|
+
sourceLink
|
|
244
|
+
)
|
|
192
245
|
);
|
|
193
|
-
const fullscreenLink =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
+
|
|
246
|
+
const fullscreenLink =
|
|
247
|
+
loc.pathname.replace(/\/$/, '') +
|
|
248
|
+
(loc.pathname.endsWith(source) ? '' : `/${source}`) +
|
|
249
|
+
'/' +
|
|
250
|
+
slugger(title);
|
|
197
251
|
|
|
198
252
|
return (
|
|
199
253
|
<div className="ws-example">
|
|
@@ -204,21 +258,27 @@ export const Example = ({
|
|
|
204
258
|
{isBeta && (
|
|
205
259
|
<Tooltip content="This beta component is currently under review and is still open for further evolution.">
|
|
206
260
|
<Button variant="plain" hasNoPadding>
|
|
207
|
-
<Label isCompact color="blue">
|
|
261
|
+
<Label isCompact color="blue">
|
|
262
|
+
Beta
|
|
263
|
+
</Label>
|
|
208
264
|
</Button>
|
|
209
265
|
</Tooltip>
|
|
210
266
|
)}
|
|
211
267
|
{isDemo && (
|
|
212
268
|
<Tooltip content="Demos show how multiple components can be used in a single design.">
|
|
213
269
|
<Button variant="plain" hasNoPadding>
|
|
214
|
-
<Label isCompact color="purple">
|
|
270
|
+
<Label isCompact color="purple">
|
|
271
|
+
Demo
|
|
272
|
+
</Label>
|
|
215
273
|
</Button>
|
|
216
274
|
</Tooltip>
|
|
217
275
|
)}
|
|
218
276
|
{isDeprecated && (
|
|
219
277
|
<Tooltip content="Deprecated components are available for use but are no longer being maintained or enhanced.">
|
|
220
278
|
<Button variant="plain" hasNoPadding>
|
|
221
|
-
<Label isCompact color="grey">
|
|
279
|
+
<Label isCompact color="grey">
|
|
280
|
+
Deprecated
|
|
281
|
+
</Label>
|
|
222
282
|
</Button>
|
|
223
283
|
</Tooltip>
|
|
224
284
|
)}
|
|
@@ -232,28 +292,34 @@ export const Example = ({
|
|
|
232
292
|
</AutoLinkHeader>
|
|
233
293
|
{children}
|
|
234
294
|
</div>
|
|
235
|
-
{isFullscreen
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
>
|
|
243
|
-
<img src={thumbnail.src} width={thumbnail.width} height={thumbnail.height} alt={`${title} screenshot`} />
|
|
244
|
-
</a>
|
|
245
|
-
</div>
|
|
246
|
-
: <div
|
|
247
|
-
id={previewId}
|
|
248
|
-
className={css(
|
|
249
|
-
className,
|
|
250
|
-
isFullscreen ? 'ws-preview-fullscreen' : 'ws-preview',
|
|
251
|
-
isRTL && 'pf-v6-m-dir-rtl')
|
|
252
|
-
}
|
|
295
|
+
{isFullscreen ? (
|
|
296
|
+
<div className="ws-preview">
|
|
297
|
+
<a
|
|
298
|
+
className="ws-preview__thumbnail-link"
|
|
299
|
+
href={fullscreenLink}
|
|
300
|
+
target="_blank"
|
|
301
|
+
aria-label={`Open fullscreen ${title} example`}
|
|
253
302
|
>
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
303
|
+
<img
|
|
304
|
+
src={thumbnail.src}
|
|
305
|
+
width={thumbnail.width}
|
|
306
|
+
height={thumbnail.height}
|
|
307
|
+
alt={`${title} screenshot`}
|
|
308
|
+
/>
|
|
309
|
+
</a>
|
|
310
|
+
</div>
|
|
311
|
+
) : (
|
|
312
|
+
<div
|
|
313
|
+
id={previewId}
|
|
314
|
+
className={css(
|
|
315
|
+
className,
|
|
316
|
+
isFullscreen ? 'ws-preview-fullscreen' : 'ws-preview',
|
|
317
|
+
isRTL && 'pf-v6-m-dir-rtl'
|
|
318
|
+
)}
|
|
319
|
+
>
|
|
320
|
+
{livePreview}
|
|
321
|
+
</div>
|
|
322
|
+
)}
|
|
257
323
|
<ExampleToolbar
|
|
258
324
|
lang={lang}
|
|
259
325
|
isFullscreen={isFullscreen}
|
|
@@ -266,4 +332,4 @@ export const Example = ({
|
|
|
266
332
|
/>
|
|
267
333
|
</div>
|
|
268
334
|
);
|
|
269
|
-
}
|
|
335
|
+
};
|
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": "6.0.0-alpha.
|
|
4
|
+
"version": "6.0.0-alpha.28",
|
|
5
5
|
"author": "Red Hat",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@babel/preset-env": "^7.24.3",
|
|
14
14
|
"@babel/preset-react": "^7.24.1",
|
|
15
15
|
"@mdx-js/util": "1.6.16",
|
|
16
|
-
"@patternfly/ast-helpers": "^1.4.0-alpha.
|
|
16
|
+
"@patternfly/ast-helpers": "^1.4.0-alpha.17",
|
|
17
17
|
"@reach/router": "npm:@gatsbyjs/reach-router@1.3.9",
|
|
18
18
|
"autoprefixer": "9.8.6",
|
|
19
19
|
"babel-loader": "^9.1.3",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"react": "^17.0.0 || ^18.0.0",
|
|
81
81
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "b4fb80a1f793864b98221f04a868b229d1b22bc4"
|
|
84
84
|
}
|