@patternfly/documentation-framework 6.0.0-alpha.8 → 6.0.0-alpha.81
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 +1165 -0
- package/app.js +2 -5
- package/components/autoLinkHeader/autoLinkHeader.css +2 -2
- package/components/autoLinkHeader/autoLinkHeader.js +8 -19
- package/components/cssVariables/cssVariables.css +9 -11
- package/components/cssVariables/cssVariables.js +19 -32
- package/components/example/example.css +14 -58
- package/components/example/example.js +149 -78
- package/components/example/exampleToolbar.js +3 -2
- package/components/footer/footer.css +16 -16
- package/components/footer/footer.js +32 -32
- package/components/gdprBanner/gdprBanner.css +0 -3
- package/components/gdprBanner/gdprBanner.js +22 -16
- package/components/inlineAlert/inlineAlert.js +1 -1
- package/components/link/link.js +23 -18
- package/components/propsTable/propsTable.js +14 -10
- package/components/sectionGallery/TextSummary.js +5 -5
- package/components/sectionGallery/sectionDataListLayout.js +87 -41
- package/components/sectionGallery/sectionGallery.css +6 -39
- package/components/sectionGallery/sectionGalleryLayout.js +73 -23
- package/components/sectionGallery/sectionGalleryToolbar.js +47 -12
- package/components/sideNav/sideNav.js +3 -4
- package/components/tableOfContents/tableOfContents.css +26 -35
- package/components/tableOfContents/tableOfContents.js +58 -28
- package/layouts/sideNavLayout/sideNavLayout.css +1 -36
- package/layouts/sideNavLayout/sideNavLayout.js +188 -101
- package/package.json +12 -19
- package/pages/404/404.css +2 -2
- package/pages/404/index.js +23 -36
- package/routes.js +3 -1
- package/scripts/md/anchor-header.js +1 -1
- package/scripts/md/parseMD.js +20 -18
- package/scripts/md/styled-tags.js +22 -14
- package/scripts/webpack/webpack.base.config.js +7 -18
- package/scripts/writeScreenshots.js +2 -2
- package/templates/mdx.css +11 -288
- package/templates/mdx.js +40 -43
- package/templates/patternfly-docs/patternfly-docs.source.js +8 -8
- package/versions.json +42 -14
- package/components/sideNav/sideNav.css +0 -21
- package/pages/global-css-variables.md +0 -109
- package/pages/img/component-variable-mapping.png +0 -0
package/app.js
CHANGED
|
@@ -3,7 +3,6 @@ import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
|
3
3
|
import { Router, useLocation } from '@reach/router';
|
|
4
4
|
import 'client-styles'; // Webpack replaces this import: patternfly-docs.css.js
|
|
5
5
|
import { SideNavLayout } from '@patternfly/documentation-framework/layouts';
|
|
6
|
-
import { Footer } from '@patternfly/documentation-framework/components';
|
|
7
6
|
import { MDXTemplate } from '@patternfly/documentation-framework/templates/mdx';
|
|
8
7
|
import { routes, groupedRoutes, fullscreenRoutes, getAsyncComponent } from './routes';
|
|
9
8
|
import { trackEvent } from './helpers';
|
|
@@ -12,7 +11,6 @@ import './components/cssVariables/cssVariables.css';
|
|
|
12
11
|
import './components/tableOfContents/tableOfContents.css';
|
|
13
12
|
import './components/example/example.css';
|
|
14
13
|
import './components/footer/footer.css';
|
|
15
|
-
import './components/sideNav/sideNav.css';
|
|
16
14
|
import './layouts/sideNavLayout/sideNavLayout.css';
|
|
17
15
|
|
|
18
16
|
const AppRoute = ({ child, title, path }) => {
|
|
@@ -37,16 +35,15 @@ const AppRoute = ({ child, title, path }) => {
|
|
|
37
35
|
return (
|
|
38
36
|
<React.Fragment>
|
|
39
37
|
{child}
|
|
40
|
-
{process.env.hasFooter && <Footer />}
|
|
41
38
|
</React.Fragment>
|
|
42
39
|
);
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
const SideNavRouter = () => {
|
|
46
|
-
const componentsData = process
|
|
43
|
+
const componentsData = process.env.componentsData;
|
|
47
44
|
return (
|
|
48
45
|
<SideNavLayout groupedRoutes={groupedRoutes} navOpen={true} >
|
|
49
|
-
<Router id="ws-page-content-router">
|
|
46
|
+
<Router id="ws-page-content-router" component="main">
|
|
50
47
|
{Object.entries(routes)
|
|
51
48
|
.map(([path, { Component, title, sources, id }]) => Component
|
|
52
49
|
? <AppRoute
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
.ws-heading-anchor {
|
|
6
|
-
color: var(--pf-
|
|
7
|
-
transform: translate(calc(-100% - var(--pf-
|
|
6
|
+
color: var(--pf-t--global--icon--color--regular);
|
|
7
|
+
transform: translate(calc(-100% - var(--pf-t--global--spacer--xs)), -50%);
|
|
8
8
|
opacity: 0;
|
|
9
9
|
position: absolute;
|
|
10
10
|
left: 0;
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Flex, FlexItem, Content } from '@patternfly/react-core';
|
|
3
3
|
import LinkIcon from '@patternfly/react-icons/dist/esm/icons/link-icon';
|
|
4
4
|
import { Link } from '../link/link';
|
|
5
5
|
import { slugger } from '../../helpers/slugger';
|
|
6
|
-
|
|
7
|
-
// "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl"
|
|
8
|
-
const sizes = {
|
|
9
|
-
h1: '3xl',
|
|
10
|
-
h2: '2xl',
|
|
11
|
-
h3: 'xl',
|
|
12
|
-
h4: 'lg',
|
|
13
|
-
h5: 'md',
|
|
14
|
-
h6: 'sm'
|
|
15
|
-
}
|
|
6
|
+
import { css } from '@patternfly/react-styles';
|
|
16
7
|
|
|
17
8
|
export const AutoLinkHeader = ({
|
|
18
9
|
id,
|
|
19
|
-
size,
|
|
20
10
|
headingLevel,
|
|
21
11
|
children,
|
|
22
12
|
metaText,
|
|
@@ -25,22 +15,21 @@ export const AutoLinkHeader = ({
|
|
|
25
15
|
const slug = id || slugger(children);
|
|
26
16
|
|
|
27
17
|
return (
|
|
28
|
-
<Flex alignItems={{ default: 'alignItemsCenter'}} spaceItems={{ default:
|
|
18
|
+
<Flex alignItems={{ default: 'alignItemsCenter'}} spaceItems={{ default: "spaceItemsSm" }}>
|
|
29
19
|
<FlexItem>
|
|
30
|
-
<
|
|
20
|
+
<Content
|
|
31
21
|
id={slug}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
className={`ws-heading ${className}`}
|
|
22
|
+
component={headingLevel}
|
|
23
|
+
className={css('ws-heading', className)}
|
|
35
24
|
tabIndex={-1}
|
|
36
25
|
>
|
|
37
26
|
<Link href={`#${slug}`} className="ws-heading-anchor" tabIndex="-1" aria-hidden>
|
|
38
27
|
<LinkIcon className="ws-heading-anchor-icon" style={{ verticalAlign: 'middle' }} />
|
|
39
28
|
</Link>
|
|
40
29
|
{children}
|
|
41
|
-
</
|
|
30
|
+
</Content>
|
|
42
31
|
</FlexItem>
|
|
43
|
-
<FlexItem>
|
|
32
|
+
{metaText && <FlexItem>{metaText}</FlexItem>}
|
|
44
33
|
</Flex>
|
|
45
34
|
)
|
|
46
35
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
.ws-color-box {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
height: 18px;
|
|
4
|
-
width: 18px;
|
|
5
|
-
border: var(--pf-v5-global--BorderWidth--sm) solid var(--pf-v5-global--BorderColor--200);
|
|
6
|
-
border-radius: var(--pf-v5-global--BorderRadius--lg);
|
|
7
|
-
}
|
|
8
1
|
|
|
9
|
-
.
|
|
10
|
-
|
|
2
|
+
.circle {
|
|
3
|
+
height: 1em;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
aspect-ratio: 1 / 1;
|
|
6
|
+
border-radius: 50%;
|
|
7
|
+
border: var(--pf-t--global--border--width--regular) solid var(--pf-t--global--background--color--inverse--default);
|
|
8
|
+
box-shadow: var(--pf-t--global--box-shadow--sm);
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
.
|
|
14
|
-
|
|
11
|
+
.rotate-90-deg {
|
|
12
|
+
transform: rotate(90deg);
|
|
15
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { debounce } from "@patternfly/react-core";
|
|
2
|
+
import { List, ListItem, debounce } from "@patternfly/react-core";
|
|
3
3
|
import {
|
|
4
4
|
Table,
|
|
5
5
|
Thead,
|
|
@@ -10,33 +10,22 @@ import {
|
|
|
10
10
|
} from "@patternfly/react-table";
|
|
11
11
|
import { AutoLinkHeader } from "../autoLinkHeader/autoLinkHeader";
|
|
12
12
|
import * as tokensModule from "@patternfly/react-tokens/dist/esm/componentIndex";
|
|
13
|
-
import global_spacer_md from "@patternfly/react-tokens/dist/esm/global_spacer_md";
|
|
14
13
|
import LevelUpAltIcon from "@patternfly/react-icons/dist/esm/icons/level-up-alt-icon";
|
|
15
14
|
import { CSSSearch } from './cssSearch';
|
|
16
15
|
|
|
17
16
|
const isColorRegex = /^(#|rgb)/;
|
|
18
17
|
|
|
19
18
|
const mappingAsList = (property, values) => (
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</div>
|
|
26
|
-
{values.map((entry, index) => (
|
|
27
|
-
<div
|
|
28
|
-
key={index}
|
|
29
|
-
style={{
|
|
30
|
-
padding: `4px 0 4px calc(${global_spacer_md.value} * ${index + 3})`
|
|
31
|
-
}}
|
|
19
|
+
<List isPlain>
|
|
20
|
+
<ListItem>{property}</ListItem>
|
|
21
|
+
{values.map((entry) => (
|
|
22
|
+
<ListItem
|
|
23
|
+
icon={<LevelUpAltIcon className="rotate-90-deg" />}
|
|
32
24
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{entry}
|
|
36
|
-
</span>
|
|
37
|
-
</div>
|
|
25
|
+
{entry}
|
|
26
|
+
</ListItem>
|
|
38
27
|
))}
|
|
39
|
-
</
|
|
28
|
+
</List>
|
|
40
29
|
);
|
|
41
30
|
|
|
42
31
|
const flattenList = files => {
|
|
@@ -62,7 +51,7 @@ const flattenList = files => {
|
|
|
62
51
|
export class CSSVariables extends React.Component {
|
|
63
52
|
constructor(props) {
|
|
64
53
|
super(props);
|
|
65
|
-
const prefixToken = props.prefix.replace("pf-
|
|
54
|
+
const prefixToken = props.prefix.replace("pf-v6-", "").replace(/-+/g, "_");
|
|
66
55
|
const applicableFiles = Object.entries(tokensModule)
|
|
67
56
|
.filter(([key, val]) => prefixToken === key)
|
|
68
57
|
.sort(([key1], [key2]) => key1.localeCompare(key2))
|
|
@@ -97,30 +86,28 @@ export class CSSVariables extends React.Component {
|
|
|
97
86
|
(values && searchRE.test(JSON.stringify(values)));
|
|
98
87
|
if (passes) {
|
|
99
88
|
const rowKey = `${selector}_${property}`;
|
|
89
|
+
const isColor = isColorRegex.test(value);
|
|
100
90
|
const cells = [
|
|
101
91
|
...this.props.hideSelectorColumn ? [] : [selector],
|
|
102
92
|
property,
|
|
103
93
|
<div key={rowKey}>
|
|
104
94
|
<div
|
|
105
95
|
key={`${rowKey}_1`}
|
|
106
|
-
className="pf-
|
|
96
|
+
className="pf-v6-l-flex pf-m-space-items-sm"
|
|
107
97
|
>
|
|
108
|
-
{
|
|
98
|
+
{isColor && (
|
|
109
99
|
<div
|
|
110
100
|
key={`${rowKey}_2`}
|
|
111
|
-
className="pf-
|
|
101
|
+
className="pf-v6-l-flex pf-m-column pf-m-align-self-center"
|
|
112
102
|
>
|
|
113
|
-
<span
|
|
114
|
-
className="ws-color-box"
|
|
115
|
-
style={{ backgroundColor: value }}
|
|
116
|
-
/>
|
|
103
|
+
<span className="circle" style={{ backgroundColor: `var(${property})`}}/>
|
|
117
104
|
</div>
|
|
118
105
|
)}
|
|
119
106
|
<div
|
|
120
107
|
key={`${rowKey}_3`}
|
|
121
|
-
className="pf-
|
|
108
|
+
className="pf-v6-l-flex pf-m-column pf-m-align-self-center ws-td-text"
|
|
122
109
|
>
|
|
123
|
-
{value}
|
|
110
|
+
{isColor && '(In light theme)'} {value}
|
|
124
111
|
</div>
|
|
125
112
|
</div>
|
|
126
113
|
</div>
|
|
@@ -170,7 +157,7 @@ export class CSSVariables extends React.Component {
|
|
|
170
157
|
render() {
|
|
171
158
|
return (
|
|
172
159
|
<React.Fragment>
|
|
173
|
-
{this.props.autoLinkHeader && <AutoLinkHeader
|
|
160
|
+
{this.props.autoLinkHeader && <AutoLinkHeader headingLevel="h3" className="pf-v6-u-mt-lg pf-v6-u-mb-md">{`Prefixed with '${this.props.prefix}'`}</AutoLinkHeader>}
|
|
174
161
|
<CSSSearch getDebouncedFilteredRows={this.getDebouncedFilteredRows} />
|
|
175
162
|
<Table
|
|
176
163
|
variant="compact"
|
|
@@ -180,7 +167,7 @@ export class CSSVariables extends React.Component {
|
|
|
180
167
|
<Tr>
|
|
181
168
|
{!this.props.hideSelectorColumn && (
|
|
182
169
|
<React.Fragment>
|
|
183
|
-
<Th />
|
|
170
|
+
<Th screenReaderText="Expand or collapse column" />
|
|
184
171
|
<Th>Selector</Th>
|
|
185
172
|
</React.Fragment>
|
|
186
173
|
)}
|
|
@@ -2,53 +2,19 @@
|
|
|
2
2
|
--ws-code-editor--tooltip--MaxWidth: 16ch;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.ws-example {
|
|
6
|
-
|
|
7
|
-
margin-bottom: var(--pf-v5-global--spacer--lg);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.ws-example > .ws-example-header {
|
|
11
|
-
padding: var(--pf-v5-global--spacer--md);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.ws-example-header > .ws-example-heading:not(:last-child) {
|
|
15
|
-
margin-bottom: var(--pf-v5-global--spacer--md);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.ws-code-editor:not(.ws-example-code-expanded) > .pf-v5-c-code-editor__header::before {
|
|
19
|
-
--pf-v5-c-code-editor__header--before--BorderBottomWidth: 0;
|
|
5
|
+
.ws-code-editor:not(.ws-example-code-expanded) > .pf-v6-c-code-editor__header::before {
|
|
6
|
+
--pf-v6-c-code-editor__header--before--BorderBottomWidth: 0;
|
|
20
7
|
}
|
|
21
8
|
|
|
22
9
|
.ws-code-editor-control {
|
|
23
|
-
--pf-
|
|
24
|
-
--pf-
|
|
25
|
-
--pf-
|
|
26
|
-
--pf-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.ws-code-editor-control.pf-v5-c-button {
|
|
30
|
-
--pf-v5-c-button--after--BorderWidth: 0;
|
|
10
|
+
--pf-v6-c-button--m-control--BackgroundColor: transparent;
|
|
11
|
+
--pf-v6-c-button--m-control--active--BackgroundColor: transparent;
|
|
12
|
+
--pf-v6-c-button--m-control--focus--BackgroundColor: transparent;
|
|
13
|
+
--pf-v6-c-button--m-control--hover--BackgroundColor: transparent;
|
|
31
14
|
}
|
|
32
15
|
|
|
33
|
-
.ws-
|
|
34
|
-
|
|
35
|
-
background-color: var(--pf-v5-global--BackgroundColor--100);
|
|
36
|
-
border-bottom: var(--pf-v5-global--BorderWidth--sm) solid var(--pf-v5-global--BorderColor--300);
|
|
37
|
-
transition: width .2s ease-in-out;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.ws-core-c-page.ws-preview > .ws-preview-html,
|
|
41
|
-
.ws-react-c-page.ws-preview > .pf-v5-c-page {
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.ws-editor {
|
|
46
|
-
font-size: var(--pf-v5-global--FontSize--md);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.ws-editor .token.punctuation,
|
|
50
|
-
.ws-editor .token.operator {
|
|
51
|
-
color: var(--pf-v5-global--danger-color--100);
|
|
16
|
+
.ws-code-editor-control.pf-v6-c-button {
|
|
17
|
+
--pf-v6-c-button--after--BorderWidth: 0;
|
|
52
18
|
}
|
|
53
19
|
|
|
54
20
|
.ws-preview__thumbnail-link {
|
|
@@ -61,7 +27,7 @@
|
|
|
61
27
|
.ws-preview__thumbnail-link::before,
|
|
62
28
|
.ws-preview__thumbnail-link::after {
|
|
63
29
|
position: absolute;
|
|
64
|
-
z-index:
|
|
30
|
+
z-index: var(--pf-t--global--z-index--sm);
|
|
65
31
|
transition: .2s;
|
|
66
32
|
opacity: 0;
|
|
67
33
|
}
|
|
@@ -100,33 +66,23 @@
|
|
|
100
66
|
color: rgba(255,255,255,.4);
|
|
101
67
|
}
|
|
102
68
|
|
|
103
|
-
.pf-v5-c-badge.ws-beta-badge {
|
|
104
|
-
--pf-v5-c-badge--m-unread--BackgroundColor: var(--pf-v5-global--BackgroundColor--100);
|
|
105
|
-
--pf-v5-c-badge--m-unread--Color: var(--pf-v5-global--primary-color--100);
|
|
106
|
-
border: var(--pf-v5-global--BorderWidth--sm) solid var(--pf-v5-global--primary-color--100);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
69
|
.ws-prop-required {
|
|
110
|
-
color: var(--pf-
|
|
70
|
+
color: var(--pf-t--global--text--color--status--danger--default);
|
|
111
71
|
}
|
|
112
72
|
|
|
113
73
|
.ws-full-page-utils {
|
|
114
74
|
position: fixed;
|
|
115
75
|
right: 0;
|
|
116
76
|
bottom: 0;
|
|
117
|
-
padding: var(--pf-
|
|
118
|
-
z-index: var(--pf-
|
|
77
|
+
padding: var(--pf-t--global--spacer--lg);
|
|
78
|
+
z-index: var(--pf-t--global--z-index--2xl);
|
|
119
79
|
}
|
|
120
80
|
|
|
121
81
|
.ws-full-page-utils::before {
|
|
122
82
|
position: absolute;
|
|
123
83
|
inset: 0;
|
|
124
84
|
content: "";
|
|
125
|
-
background-color: var(--pf-
|
|
85
|
+
background-color: var(--pf-t--global--background--color--floating--default);
|
|
126
86
|
opacity: 0.8;
|
|
127
|
-
box-shadow: var(--pf-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.pf-v5-theme-dark .ws-theme-switch-full-page::before {
|
|
131
|
-
background-color: var(--pf-v5-global--BackgroundColor--300);
|
|
87
|
+
box-shadow: var(--pf-t--global--box-shadow--sm);
|
|
132
88
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
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
|
+
Stack,
|
|
13
|
+
StackItem
|
|
14
|
+
} from '@patternfly/react-core';
|
|
4
15
|
import * as reactCoreModule from '@patternfly/react-core';
|
|
5
16
|
import * as reactCoreNextModule from '@patternfly/react-core/next';
|
|
6
17
|
import * as reactCoreDeprecatedModule from '@patternfly/react-core/deprecated';
|
|
@@ -16,13 +27,13 @@ import {
|
|
|
16
27
|
getReactParams,
|
|
17
28
|
getExampleClassName,
|
|
18
29
|
getExampleId,
|
|
19
|
-
liveCodeTypes
|
|
30
|
+
liveCodeTypes,
|
|
20
31
|
} from '../../helpers';
|
|
21
32
|
import { convertToReactComponent } from '@patternfly/ast-helpers';
|
|
22
33
|
import missingThumbnail from './missing-thumbnail.jpg';
|
|
23
34
|
import { RtlContext } from '../../layouts';
|
|
24
35
|
|
|
25
|
-
const errorComponent = err => <pre>{err.toString()}</pre>;
|
|
36
|
+
const errorComponent = (err) => <pre>{err.toString()}</pre>;
|
|
26
37
|
|
|
27
38
|
class ErrorBoundary extends React.Component {
|
|
28
39
|
constructor(props) {
|
|
@@ -34,7 +45,7 @@ class ErrorBoundary extends React.Component {
|
|
|
34
45
|
errorInfo._suppressLogging = true;
|
|
35
46
|
this.setState({
|
|
36
47
|
error: error,
|
|
37
|
-
errorInfo: errorInfo
|
|
48
|
+
errorInfo: errorInfo,
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
|
|
@@ -94,15 +105,24 @@ export const Example = ({
|
|
|
94
105
|
// md file location in node_modules, used to resolve relative import paths in examples
|
|
95
106
|
relPath = '',
|
|
96
107
|
// absolute url to hosted file
|
|
97
|
-
sourceLink = ''
|
|
108
|
+
sourceLink = '',
|
|
98
109
|
}) => {
|
|
99
110
|
if (isFullscreenPreview) {
|
|
100
111
|
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
112
|
}
|
|
113
|
+
|
|
114
|
+
//append a class to the document body on fullscreen examples to indicate to screenshot/automated visual regression tools that the page has loaded
|
|
115
|
+
const addPageLoadedClass = () => document.body.classList.add('page-loaded');
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!isFullscreenPreview) return;
|
|
118
|
+
|
|
119
|
+
document.readyState === 'complete'
|
|
120
|
+
? addPageLoadedClass()
|
|
121
|
+
: window.addEventListener('load', addPageLoadedClass);
|
|
122
|
+
|
|
123
|
+
return () => window.removeEventListener('load', addPageLoadedClass);
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
106
126
|
if (!lang) {
|
|
107
127
|
// Inline code
|
|
108
128
|
return <code className="ws-code">{code}</code>;
|
|
@@ -124,20 +144,26 @@ export const Example = ({
|
|
|
124
144
|
...reactCoreModule,
|
|
125
145
|
...reactTableModule,
|
|
126
146
|
...(source === 'react-next' ? reactCoreNextModule : {}),
|
|
127
|
-
...(source === 'react-deprecated'
|
|
147
|
+
...(source === 'react-deprecated'
|
|
148
|
+
? { ...reactCoreDeprecatedModule, ...reactTableDeprecatedModule }
|
|
149
|
+
: {}),
|
|
128
150
|
};
|
|
129
151
|
|
|
130
152
|
let livePreview = null;
|
|
131
153
|
if (lang === 'html') {
|
|
132
154
|
livePreview = (
|
|
133
155
|
<div
|
|
134
|
-
className={css(
|
|
156
|
+
className={css(
|
|
157
|
+
'ws-preview-html', // core uses this class name to apply styles to specific examples
|
|
158
|
+
isFullscreenPreview && 'pf-v6-u-h-100'
|
|
159
|
+
)}
|
|
135
160
|
dangerouslySetInnerHTML={{ __html: editorCode }}
|
|
136
161
|
/>
|
|
137
162
|
);
|
|
138
163
|
} else {
|
|
139
164
|
try {
|
|
140
|
-
const { code: transformedCode, hasTS } =
|
|
165
|
+
const { code: transformedCode, hasTS } =
|
|
166
|
+
convertToReactComponent(editorCode);
|
|
141
167
|
if (hasTS) {
|
|
142
168
|
lang = 'ts';
|
|
143
169
|
} else {
|
|
@@ -147,7 +173,11 @@ export const Example = ({
|
|
|
147
173
|
const componentNames = Object.keys(scope);
|
|
148
174
|
const componentValues = Object.values(scope);
|
|
149
175
|
|
|
150
|
-
const getPreviewComponent = new Function(
|
|
176
|
+
const getPreviewComponent = new Function(
|
|
177
|
+
'React',
|
|
178
|
+
...componentNames,
|
|
179
|
+
transformedCode
|
|
180
|
+
);
|
|
151
181
|
const PreviewComponent = getPreviewComponent(React, ...componentValues);
|
|
152
182
|
|
|
153
183
|
livePreview = (
|
|
@@ -164,20 +194,37 @@ export const Example = ({
|
|
|
164
194
|
|
|
165
195
|
if (isFullscreenPreview) {
|
|
166
196
|
return (
|
|
167
|
-
<div id={previewId} className={css(className, 'pf-
|
|
197
|
+
<div id={previewId} className={css(className, 'pf-v6-u-h-100')}>
|
|
168
198
|
{livePreview}
|
|
169
199
|
{(hasDarkThemeSwitcher || hasRTLSwitcher) && (
|
|
170
|
-
<Flex
|
|
200
|
+
<Flex
|
|
201
|
+
direction={{ default: 'column' }}
|
|
202
|
+
gap={{ default: 'gapLg' }}
|
|
203
|
+
className="ws-full-page-utils pf-v6-m-dir-ltr "
|
|
204
|
+
>
|
|
171
205
|
{hasDarkThemeSwitcher && (
|
|
172
|
-
<Switch
|
|
173
|
-
|
|
206
|
+
<Switch
|
|
207
|
+
id="ws-example-theme-switch"
|
|
208
|
+
label="Dark theme"
|
|
209
|
+
defaultChecked={false}
|
|
210
|
+
onChange={() =>
|
|
211
|
+
document
|
|
212
|
+
.querySelector('html')
|
|
213
|
+
.classList.toggle('pf-v6-theme-dark')
|
|
214
|
+
}
|
|
215
|
+
/>
|
|
174
216
|
)}
|
|
175
217
|
{hasRTLSwitcher && (
|
|
176
|
-
<Switch
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
218
|
+
<Switch
|
|
219
|
+
id="ws-example-rtl-switch"
|
|
220
|
+
label="RTL"
|
|
221
|
+
defaultChecked={false}
|
|
222
|
+
onChange={() => {
|
|
223
|
+
const html = document.querySelector('html');
|
|
224
|
+
const curDir = html.dir;
|
|
225
|
+
html.dir = curDir !== 'rtl' ? 'rtl' : 'ltr';
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
181
228
|
)}
|
|
182
229
|
</Flex>
|
|
183
230
|
)}
|
|
@@ -188,82 +235,106 @@ export const Example = ({
|
|
|
188
235
|
const codeBoxParams = getParameters(
|
|
189
236
|
lang === 'html'
|
|
190
237
|
? getStaticParams(title, editorCode)
|
|
191
|
-
: getReactParams(
|
|
238
|
+
: getReactParams(
|
|
239
|
+
title,
|
|
240
|
+
editorCode,
|
|
241
|
+
scope,
|
|
242
|
+
lang,
|
|
243
|
+
relativeImports,
|
|
244
|
+
relPath,
|
|
245
|
+
sourceLink
|
|
246
|
+
)
|
|
192
247
|
);
|
|
193
|
-
const fullscreenLink =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
+
|
|
248
|
+
const fullscreenLink =
|
|
249
|
+
loc.pathname.replace(/\/$/, '') +
|
|
250
|
+
(loc.pathname.endsWith(source) ? '' : `/${source}`) +
|
|
251
|
+
'/' +
|
|
252
|
+
slugger(title);
|
|
253
|
+
|
|
254
|
+
const hasMetaText = isBeta || isDemo || isDeprecated || false;
|
|
255
|
+
const tooltips = (<React.Fragment>
|
|
256
|
+
{isBeta && (
|
|
257
|
+
<Tooltip content="This beta component is currently under review and is still open for further evolution.">
|
|
258
|
+
<Button variant="plain" hasNoPadding>
|
|
259
|
+
<Label isCompact color="blue">
|
|
260
|
+
Beta
|
|
261
|
+
</Label>
|
|
262
|
+
</Button>
|
|
263
|
+
</Tooltip>
|
|
264
|
+
)}
|
|
265
|
+
{isDemo && (
|
|
266
|
+
<Tooltip content="Demos show how multiple components can be used in a single design.">
|
|
267
|
+
<Button variant="plain" hasNoPadding>
|
|
268
|
+
<Label isCompact color="purple">
|
|
269
|
+
Demo
|
|
270
|
+
</Label>
|
|
271
|
+
</Button>
|
|
272
|
+
</Tooltip>
|
|
273
|
+
)}
|
|
274
|
+
{isDeprecated && (
|
|
275
|
+
<Tooltip content="Deprecated components are available for use but are no longer being maintained or enhanced.">
|
|
276
|
+
<Button variant="plain" hasNoPadding>
|
|
277
|
+
<Label isCompact color="grey">
|
|
278
|
+
Deprecated
|
|
279
|
+
</Label>
|
|
280
|
+
</Button>
|
|
281
|
+
</Tooltip>
|
|
282
|
+
)}
|
|
283
|
+
</React.Fragment>);
|
|
284
|
+
const metaText = hasMetaText && tooltips
|
|
197
285
|
|
|
198
286
|
return (
|
|
199
|
-
<
|
|
200
|
-
<
|
|
287
|
+
<Stack hasGutter>
|
|
288
|
+
<StackItem>
|
|
201
289
|
<AutoLinkHeader
|
|
202
|
-
metaText={
|
|
203
|
-
<React.Fragment>
|
|
204
|
-
{isBeta && (
|
|
205
|
-
<Tooltip content="This beta component is currently under review and is still open for further evolution.">
|
|
206
|
-
<Button variant="plain">
|
|
207
|
-
<Label isCompact color="blue">Beta</Label>
|
|
208
|
-
</Button>
|
|
209
|
-
</Tooltip>
|
|
210
|
-
)}
|
|
211
|
-
{isDemo && (
|
|
212
|
-
<Tooltip content="Demos show how multiple components can be used in a single design.">
|
|
213
|
-
<Button variant="plain">
|
|
214
|
-
<Label isCompact color="purple">Demo</Label>
|
|
215
|
-
</Button>
|
|
216
|
-
</Tooltip>
|
|
217
|
-
)}
|
|
218
|
-
{isDeprecated && (
|
|
219
|
-
<Tooltip content="Deprecated components are available for use but are no longer being maintained or enhanced.">
|
|
220
|
-
<Button variant="plain">
|
|
221
|
-
<Label isCompact color="grey">Deprecated</Label>
|
|
222
|
-
</Button>
|
|
223
|
-
</Tooltip>
|
|
224
|
-
)}
|
|
225
|
-
</React.Fragment>
|
|
226
|
-
}
|
|
227
|
-
size="h4"
|
|
290
|
+
metaText={metaText}
|
|
228
291
|
headingLevel="h3"
|
|
229
|
-
className="ws-example-heading"
|
|
230
292
|
>
|
|
231
293
|
{title}
|
|
232
294
|
</AutoLinkHeader>
|
|
233
295
|
{children}
|
|
234
|
-
</
|
|
235
|
-
|
|
236
|
-
?
|
|
296
|
+
</StackItem>
|
|
297
|
+
<StackItem>
|
|
298
|
+
{isFullscreen ? (
|
|
299
|
+
<div>
|
|
237
300
|
<a
|
|
238
301
|
className="ws-preview__thumbnail-link"
|
|
239
302
|
href={fullscreenLink}
|
|
240
303
|
target="_blank"
|
|
241
304
|
aria-label={`Open fullscreen ${title} example`}
|
|
242
305
|
>
|
|
243
|
-
<img
|
|
306
|
+
<img
|
|
307
|
+
src={thumbnail.src}
|
|
308
|
+
width={thumbnail.width}
|
|
309
|
+
height={thumbnail.height}
|
|
310
|
+
alt={`${title} screenshot`}
|
|
311
|
+
/>
|
|
244
312
|
</a>
|
|
245
313
|
</div>
|
|
246
|
-
:
|
|
314
|
+
) : (
|
|
315
|
+
<div
|
|
247
316
|
id={previewId}
|
|
248
317
|
className={css(
|
|
249
318
|
className,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
319
|
+
isRTL && 'pf-v6-m-dir-rtl'
|
|
320
|
+
)}
|
|
253
321
|
>
|
|
254
322
|
{livePreview}
|
|
255
323
|
</div>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
324
|
+
)}
|
|
325
|
+
</StackItem>
|
|
326
|
+
<StackItem>
|
|
327
|
+
<ExampleToolbar
|
|
328
|
+
lang={lang}
|
|
329
|
+
isFullscreen={isFullscreen}
|
|
330
|
+
fullscreenLink={fullscreenLink}
|
|
331
|
+
originalCode={code}
|
|
332
|
+
code={editorCode}
|
|
333
|
+
setCode={debounce(setEditorCode, 300)}
|
|
334
|
+
codeBoxParams={codeBoxParams}
|
|
335
|
+
exampleTitle={title}
|
|
336
|
+
/>
|
|
337
|
+
</StackItem>
|
|
338
|
+
</Stack>
|
|
268
339
|
);
|
|
269
|
-
}
|
|
340
|
+
};
|