@patternfly/documentation-framework 6.0.0-alpha.5 → 6.0.0-alpha.50
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 +893 -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 +4 -4
- package/components/cssVariables/cssVariables.js +6 -6
- package/components/example/example.css +13 -57
- package/components/example/example.js +148 -78
- package/components/example/exampleToolbar.js +3 -2
- package/components/footer/footer.css +16 -16
- package/components/footer/footer.js +29 -29
- package/components/gdprBanner/gdprBanner.css +0 -3
- package/components/gdprBanner/gdprBanner.js +24 -17
- package/components/inlineAlert/inlineAlert.js +1 -1
- package/components/propsTable/propsTable.js +14 -10
- package/components/sectionGallery/sectionDataListLayout.js +3 -3
- package/components/sectionGallery/sectionGallery.css +12 -12
- package/components/sectionGallery/sectionGalleryToolbar.js +1 -1
- package/components/sideNav/sideNav.js +3 -4
- package/components/tableOfContents/tableOfContents.css +23 -24
- package/layouts/sideNavLayout/sideNavLayout.css +14 -14
- package/layouts/sideNavLayout/sideNavLayout.js +58 -33
- package/package.json +13 -20
- package/pages/404/404.css +2 -2
- package/pages/404/index.js +5 -8
- 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 +28 -229
- package/templates/mdx.js +37 -40
- package/templates/patternfly-docs/patternfly-docs.source.js +8 -8
- package/versions.json +39 -12
- 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, Text } 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
|
+
<Text
|
|
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
|
+
</Text>
|
|
42
31
|
</FlexItem>
|
|
43
|
-
<FlexItem>
|
|
32
|
+
{metaText && <FlexItem>{metaText}</FlexItem>}
|
|
44
33
|
</Flex>
|
|
45
34
|
)
|
|
46
35
|
};
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
display: inline-block;
|
|
3
3
|
height: 18px;
|
|
4
4
|
width: 18px;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/* border: var(--pf-v6-global--BorderWidth--sm) solid var(--pf-v6-global--BorderColor--200); */
|
|
6
|
+
/* border-radius: var(--pf-v6-global--BorderRadius--lg); */
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.ws-td-text {
|
|
10
|
-
|
|
10
|
+
/* font-size: var(--pf-v6-global--FontSize--sm) !important; */
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.ws-css-property {
|
|
14
|
-
padding: var(--pf-
|
|
14
|
+
padding: var(--pf-t--global--spacer--xs) var(--pf-t--global--spacer--md);
|
|
15
15
|
}
|
|
@@ -62,7 +62,7 @@ const flattenList = files => {
|
|
|
62
62
|
export class CSSVariables extends React.Component {
|
|
63
63
|
constructor(props) {
|
|
64
64
|
super(props);
|
|
65
|
-
const prefixToken = props.prefix.replace("pf-
|
|
65
|
+
const prefixToken = props.prefix.replace("pf-v6-", "").replace(/-+/g, "_");
|
|
66
66
|
const applicableFiles = Object.entries(tokensModule)
|
|
67
67
|
.filter(([key, val]) => prefixToken === key)
|
|
68
68
|
.sort(([key1], [key2]) => key1.localeCompare(key2))
|
|
@@ -103,12 +103,12 @@ export class CSSVariables extends React.Component {
|
|
|
103
103
|
<div key={rowKey}>
|
|
104
104
|
<div
|
|
105
105
|
key={`${rowKey}_1`}
|
|
106
|
-
className="pf-
|
|
106
|
+
className="pf-v6-l-flex pf-m-space-items-sm"
|
|
107
107
|
>
|
|
108
108
|
{isColorRegex.test(value) && (
|
|
109
109
|
<div
|
|
110
110
|
key={`${rowKey}_2`}
|
|
111
|
-
className="pf-
|
|
111
|
+
className="pf-v6-l-flex pf-m-column pf-m-align-self-center"
|
|
112
112
|
>
|
|
113
113
|
<span
|
|
114
114
|
className="ws-color-box"
|
|
@@ -118,7 +118,7 @@ export class CSSVariables extends React.Component {
|
|
|
118
118
|
)}
|
|
119
119
|
<div
|
|
120
120
|
key={`${rowKey}_3`}
|
|
121
|
-
className="pf-
|
|
121
|
+
className="pf-v6-l-flex pf-m-column pf-m-align-self-center ws-td-text"
|
|
122
122
|
>
|
|
123
123
|
{value}
|
|
124
124
|
</div>
|
|
@@ -170,7 +170,7 @@ export class CSSVariables extends React.Component {
|
|
|
170
170
|
render() {
|
|
171
171
|
return (
|
|
172
172
|
<React.Fragment>
|
|
173
|
-
{this.props.autoLinkHeader && <AutoLinkHeader
|
|
173
|
+
{this.props.autoLinkHeader && <AutoLinkHeader headingLevel="h3" className="pf-v6-u-mt-lg pf-v6-u-mb-md">{`Prefixed with '${this.props.prefix}'`}</AutoLinkHeader>}
|
|
174
174
|
<CSSSearch getDebouncedFilteredRows={this.getDebouncedFilteredRows} />
|
|
175
175
|
<Table
|
|
176
176
|
variant="compact"
|
|
@@ -180,7 +180,7 @@ export class CSSVariables extends React.Component {
|
|
|
180
180
|
<Tr>
|
|
181
181
|
{!this.props.hideSelectorColumn && (
|
|
182
182
|
<React.Fragment>
|
|
183
|
-
<Th />
|
|
183
|
+
<Th screenReaderText="Expand or collapse column" />
|
|
184
184
|
<Th>Selector</Th>
|
|
185
185
|
</React.Fragment>
|
|
186
186
|
)}
|
|
@@ -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 {
|
|
@@ -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,25 @@ 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
|
+
isFullscreenPreview && 'pf-v6-u-h-100'
|
|
158
|
+
)}
|
|
135
159
|
dangerouslySetInnerHTML={{ __html: editorCode }}
|
|
136
160
|
/>
|
|
137
161
|
);
|
|
138
162
|
} else {
|
|
139
163
|
try {
|
|
140
|
-
const { code: transformedCode, hasTS } =
|
|
164
|
+
const { code: transformedCode, hasTS } =
|
|
165
|
+
convertToReactComponent(editorCode);
|
|
141
166
|
if (hasTS) {
|
|
142
167
|
lang = 'ts';
|
|
143
168
|
} else {
|
|
@@ -147,7 +172,11 @@ export const Example = ({
|
|
|
147
172
|
const componentNames = Object.keys(scope);
|
|
148
173
|
const componentValues = Object.values(scope);
|
|
149
174
|
|
|
150
|
-
const getPreviewComponent = new Function(
|
|
175
|
+
const getPreviewComponent = new Function(
|
|
176
|
+
'React',
|
|
177
|
+
...componentNames,
|
|
178
|
+
transformedCode
|
|
179
|
+
);
|
|
151
180
|
const PreviewComponent = getPreviewComponent(React, ...componentValues);
|
|
152
181
|
|
|
153
182
|
livePreview = (
|
|
@@ -164,20 +193,37 @@ export const Example = ({
|
|
|
164
193
|
|
|
165
194
|
if (isFullscreenPreview) {
|
|
166
195
|
return (
|
|
167
|
-
<div id={previewId} className={css(className, 'pf-
|
|
196
|
+
<div id={previewId} className={css(className, 'pf-v6-u-h-100')}>
|
|
168
197
|
{livePreview}
|
|
169
198
|
{(hasDarkThemeSwitcher || hasRTLSwitcher) && (
|
|
170
|
-
<Flex
|
|
199
|
+
<Flex
|
|
200
|
+
direction={{ default: 'column' }}
|
|
201
|
+
gap={{ default: 'gapLg' }}
|
|
202
|
+
className="ws-full-page-utils pf-v6-m-dir-ltr "
|
|
203
|
+
>
|
|
171
204
|
{hasDarkThemeSwitcher && (
|
|
172
|
-
<Switch
|
|
173
|
-
|
|
205
|
+
<Switch
|
|
206
|
+
id="ws-example-theme-switch"
|
|
207
|
+
label="Dark theme"
|
|
208
|
+
defaultChecked={false}
|
|
209
|
+
onChange={() =>
|
|
210
|
+
document
|
|
211
|
+
.querySelector('html')
|
|
212
|
+
.classList.toggle('pf-v6-theme-dark')
|
|
213
|
+
}
|
|
214
|
+
/>
|
|
174
215
|
)}
|
|
175
216
|
{hasRTLSwitcher && (
|
|
176
|
-
<Switch
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
217
|
+
<Switch
|
|
218
|
+
id="ws-example-rtl-switch"
|
|
219
|
+
label="RTL"
|
|
220
|
+
defaultChecked={false}
|
|
221
|
+
onChange={() => {
|
|
222
|
+
const html = document.querySelector('html');
|
|
223
|
+
const curDir = html.dir;
|
|
224
|
+
html.dir = curDir !== 'rtl' ? 'rtl' : 'ltr';
|
|
225
|
+
}}
|
|
226
|
+
/>
|
|
181
227
|
)}
|
|
182
228
|
</Flex>
|
|
183
229
|
)}
|
|
@@ -188,82 +234,106 @@ export const Example = ({
|
|
|
188
234
|
const codeBoxParams = getParameters(
|
|
189
235
|
lang === 'html'
|
|
190
236
|
? getStaticParams(title, editorCode)
|
|
191
|
-
: getReactParams(
|
|
237
|
+
: getReactParams(
|
|
238
|
+
title,
|
|
239
|
+
editorCode,
|
|
240
|
+
scope,
|
|
241
|
+
lang,
|
|
242
|
+
relativeImports,
|
|
243
|
+
relPath,
|
|
244
|
+
sourceLink
|
|
245
|
+
)
|
|
192
246
|
);
|
|
193
|
-
const fullscreenLink =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
+
|
|
247
|
+
const fullscreenLink =
|
|
248
|
+
loc.pathname.replace(/\/$/, '') +
|
|
249
|
+
(loc.pathname.endsWith(source) ? '' : `/${source}`) +
|
|
250
|
+
'/' +
|
|
251
|
+
slugger(title);
|
|
252
|
+
|
|
253
|
+
const hasMetaText = isBeta || isDemo || isDeprecated || false;
|
|
254
|
+
const tooltips = (<React.Fragment>
|
|
255
|
+
{isBeta && (
|
|
256
|
+
<Tooltip content="This beta component is currently under review and is still open for further evolution.">
|
|
257
|
+
<Button variant="plain" hasNoPadding>
|
|
258
|
+
<Label isCompact color="blue">
|
|
259
|
+
Beta
|
|
260
|
+
</Label>
|
|
261
|
+
</Button>
|
|
262
|
+
</Tooltip>
|
|
263
|
+
)}
|
|
264
|
+
{isDemo && (
|
|
265
|
+
<Tooltip content="Demos show how multiple components can be used in a single design.">
|
|
266
|
+
<Button variant="plain" hasNoPadding>
|
|
267
|
+
<Label isCompact color="purple">
|
|
268
|
+
Demo
|
|
269
|
+
</Label>
|
|
270
|
+
</Button>
|
|
271
|
+
</Tooltip>
|
|
272
|
+
)}
|
|
273
|
+
{isDeprecated && (
|
|
274
|
+
<Tooltip content="Deprecated components are available for use but are no longer being maintained or enhanced.">
|
|
275
|
+
<Button variant="plain" hasNoPadding>
|
|
276
|
+
<Label isCompact color="grey">
|
|
277
|
+
Deprecated
|
|
278
|
+
</Label>
|
|
279
|
+
</Button>
|
|
280
|
+
</Tooltip>
|
|
281
|
+
)}
|
|
282
|
+
</React.Fragment>);
|
|
283
|
+
const metaText = hasMetaText && tooltips
|
|
197
284
|
|
|
198
285
|
return (
|
|
199
|
-
<
|
|
200
|
-
<
|
|
286
|
+
<Stack hasGutter>
|
|
287
|
+
<StackItem>
|
|
201
288
|
<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"
|
|
289
|
+
metaText={metaText}
|
|
228
290
|
headingLevel="h3"
|
|
229
|
-
className="ws-example-heading"
|
|
230
291
|
>
|
|
231
292
|
{title}
|
|
232
293
|
</AutoLinkHeader>
|
|
233
294
|
{children}
|
|
234
|
-
</
|
|
235
|
-
|
|
236
|
-
?
|
|
295
|
+
</StackItem>
|
|
296
|
+
<StackItem>
|
|
297
|
+
{isFullscreen ? (
|
|
298
|
+
<div>
|
|
237
299
|
<a
|
|
238
300
|
className="ws-preview__thumbnail-link"
|
|
239
301
|
href={fullscreenLink}
|
|
240
302
|
target="_blank"
|
|
241
303
|
aria-label={`Open fullscreen ${title} example`}
|
|
242
304
|
>
|
|
243
|
-
<img
|
|
305
|
+
<img
|
|
306
|
+
src={thumbnail.src}
|
|
307
|
+
width={thumbnail.width}
|
|
308
|
+
height={thumbnail.height}
|
|
309
|
+
alt={`${title} screenshot`}
|
|
310
|
+
/>
|
|
244
311
|
</a>
|
|
245
312
|
</div>
|
|
246
|
-
:
|
|
313
|
+
) : (
|
|
314
|
+
<div
|
|
247
315
|
id={previewId}
|
|
248
316
|
className={css(
|
|
249
317
|
className,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
318
|
+
isRTL && 'pf-v6-m-dir-rtl'
|
|
319
|
+
)}
|
|
253
320
|
>
|
|
254
321
|
{livePreview}
|
|
255
322
|
</div>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
323
|
+
)}
|
|
324
|
+
</StackItem>
|
|
325
|
+
<StackItem>
|
|
326
|
+
<ExampleToolbar
|
|
327
|
+
lang={lang}
|
|
328
|
+
isFullscreen={isFullscreen}
|
|
329
|
+
fullscreenLink={fullscreenLink}
|
|
330
|
+
originalCode={code}
|
|
331
|
+
code={editorCode}
|
|
332
|
+
setCode={debounce(setEditorCode, 300)}
|
|
333
|
+
codeBoxParams={codeBoxParams}
|
|
334
|
+
exampleTitle={title}
|
|
335
|
+
/>
|
|
336
|
+
</StackItem>
|
|
337
|
+
</Stack>
|
|
268
338
|
);
|
|
269
|
-
}
|
|
339
|
+
};
|
|
@@ -103,7 +103,7 @@ export const ExampleToolbar = ({
|
|
|
103
103
|
copyCode();
|
|
104
104
|
trackEvent('code_editor_control_click', 'click_event', 'COPY_CODE');
|
|
105
105
|
}}
|
|
106
|
-
variant="
|
|
106
|
+
variant="plain"
|
|
107
107
|
aria-label={copyAriaLabel}
|
|
108
108
|
className={editorControlProps.className}
|
|
109
109
|
>
|
|
@@ -124,7 +124,7 @@ export const ExampleToolbar = ({
|
|
|
124
124
|
>
|
|
125
125
|
<Button
|
|
126
126
|
aria-label={codesandboxAriaLabel}
|
|
127
|
-
variant="
|
|
127
|
+
variant="plain"
|
|
128
128
|
type="submit"
|
|
129
129
|
onClick={() => {
|
|
130
130
|
trackEvent('code_editor_control_click', 'click_event', 'CODESANDBOX_LINK');
|
|
@@ -218,6 +218,7 @@ export const ExampleToolbar = ({
|
|
|
218
218
|
onEditorDidMount={onEditorDidMount}
|
|
219
219
|
isReadOnly={isFullscreen}
|
|
220
220
|
className={`${isEditorOpen ? 'ws-example-code-expanded ' : ''}ws-code-editor`}
|
|
221
|
+
isHeaderPlain
|
|
221
222
|
/>
|
|
222
223
|
);
|
|
223
224
|
}
|