@patternfly/patternfly-doc-core 1.5.0 → 1.6.0
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/.astro/collections/examples.schema.json +40 -0
- package/.astro/content-modules.mjs +4 -1
- package/.astro/content.d.ts +20 -1
- package/astro.config.mjs +2 -2
- package/declarations.d.ts +2 -0
- package/dist/client/_astro/LiveExample.B7IM_dLQ.css +1 -0
- package/dist/client/_astro/LiveExample.Df-EUsee.js +40 -0
- package/dist/client/_astro/Navigation.CabjIYg4.js +1 -0
- package/dist/client/_astro/PageContext.D1pNBMhh.js +9 -0
- package/dist/client/_astro/PageSidebarBody.Y-7d6zQM.js +1 -0
- package/dist/client/_astro/PageToggle.CbfM9bJB.js +1 -0
- package/dist/client/_astro/PageToggleButton.CZ3xPbcc.js +1 -0
- package/dist/client/_astro/Toolbar.9-YSFh3P.js +1 -0
- package/dist/client/_astro/ToolbarContent.BXdFKbs9.js +1 -0
- package/dist/client/_astro/_page_.B8cBYNKa.css +1 -0
- package/dist/client/_astro/_page_.CtheD08_.css +1 -0
- package/dist/client/_astro/_tab_.DxJDkZPc.css +1 -0
- package/dist/client/_astro/_tab_.YrfmckTJ.css +1 -0
- package/dist/client/_astro/client.CTJTt880.js +1 -0
- package/dist/client/_astro/divider.DjbDHO_6.js +1 -0
- package/dist/client/_astro/index.Dhi-S4Ah.js +24 -0
- package/dist/client/_astro/index.Dkaqzkgy.js +9 -0
- package/dist/client/_astro/page.CDtWFZb5.js +1 -0
- package/dist/client/components/accordion/index.html +85 -0
- package/dist/client/design-foundations/typography/index.html +10 -8
- package/dist/client/design-foundations/usage-and-behavior/index.html +10 -8
- package/dist/client/get-started/contribute/index.html +10 -8
- package/dist/client/index.html +5 -3
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -1
- package/dist/server/chunks/{PropsTables_MQNZVYdD.mjs → PropsTables_IgCNCQTX.mjs} +147 -213
- package/dist/server/chunks/{_@astrojs-ssr-adapter_8jk9s5dg.mjs → _@astrojs-ssr-adapter_CbICuCdt.mjs} +2 -2
- package/dist/server/chunks/{_astro_assets_CmxVRFAY.mjs → _astro_assets_DaYumpRZ.mjs} +2 -2
- package/dist/server/chunks/_astro_data-layer-content_Ni7IDnLe.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_BNJvzYv-.mjs → angle-down-icon_C5YQ7k8s.mjs} +163 -213
- package/dist/server/chunks/astro/{server_zRMEhmuT.mjs → server_Cl9jPh4p.mjs} +179 -89
- package/dist/server/chunks/{astro-designed-error-pages_DRBnGamN.mjs → astro-designed-error-pages_BFveJFnQ.mjs} +1 -1
- package/dist/server/chunks/content-modules_BzUEG69n.mjs +1 -0
- package/dist/server/chunks/{sharp_BAxaBZQw.mjs → sharp_CbOL3WDk.mjs} +2 -2
- package/dist/server/entry.mjs +3 -3
- package/dist/server/{manifest_7YAgSoyv.mjs → manifest_DoNTQyvZ.mjs} +3 -3
- package/dist/server/pages/_image.astro.mjs +1 -1
- package/dist/server/renderers.mjs +63 -14
- package/package.json +5 -2
- package/src/components/Content.tsx +61 -0
- package/src/components/ExampleToolbar.tsx +296 -0
- package/src/components/LiveExample.astro +7 -0
- package/src/components/LiveExample.tsx +42 -0
- package/src/content.ts +2 -1
- package/src/pages/[section]/[page]/[...tab].astro +97 -39
- package/textContent/examples/Accordion/Accordion.mdx +45 -0
- package/textContent/examples/Accordion/AccordionBordered.tsx +141 -0
- package/textContent/examples/Accordion/AccordionDefinitionList.tsx +102 -0
- package/textContent/examples/Accordion/AccordionFixedWithMultipleExpandBehavior.tsx +128 -0
- package/textContent/examples/Accordion/AccordionSingleExpandBehavior.tsx +118 -0
- package/textContent/examples/Accordion/AccordionToggleIconAtStart.tsx +118 -0
- package/dist/client/_astro/Button.C3_jB5tC.js +0 -9
- package/dist/client/_astro/Navigation.CULUlMEB.js +0 -1
- package/dist/client/_astro/PageContext.C7BqCh9N.js +0 -1
- package/dist/client/_astro/PageToggle.DDEjruql.js +0 -1
- package/dist/client/_astro/Toolbar.TAdHxLSQ.js +0 -1
- package/dist/client/_astro/_page_.CXyz_BEo.css +0 -1
- package/dist/client/_astro/_page_.DVvr_Mfl.css +0 -1
- package/dist/client/_astro/_page_.SnUmZn2y.css +0 -1
- package/dist/client/_astro/client.CeeiqVaE.js +0 -1
- package/dist/client/_astro/divider.BSD-oFoh.js +0 -1
- package/dist/client/_astro/index.CTH3fVMn.js +0 -32
- package/dist/client/_astro/page.B65lVdBS.js +0 -1
- /package/dist/server/chunks/{_astro_data-layer-content_DDGBHvtb.mjs → Accordion_CGgMUho2.mjs} +0 -0
- /package/dist/server/chunks/{content-modules_Dz-S_Wwv.mjs → Accordion_DlM2LvlF.mjs} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Content as PFContent } from '@patternfly/react-core'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
export const h1 = ({ children }: { children: ReactNode }) => (
|
|
5
|
+
<PFContent component="h1">{children}</PFContent>
|
|
6
|
+
)
|
|
7
|
+
export const h2 = ({ children }: { children: ReactNode }) => (
|
|
8
|
+
<PFContent component="h2">{children}</PFContent>
|
|
9
|
+
)
|
|
10
|
+
export const h3 = ({ children }: { children: ReactNode }) => (
|
|
11
|
+
<PFContent component="h3">{children}</PFContent>
|
|
12
|
+
)
|
|
13
|
+
export const h4 = ({ children }: { children: ReactNode }) => (
|
|
14
|
+
<PFContent component="h4">{children}</PFContent>
|
|
15
|
+
)
|
|
16
|
+
export const h5 = ({ children }: { children: ReactNode }) => (
|
|
17
|
+
<PFContent component="h5">{children}</PFContent>
|
|
18
|
+
)
|
|
19
|
+
export const h6 = ({ children }: { children: ReactNode }) => (
|
|
20
|
+
<PFContent component="h6">{children}</PFContent>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
export const p = ({ children }: { children: ReactNode }) => (
|
|
24
|
+
<PFContent component="p">{children}</PFContent>
|
|
25
|
+
)
|
|
26
|
+
export const a = ({ children }: { children: ReactNode }) => (
|
|
27
|
+
<PFContent component="a">{children}</PFContent>
|
|
28
|
+
)
|
|
29
|
+
export const small = ({ children }: { children: ReactNode }) => (
|
|
30
|
+
<PFContent component="small">{children}</PFContent>
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export const blockquote = ({ children }: { children: ReactNode }) => (
|
|
34
|
+
<PFContent component="blockquote">{children}</PFContent>
|
|
35
|
+
)
|
|
36
|
+
export const pre = ({ children }: { children: ReactNode }) => (
|
|
37
|
+
<PFContent component="pre">{children}</PFContent>
|
|
38
|
+
)
|
|
39
|
+
export const hr = ({ children }: { children: ReactNode }) => (
|
|
40
|
+
<PFContent component="hr">{children}</PFContent>
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export const ul = ({ children }: { children: ReactNode }) => (
|
|
44
|
+
<PFContent component="ul">{children}</PFContent>
|
|
45
|
+
)
|
|
46
|
+
export const ol = ({ children }: { children: ReactNode }) => (
|
|
47
|
+
<PFContent component="ol">{children}</PFContent>
|
|
48
|
+
)
|
|
49
|
+
export const dl = ({ children }: { children: ReactNode }) => (
|
|
50
|
+
<PFContent component="dl">{children}</PFContent>
|
|
51
|
+
)
|
|
52
|
+
export const li = ({ children }: { children: ReactNode }) => (
|
|
53
|
+
<PFContent component="li">{children}</PFContent>
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
export const dt = ({ children }: { children: ReactNode }) => (
|
|
57
|
+
<PFContent component="dt">{children}</PFContent>
|
|
58
|
+
)
|
|
59
|
+
export const dd = ({ children }: { children: ReactNode }) => (
|
|
60
|
+
<PFContent component="dd">{children}</PFContent>
|
|
61
|
+
)
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// TODO remove this component it is not good and I don't like that I have to add it
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { Button, Form, Tooltip } from '@patternfly/react-core'
|
|
5
|
+
import {
|
|
6
|
+
CodeEditor,
|
|
7
|
+
CodeEditorControl,
|
|
8
|
+
Language,
|
|
9
|
+
} from '@patternfly/react-code-editor'
|
|
10
|
+
import { convertToJSX } from '@patternfly/ast-helpers'
|
|
11
|
+
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon'
|
|
12
|
+
import CodepenIcon from '@patternfly/react-icons/dist/esm/icons/codepen-icon'
|
|
13
|
+
import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon'
|
|
14
|
+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'
|
|
15
|
+
import AngleDoubleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-double-right-icon'
|
|
16
|
+
import ReplyAllIcon from '@patternfly/react-icons/dist/esm/icons/reply-all-icon'
|
|
17
|
+
|
|
18
|
+
const copy = (textToCopy: string) => {
|
|
19
|
+
navigator.clipboard.writeText(textToCopy)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TrackEventValue {
|
|
23
|
+
event_category: string
|
|
24
|
+
event_label: string
|
|
25
|
+
value?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface WindowWithGtag extends Window {
|
|
29
|
+
gtag?: (type: string, name: string, value: TrackEventValue) => void
|
|
30
|
+
}
|
|
31
|
+
const _window = window as WindowWithGtag
|
|
32
|
+
/**
|
|
33
|
+
* Sends network call using Google Analytic's gtag function
|
|
34
|
+
* https://developers.google.com/analytics/devguides/collection/gtagjs/events#send_events
|
|
35
|
+
*
|
|
36
|
+
* @param name {string} - The value that will appear as the event action in Google Analytics Event reports.
|
|
37
|
+
* @param eventCategory {string} - The category of the event.
|
|
38
|
+
* @param eventLabel {string} - The label of the event.
|
|
39
|
+
* @param [value] {number} - An optional non-negative integer that will appear as the event value.
|
|
40
|
+
*/
|
|
41
|
+
const trackEvent = (
|
|
42
|
+
name: string,
|
|
43
|
+
eventCategory: string,
|
|
44
|
+
eventLabel: string,
|
|
45
|
+
value?: number,
|
|
46
|
+
) => {
|
|
47
|
+
value ||= 0
|
|
48
|
+
if (_window?.gtag) {
|
|
49
|
+
_window?.gtag('event', name, {
|
|
50
|
+
// eslint-disable-next-line camelcase
|
|
51
|
+
event_category: eventCategory,
|
|
52
|
+
// eslint-disable-next-line camelcase
|
|
53
|
+
event_label: eventLabel,
|
|
54
|
+
// Optional non-negative integer
|
|
55
|
+
...(value >= 0 && { value }),
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getLanguage(lang: string) {
|
|
61
|
+
if (lang === 'js') {
|
|
62
|
+
return Language.javascript
|
|
63
|
+
} else if (lang === 'ts') {
|
|
64
|
+
return Language.typescript
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return lang as Language
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ExampleToolbarProps {
|
|
71
|
+
fullscreenLink?: string
|
|
72
|
+
codeBoxParams?: any
|
|
73
|
+
lang: string
|
|
74
|
+
isFullscreen?: boolean
|
|
75
|
+
originalCode: string
|
|
76
|
+
code: string
|
|
77
|
+
setCode: (code: string) => void
|
|
78
|
+
exampleTitle?: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const ExampleToolbar = ({
|
|
82
|
+
// Link to fullscreen example page (each example has one)
|
|
83
|
+
fullscreenLink,
|
|
84
|
+
// Params to pass to codesandbox
|
|
85
|
+
codeBoxParams,
|
|
86
|
+
// Language of code
|
|
87
|
+
lang,
|
|
88
|
+
// Whether the example is fullscreen only
|
|
89
|
+
isFullscreen,
|
|
90
|
+
// Original version of the code
|
|
91
|
+
originalCode,
|
|
92
|
+
// Current code in editor
|
|
93
|
+
code,
|
|
94
|
+
// Callback to set code in parent component
|
|
95
|
+
setCode,
|
|
96
|
+
// Title of example used in creating unique labels
|
|
97
|
+
exampleTitle,
|
|
98
|
+
}: ExampleToolbarProps) => {
|
|
99
|
+
const [isEditorOpen, setIsEditorOpen] = React.useState(false)
|
|
100
|
+
const [isCopied, setCopied] = React.useState(false)
|
|
101
|
+
|
|
102
|
+
const copyLabel = 'Copy code to clipboard'
|
|
103
|
+
const languageLabel = `Toggle ${lang.toUpperCase()} code`
|
|
104
|
+
const codesandboxLabel = 'Open example in CodeSandbox'
|
|
105
|
+
const fullscreenLabel = 'Open example in new window'
|
|
106
|
+
const convertLabel = 'Convert example from Typescript to JavaScript'
|
|
107
|
+
const undoAllLabel = 'Undo all changes'
|
|
108
|
+
|
|
109
|
+
const copyAriaLabel = `Copy ${exampleTitle} example code to clipboard`
|
|
110
|
+
const languageAriaLabel = `Toggle ${lang.toUpperCase()} code in ${exampleTitle} example`
|
|
111
|
+
const codesandboxAriaLabel = `Open ${exampleTitle} example in CodeSandbox`
|
|
112
|
+
const fullscreenAriaLabel = `Open ${exampleTitle} example in new window`
|
|
113
|
+
const convertAriaLabel = `Convert ${exampleTitle} example from Typescript to JavaScript`
|
|
114
|
+
const undoAllAriaLabel = `Undo all changes to ${exampleTitle}`
|
|
115
|
+
|
|
116
|
+
const editorControlProps = {
|
|
117
|
+
className: 'ws-code-editor-control',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const commonTooltipProps = {
|
|
121
|
+
exitDelay: 300,
|
|
122
|
+
maxWidth: 'var(--ws-code-editor--tooltip--MaxWidth)',
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const copyCode = () => {
|
|
126
|
+
copy(code)
|
|
127
|
+
setCopied(true)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const customControls = (
|
|
131
|
+
<React.Fragment>
|
|
132
|
+
<CodeEditorControl
|
|
133
|
+
icon={
|
|
134
|
+
<React.Fragment>
|
|
135
|
+
<CodeIcon />
|
|
136
|
+
{' ' + lang.toUpperCase()}
|
|
137
|
+
</React.Fragment>
|
|
138
|
+
}
|
|
139
|
+
onClick={() => {
|
|
140
|
+
setIsEditorOpen(!isEditorOpen)
|
|
141
|
+
// 1 === expand code, 0 === collapse code
|
|
142
|
+
trackEvent(
|
|
143
|
+
'code_editor_control_click',
|
|
144
|
+
'click_event',
|
|
145
|
+
'TOGGLE_CODE',
|
|
146
|
+
isEditorOpen ? 0 : 1,
|
|
147
|
+
)
|
|
148
|
+
}}
|
|
149
|
+
tooltipProps={{
|
|
150
|
+
content: languageLabel,
|
|
151
|
+
...commonTooltipProps,
|
|
152
|
+
}}
|
|
153
|
+
aria-label={languageAriaLabel}
|
|
154
|
+
aria-expanded={isEditorOpen}
|
|
155
|
+
{...editorControlProps}
|
|
156
|
+
/>
|
|
157
|
+
<Tooltip
|
|
158
|
+
content={<div>{isCopied ? 'Code copied' : copyLabel}</div>}
|
|
159
|
+
maxWidth={(editorControlProps as any)?.maxWidth}
|
|
160
|
+
exitDelay={isCopied ? 300 : 1600}
|
|
161
|
+
onTooltipHidden={() => setCopied(false)}
|
|
162
|
+
>
|
|
163
|
+
<Button
|
|
164
|
+
onClick={() => {
|
|
165
|
+
copyCode()
|
|
166
|
+
trackEvent('code_editor_control_click', 'click_event', 'COPY_CODE')
|
|
167
|
+
}}
|
|
168
|
+
variant="plain"
|
|
169
|
+
aria-label={copyAriaLabel}
|
|
170
|
+
className={editorControlProps.className}
|
|
171
|
+
>
|
|
172
|
+
<CopyIcon />
|
|
173
|
+
</Button>
|
|
174
|
+
</Tooltip>
|
|
175
|
+
{codeBoxParams && (
|
|
176
|
+
<Form
|
|
177
|
+
aria-label={`${codesandboxAriaLabel} form`}
|
|
178
|
+
action="https://codesandbox.io/api/v1/sandboxes/define"
|
|
179
|
+
method="POST"
|
|
180
|
+
target="_blank"
|
|
181
|
+
style={{ display: 'inline-block' }}
|
|
182
|
+
>
|
|
183
|
+
<Tooltip
|
|
184
|
+
content={codesandboxLabel}
|
|
185
|
+
maxWidth={(editorControlProps as any).maxWidth}
|
|
186
|
+
>
|
|
187
|
+
<Button
|
|
188
|
+
aria-label={codesandboxAriaLabel}
|
|
189
|
+
variant="plain"
|
|
190
|
+
type="submit"
|
|
191
|
+
onClick={() => {
|
|
192
|
+
trackEvent(
|
|
193
|
+
'code_editor_control_click',
|
|
194
|
+
'click_event',
|
|
195
|
+
'CODESANDBOX_LINK',
|
|
196
|
+
)
|
|
197
|
+
}}
|
|
198
|
+
className={editorControlProps.className}
|
|
199
|
+
>
|
|
200
|
+
<CodepenIcon />
|
|
201
|
+
</Button>
|
|
202
|
+
</Tooltip>
|
|
203
|
+
<input type="hidden" name="parameters" value={codeBoxParams} />
|
|
204
|
+
</Form>
|
|
205
|
+
)}
|
|
206
|
+
{fullscreenLink && (
|
|
207
|
+
<CodeEditorControl
|
|
208
|
+
component="a"
|
|
209
|
+
icon={<ExternalLinkAltIcon />}
|
|
210
|
+
href={fullscreenLink}
|
|
211
|
+
target="_blank"
|
|
212
|
+
rel="noopener noreferrer"
|
|
213
|
+
aria-label={fullscreenAriaLabel}
|
|
214
|
+
tooltipProps={{
|
|
215
|
+
content: fullscreenLabel,
|
|
216
|
+
...commonTooltipProps,
|
|
217
|
+
}}
|
|
218
|
+
onClick={() => {
|
|
219
|
+
trackEvent(
|
|
220
|
+
'code_editor_control_click',
|
|
221
|
+
'click_event',
|
|
222
|
+
'FULLSCREEN_LINK',
|
|
223
|
+
)
|
|
224
|
+
}}
|
|
225
|
+
{...editorControlProps}
|
|
226
|
+
/>
|
|
227
|
+
)}
|
|
228
|
+
{isEditorOpen && lang === 'ts' && (
|
|
229
|
+
<CodeEditorControl
|
|
230
|
+
icon={
|
|
231
|
+
<React.Fragment>
|
|
232
|
+
{'TS '}
|
|
233
|
+
<AngleDoubleRightIcon />
|
|
234
|
+
{' JS'}
|
|
235
|
+
</React.Fragment>
|
|
236
|
+
}
|
|
237
|
+
aria-label={convertAriaLabel}
|
|
238
|
+
tooltipProps={{
|
|
239
|
+
content: convertLabel,
|
|
240
|
+
...commonTooltipProps,
|
|
241
|
+
}}
|
|
242
|
+
onClick={() => {
|
|
243
|
+
setCode(convertToJSX(code).code)
|
|
244
|
+
trackEvent('code_editor_control_click', 'click_event', 'TS_TO_JS')
|
|
245
|
+
}}
|
|
246
|
+
{...editorControlProps}
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
{code !== originalCode && (
|
|
250
|
+
<CodeEditorControl
|
|
251
|
+
icon={<ReplyAllIcon />}
|
|
252
|
+
aria-label={undoAllAriaLabel}
|
|
253
|
+
tooltipProps={{
|
|
254
|
+
content: undoAllLabel,
|
|
255
|
+
...commonTooltipProps,
|
|
256
|
+
}}
|
|
257
|
+
onClick={() => {
|
|
258
|
+
setCode(originalCode)
|
|
259
|
+
trackEvent('code_editor_control_click', 'click_event', 'RESET_CODE')
|
|
260
|
+
}}
|
|
261
|
+
{...editorControlProps}
|
|
262
|
+
/>
|
|
263
|
+
)}
|
|
264
|
+
</React.Fragment>
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
// TODO: check if worth adding react, patternfly, and example types
|
|
268
|
+
// https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.typescript.languageservicedefaults.html#addextralib
|
|
269
|
+
const onEditorDidMount = (_editor: any, monaco: any) => {
|
|
270
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
271
|
+
jsx: true,
|
|
272
|
+
...monaco.languages.typescript.typescriptDefaults.getCompilerOptions(),
|
|
273
|
+
})
|
|
274
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
275
|
+
noSemanticValidation: true,
|
|
276
|
+
noSyntaxValidation: true,
|
|
277
|
+
noSuggestionDiagnostics: true,
|
|
278
|
+
onlyVisible: true,
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<CodeEditor
|
|
284
|
+
customControls={customControls}
|
|
285
|
+
showEditor={isEditorOpen}
|
|
286
|
+
language={getLanguage(lang)}
|
|
287
|
+
height="400px"
|
|
288
|
+
code={code}
|
|
289
|
+
onChange={(newCode) => setCode(newCode)}
|
|
290
|
+
onEditorDidMount={onEditorDidMount}
|
|
291
|
+
isReadOnly={isFullscreen}
|
|
292
|
+
className={`${isEditorOpen ? 'ws-example-code-expanded ' : ''}ws-code-editor`}
|
|
293
|
+
isHeaderPlain
|
|
294
|
+
/>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { convertToReactComponent } from '@patternfly/ast-helpers'
|
|
3
|
+
import * as reactCoreModule from '@patternfly/react-core'
|
|
4
|
+
import { ExampleToolbar } from './ExampleToolbar'
|
|
5
|
+
interface LiveExampleProps {
|
|
6
|
+
src: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getLivePreview(editorCode: string) {
|
|
10
|
+
const scope = { ...reactCoreModule, ...{ useState } }
|
|
11
|
+
const { code: transformedCode } = convertToReactComponent(editorCode)
|
|
12
|
+
|
|
13
|
+
const componentNames = Object.keys(scope)
|
|
14
|
+
const componentValues = Object.values(scope)
|
|
15
|
+
|
|
16
|
+
const getPreviewComponent = new Function(
|
|
17
|
+
'React',
|
|
18
|
+
...componentNames,
|
|
19
|
+
transformedCode,
|
|
20
|
+
)
|
|
21
|
+
const PreviewComponent = getPreviewComponent(React, ...componentValues)
|
|
22
|
+
|
|
23
|
+
return <PreviewComponent />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const LiveExample = ({ src }: LiveExampleProps) => {
|
|
27
|
+
const [code, setCode] = useState(src)
|
|
28
|
+
const livePreview = getLivePreview(code)
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{livePreview}
|
|
33
|
+
<ExampleToolbar
|
|
34
|
+
originalCode={src}
|
|
35
|
+
code={code}
|
|
36
|
+
setCode={setCode}
|
|
37
|
+
lang="ts"
|
|
38
|
+
isFullscreen={false}
|
|
39
|
+
/>
|
|
40
|
+
</>
|
|
41
|
+
)
|
|
42
|
+
}
|
package/src/content.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const content = [
|
|
2
|
-
{ base: 'textContent', pattern: '*.md', name:
|
|
2
|
+
{ base: 'textContent', pattern: '*.{md,mdx}', name: 'textContent' },
|
|
3
|
+
{ base: 'textContent', pattern: 'examples/*/*.mdx', name: 'examples' },
|
|
3
4
|
// TODO: Remove. Uncomment for local testing.
|
|
4
5
|
// {
|
|
5
6
|
// "packageName":"@patternfly/react-core",
|
|
@@ -1,74 +1,132 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title, PageSection
|
|
3
|
+
import { Title, PageSection } from '@patternfly/react-core'
|
|
4
4
|
import MainLayout from '../../../layouts/Main.astro'
|
|
5
|
-
import { content } from
|
|
5
|
+
import { content } from '../../../content'
|
|
6
6
|
import { kebabCase } from 'change-case'
|
|
7
|
-
import { componentTabs, tabNames, buildTab, sortTabs } from '../../../globals'
|
|
7
|
+
import { componentTabs, tabNames, buildTab, sortTabs } from '../../../globals'
|
|
8
8
|
import PropsTables from '../../../components/PropsTables.astro'
|
|
9
|
+
import {
|
|
10
|
+
h1,
|
|
11
|
+
h2,
|
|
12
|
+
h3,
|
|
13
|
+
h4,
|
|
14
|
+
h5,
|
|
15
|
+
h6,
|
|
16
|
+
p,
|
|
17
|
+
a,
|
|
18
|
+
small,
|
|
19
|
+
blockquote,
|
|
20
|
+
pre,
|
|
21
|
+
hr,
|
|
22
|
+
ul,
|
|
23
|
+
ol,
|
|
24
|
+
dl,
|
|
25
|
+
li,
|
|
26
|
+
dt,
|
|
27
|
+
dd,
|
|
28
|
+
} from '../../../components/Content'
|
|
29
|
+
import LiveExample from '../../../components/LiveExample.astro'
|
|
9
30
|
|
|
10
31
|
export async function getStaticPaths() {
|
|
11
|
-
const collections = await Promise.all(
|
|
32
|
+
const collections = await Promise.all(
|
|
33
|
+
content.map(
|
|
34
|
+
async (entry) => await getCollection(entry.name as 'textContent'),
|
|
35
|
+
),
|
|
36
|
+
)
|
|
12
37
|
|
|
13
|
-
const flatCol =
|
|
38
|
+
const flatCol = collections.flat().map((entry) => {
|
|
14
39
|
// Build tabs dictionary
|
|
15
|
-
let tab = entry.data.tab
|
|
16
|
-
if(tab) {
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
let tab = entry.data.tab
|
|
41
|
+
if (tab) {
|
|
42
|
+
// check for demos/deprecated
|
|
43
|
+
if (entry.id.includes('demos')) {
|
|
44
|
+
tab = `${tab}-demos`
|
|
19
45
|
} else if (entry.id.includes('deprecated')) {
|
|
20
|
-
tab = `${tab}-deprecated
|
|
46
|
+
tab = `${tab}-deprecated`
|
|
21
47
|
}
|
|
22
48
|
}
|
|
23
|
-
buildTab(entry, tab)
|
|
49
|
+
buildTab(entry, tab)
|
|
24
50
|
|
|
25
51
|
return {
|
|
26
|
-
params: {
|
|
52
|
+
params: {
|
|
53
|
+
page: kebabCase(entry.data.id),
|
|
54
|
+
section: entry.data.section,
|
|
55
|
+
tab,
|
|
56
|
+
},
|
|
27
57
|
props: { entry, ...entry.data },
|
|
28
58
|
}
|
|
29
59
|
})
|
|
30
60
|
|
|
31
|
-
sortTabs()
|
|
32
|
-
return flatCol
|
|
61
|
+
sortTabs()
|
|
62
|
+
return flatCol
|
|
33
63
|
}
|
|
34
64
|
|
|
35
65
|
const { entry, propComponents } = Astro.props
|
|
36
66
|
const { title, id, section } = entry.data
|
|
37
67
|
const { Content } = await render(entry)
|
|
38
|
-
const currentPath = Astro.url.pathname
|
|
39
|
-
|
|
68
|
+
const currentPath = Astro.url.pathname
|
|
40
69
|
---
|
|
41
70
|
|
|
42
71
|
<MainLayout>
|
|
43
72
|
{
|
|
44
73
|
title && (
|
|
45
74
|
<Title headingLevel="h1" size="4xl">
|
|
46
|
-
{title}
|
|
75
|
+
{title}
|
|
47
76
|
</Title>
|
|
48
77
|
)
|
|
49
78
|
}
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
{
|
|
80
|
+
componentTabs[id] && (
|
|
81
|
+
<PageSection
|
|
82
|
+
id="ws-sticky-nav-tabs"
|
|
83
|
+
stickyOnBreakpoint={{ default: 'top' }}
|
|
84
|
+
type="tabs"
|
|
85
|
+
>
|
|
86
|
+
<div class="pf-v6-c-tabs pf-m-page-insets pf-m-no-border-bottom">
|
|
87
|
+
<ul class="pf-v6-c-tabs__list">
|
|
88
|
+
{componentTabs[id].map((tab: string) => (
|
|
89
|
+
// eslint-disable-next-line react/jsx-key
|
|
90
|
+
<li
|
|
91
|
+
class={`pf-v6-c-tabs__item${currentPath === `/${section}/${kebabCase(id)}/${tab}` ? ' pf-m-current' : ''}`}
|
|
92
|
+
>
|
|
93
|
+
<a
|
|
94
|
+
class="pf-v6-c-tabs__link"
|
|
95
|
+
href={`/${section}/${kebabCase(id)}/${tab}`}
|
|
96
|
+
>
|
|
97
|
+
{tabNames[tab]}
|
|
98
|
+
</a>
|
|
99
|
+
</li>
|
|
100
|
+
))}
|
|
101
|
+
</ul>
|
|
102
|
+
</div>
|
|
103
|
+
</PageSection>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
68
106
|
<PageSection id="main-content" isFilled>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
107
|
+
<Content
|
|
108
|
+
components={{
|
|
109
|
+
h1,
|
|
110
|
+
h2,
|
|
111
|
+
h3,
|
|
112
|
+
h4,
|
|
113
|
+
h5,
|
|
114
|
+
h6,
|
|
115
|
+
p,
|
|
116
|
+
a,
|
|
117
|
+
small,
|
|
118
|
+
blockquote,
|
|
119
|
+
pre,
|
|
120
|
+
hr,
|
|
121
|
+
ul,
|
|
122
|
+
ol,
|
|
123
|
+
dl,
|
|
124
|
+
li,
|
|
125
|
+
dt,
|
|
126
|
+
dd,
|
|
127
|
+
LiveExample,
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
73
131
|
</PageSection>
|
|
74
132
|
</MainLayout>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Accordion
|
|
3
|
+
section: components
|
|
4
|
+
cssPrefix: pf-v6-c-accordion
|
|
5
|
+
propComponents:
|
|
6
|
+
[
|
|
7
|
+
'Accordion',
|
|
8
|
+
'AccordionItem',
|
|
9
|
+
'AccordionContent',
|
|
10
|
+
'AccordionToggle',
|
|
11
|
+
AccordionExpandableContentBody,
|
|
12
|
+
]
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Definition list
|
|
18
|
+
|
|
19
|
+
import AccordionDefinitionList from './AccordionDefinitionList.tsx?raw'
|
|
20
|
+
|
|
21
|
+
<LiveExample src={AccordionDefinitionList} />
|
|
22
|
+
|
|
23
|
+
### Single expand behavior
|
|
24
|
+
|
|
25
|
+
import AccordionSingleExpandBehavior from './AccordionSingleExpandBehavior.tsx?raw'
|
|
26
|
+
|
|
27
|
+
<LiveExample src={AccordionSingleExpandBehavior} />
|
|
28
|
+
|
|
29
|
+
### Fixed with multiple expand behavior
|
|
30
|
+
|
|
31
|
+
import AccordionFixedWithMultipleExpandBehavior from './AccordionFixedWithMultipleExpandBehavior.tsx?raw'
|
|
32
|
+
|
|
33
|
+
<LiveExample src={AccordionFixedWithMultipleExpandBehavior} />
|
|
34
|
+
|
|
35
|
+
### Bordered
|
|
36
|
+
|
|
37
|
+
import AccordionBordered from './AccordionBordered.tsx?raw'
|
|
38
|
+
|
|
39
|
+
<LiveExample src={AccordionBordered} />
|
|
40
|
+
|
|
41
|
+
### Toggle icon at start
|
|
42
|
+
|
|
43
|
+
import AccordionToggleIconAtStart from './AccordionToggleIconAtStart.tsx?raw'
|
|
44
|
+
|
|
45
|
+
<LiveExample src={AccordionToggleIconAtStart} />
|