@patternfly/patternfly-doc-core 1.5.0 → 1.7.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 +56 -0
- package/.astro/collections/textContent.schema.json +16 -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/Button.IBWho7ny.js +9 -0
- package/dist/client/_astro/CSSTable.DHtMmTtQ.js +1185 -0
- package/dist/client/_astro/LiveExample.B7IM_dLQ.css +1 -0
- package/dist/client/_astro/LiveExample.CwKQ5TSc.js +33 -0
- package/dist/client/_astro/Navigation.BSSYIa2f.js +1 -0
- package/dist/client/_astro/PageContext.ipir86Hm.js +1 -0
- package/dist/client/_astro/PageSidebarBody.tzSXGYXP.js +1 -0
- package/dist/client/_astro/PageToggle.C6_rp-Bm.js +1 -0
- package/dist/client/_astro/PageToggleButton.CagcouJB.js +1 -0
- package/dist/client/_astro/SearchInput.BjY-zTwj.js +1 -0
- package/dist/client/_astro/Toolbar.D4TQG77s.js +1 -0
- package/dist/client/_astro/ToolbarContent.DzYW_pmy.js +1 -0
- package/dist/client/_astro/_page_.BWicMEzd.css +1 -0
- package/dist/client/_astro/_page_.Chv_bGyU.css +1 -0
- package/dist/client/_astro/_page_.CtheD08_.css +1 -0
- package/dist/client/_astro/_page_.DxJDkZPc.css +1 -0
- package/dist/client/_astro/client.zs76E0tG.js +1 -0
- package/dist/client/_astro/divider.DTvtnAAt.js +1 -0
- package/dist/client/_astro/help-icon.CDKTE3GW.js +8 -0
- package/dist/client/_astro/index.BQFV5hT1.js +24 -0
- package/dist/client/_astro/index.eCxJ45ll.js +9 -0
- package/dist/client/_astro/page.BTC3Kf3x.js +1 -0
- package/dist/client/components/accordion/index.html +110 -0
- package/dist/client/design-foundations/typography/index.html +35 -8
- package/dist/client/design-foundations/usage-and-behavior/index.html +35 -8
- package/dist/client/get-started/contribute/index.html +35 -8
- package/dist/client/index.html +4 -3
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -1
- package/dist/server/chunks/Button_DVSwQ8oX.mjs +639 -0
- package/dist/server/chunks/CSSTable_CG80uW98.mjs +740 -0
- package/dist/server/chunks/CSSTable_Dj2CroFz.mjs +4 -0
- package/dist/server/chunks/{PropsTables_MQNZVYdD.mjs → PropsTables_DUo7F9VR.mjs} +169 -246
- package/dist/server/chunks/Stack_Xm3fJVbK.mjs +22 -0
- 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_1EAcQtZj.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_BNJvzYv-.mjs → angle-down-icon_DtGGiMR5.mjs} +150 -832
- 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 +4 -3
- package/dist/server/{manifest_7YAgSoyv.mjs → manifest_Dpwo8Jjv.mjs} +3 -3
- package/dist/server/pages/_image.astro.mjs +1 -1
- package/dist/server/renderers.mjs +63 -14
- package/jest.config.ts +1 -1
- package/package.json +5 -2
- package/src/components/AutoLinkHeader.tsx +56 -0
- package/src/components/CSSSearch.tsx +33 -0
- package/src/components/CSSTable.astro +33 -0
- package/src/components/CSSTable.tsx +268 -0
- 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.config.ts +10 -3
- package/src/content.ts +2 -1
- package/src/layouts/Main.astro +12 -8
- package/src/pages/[section]/[...page].astro +16 -6
- package/src/pages/[section]/[page]/[...tab].astro +107 -40
- package/src/pages/index.astro +0 -1
- package/src/styles/global.scss +47 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/slugger.ts +14 -0
- package/textContent/contribute.md +19 -13
- 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,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.config.ts
CHANGED
|
@@ -17,8 +17,8 @@ function defineContent(contentObj: CollectionDefinition) {
|
|
|
17
17
|
// TODO: Expand for other packages that remain under the react umbrella (Table, CodeEditor, etc)
|
|
18
18
|
const tabMap: any = {
|
|
19
19
|
'react-component-docs': 'react',
|
|
20
|
-
'core-component-docs': 'html'
|
|
21
|
-
}
|
|
20
|
+
'core-component-docs': 'html',
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
return defineCollection({
|
|
24
24
|
loader: glob({ base: dir, pattern }),
|
|
@@ -28,7 +28,14 @@ function defineContent(contentObj: CollectionDefinition) {
|
|
|
28
28
|
subsection: z.string().optional(),
|
|
29
29
|
title: z.string().optional(),
|
|
30
30
|
propComponents: z.array(z.string()).optional(),
|
|
31
|
-
tab: z.string().optional().default(tabMap[name])
|
|
31
|
+
tab: z.string().optional().default(tabMap[name]),
|
|
32
|
+
cssPrefix: z
|
|
33
|
+
.union([
|
|
34
|
+
z.string().transform((val) => [val]),
|
|
35
|
+
z.array(z.string()),
|
|
36
|
+
z.null().transform(() => undefined),
|
|
37
|
+
])
|
|
38
|
+
.optional(),
|
|
32
39
|
}),
|
|
33
40
|
})
|
|
34
41
|
}
|
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",
|
package/src/layouts/Main.astro
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '@patternfly/patternfly/patternfly.css'
|
|
3
|
+
import '../styles/global.scss'
|
|
3
4
|
import { ClientRouter } from 'astro:transitions'
|
|
4
5
|
|
|
5
6
|
import Page from '../components/Page.astro'
|
|
6
7
|
import Masthead from '../components/Masthead.astro'
|
|
7
8
|
import Navigation from '../components/Navigation.astro'
|
|
8
|
-
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
<html lang="en" transition:animate="none">
|
|
@@ -27,11 +27,15 @@ import Navigation from '../components/Navigation.astro'
|
|
|
27
27
|
</html>
|
|
28
28
|
|
|
29
29
|
<script>
|
|
30
|
-
const themePreference = window.localStorage.getItem
|
|
31
|
-
document
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const themePreference = window.localStorage.getItem('theme-preference')
|
|
31
|
+
document
|
|
32
|
+
?.querySelector('html')
|
|
33
|
+
?.classList.toggle('pf-v6-theme-dark', themePreference === 'dark')
|
|
34
|
+
|
|
35
|
+
document.addEventListener('astro:after-swap', () => {
|
|
36
|
+
const themePreference = window.localStorage.getItem('theme-preference')
|
|
37
|
+
document
|
|
38
|
+
?.querySelector('html')
|
|
39
|
+
?.classList.toggle('pf-v6-theme-dark', themePreference === 'dark')
|
|
40
|
+
})
|
|
37
41
|
</script>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title } from '@patternfly/react-core'
|
|
3
|
+
import { Title, Stack, StackItem } from '@patternfly/react-core'
|
|
4
4
|
import MainLayout from '../../layouts/Main.astro'
|
|
5
5
|
import { content } from '../../content'
|
|
6
6
|
import { kebabCase } from 'change-case'
|
|
7
7
|
import { componentTabs } from '../../globals'
|
|
8
8
|
import PropsTables from '../../components/PropsTables.astro'
|
|
9
|
+
import CSSTable from '../../components/CSSTable.astro'
|
|
9
10
|
|
|
10
11
|
export async function getStaticPaths() {
|
|
11
12
|
const collections = await Promise.all(
|
|
@@ -20,16 +21,18 @@ export async function getStaticPaths() {
|
|
|
20
21
|
entry,
|
|
21
22
|
title: entry.data.title,
|
|
22
23
|
propComponents: entry.data.propComponents,
|
|
24
|
+
cssPrefix: entry.data.cssPrefix,
|
|
23
25
|
},
|
|
24
26
|
}))
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const { entry, propComponents } = Astro.props
|
|
29
|
+
const { entry, propComponents, cssPrefix } = Astro.props
|
|
28
30
|
const { title, id, section } = entry.data
|
|
29
31
|
const { Content } = await render(entry)
|
|
30
32
|
|
|
31
|
-
if(section === 'components') {
|
|
32
|
-
|
|
33
|
+
if (section === 'components') {
|
|
34
|
+
// if section is components, rewrite to first tab content
|
|
35
|
+
return Astro.rewrite(`/components/${kebabCase(id)}/${componentTabs[id][0]}`)
|
|
33
36
|
}
|
|
34
37
|
---
|
|
35
38
|
|
|
@@ -37,10 +40,17 @@ if(section === 'components') { // if section is components, rewrite to first tab
|
|
|
37
40
|
{
|
|
38
41
|
title && (
|
|
39
42
|
<Title headingLevel="h1" size="4xl">
|
|
40
|
-
{title}
|
|
43
|
+
{title}
|
|
41
44
|
</Title>
|
|
42
45
|
)
|
|
43
46
|
}
|
|
44
47
|
<Content />
|
|
45
|
-
<
|
|
48
|
+
<Stack hasGutter>
|
|
49
|
+
<StackItem>
|
|
50
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
51
|
+
</StackItem>
|
|
52
|
+
<StackItem>
|
|
53
|
+
<CSSTable cssPrefix={cssPrefix} server:defer />
|
|
54
|
+
</StackItem>
|
|
55
|
+
</Stack>
|
|
46
56
|
</MainLayout>
|
|
@@ -1,74 +1,141 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title, PageSection,
|
|
3
|
+
import { Title, PageSection, Stack, StackItem } 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'
|
|
30
|
+
import CSSTable from '../../../components/CSSTable.astro'
|
|
9
31
|
|
|
10
32
|
export async function getStaticPaths() {
|
|
11
|
-
const collections = await Promise.all(
|
|
33
|
+
const collections = await Promise.all(
|
|
34
|
+
content.map(
|
|
35
|
+
async (entry) => await getCollection(entry.name as 'textContent'),
|
|
36
|
+
),
|
|
37
|
+
)
|
|
12
38
|
|
|
13
|
-
const flatCol =
|
|
39
|
+
const flatCol = collections.flat().map((entry) => {
|
|
14
40
|
// Build tabs dictionary
|
|
15
|
-
let tab = entry.data.tab
|
|
16
|
-
if(tab) {
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
let tab = entry.data.tab
|
|
42
|
+
if (tab) {
|
|
43
|
+
// check for demos/deprecated
|
|
44
|
+
if (entry.id.includes('demos')) {
|
|
45
|
+
tab = `${tab}-demos`
|
|
19
46
|
} else if (entry.id.includes('deprecated')) {
|
|
20
|
-
tab = `${tab}-deprecated
|
|
47
|
+
tab = `${tab}-deprecated`
|
|
21
48
|
}
|
|
22
49
|
}
|
|
23
|
-
buildTab(entry, tab)
|
|
50
|
+
buildTab(entry, tab)
|
|
24
51
|
|
|
25
52
|
return {
|
|
26
|
-
params: {
|
|
53
|
+
params: {
|
|
54
|
+
page: kebabCase(entry.data.id),
|
|
55
|
+
section: entry.data.section,
|
|
56
|
+
tab,
|
|
57
|
+
},
|
|
27
58
|
props: { entry, ...entry.data },
|
|
28
59
|
}
|
|
29
60
|
})
|
|
30
61
|
|
|
31
|
-
sortTabs()
|
|
32
|
-
return flatCol
|
|
62
|
+
sortTabs()
|
|
63
|
+
return flatCol
|
|
33
64
|
}
|
|
34
65
|
|
|
35
|
-
const { entry, propComponents } = Astro.props
|
|
66
|
+
const { entry, propComponents, cssPrefix } = Astro.props
|
|
67
|
+
|
|
36
68
|
const { title, id, section } = entry.data
|
|
37
69
|
const { Content } = await render(entry)
|
|
38
|
-
const currentPath = Astro.url.pathname
|
|
39
|
-
|
|
70
|
+
const currentPath = Astro.url.pathname
|
|
40
71
|
---
|
|
41
72
|
|
|
42
73
|
<MainLayout>
|
|
43
74
|
{
|
|
44
75
|
title && (
|
|
45
76
|
<Title headingLevel="h1" size="4xl">
|
|
46
|
-
{title}
|
|
77
|
+
{title}
|
|
47
78
|
</Title>
|
|
48
79
|
)
|
|
49
80
|
}
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
{
|
|
82
|
+
componentTabs[id] && (
|
|
83
|
+
<PageSection
|
|
84
|
+
id="ws-sticky-nav-tabs"
|
|
85
|
+
stickyOnBreakpoint={{ default: 'top' }}
|
|
86
|
+
type="tabs"
|
|
87
|
+
>
|
|
88
|
+
<div class="pf-v6-c-tabs pf-m-page-insets pf-m-no-border-bottom">
|
|
89
|
+
<ul class="pf-v6-c-tabs__list">
|
|
90
|
+
{componentTabs[id].map((tab: string) => (
|
|
91
|
+
// eslint-disable-next-line react/jsx-key
|
|
92
|
+
<li
|
|
93
|
+
class={`pf-v6-c-tabs__item${currentPath === `/${section}/${kebabCase(id)}/${tab}` ? ' pf-m-current' : ''}`}
|
|
94
|
+
>
|
|
95
|
+
<a
|
|
96
|
+
class="pf-v6-c-tabs__link"
|
|
97
|
+
href={`/${section}/${kebabCase(id)}/${tab}`}
|
|
98
|
+
>
|
|
99
|
+
{tabNames[tab]}
|
|
100
|
+
</a>
|
|
101
|
+
</li>
|
|
102
|
+
))}
|
|
103
|
+
</ul>
|
|
104
|
+
</div>
|
|
105
|
+
</PageSection>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
68
108
|
<PageSection id="main-content" isFilled>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
<Content
|
|
110
|
+
components={{
|
|
111
|
+
h1,
|
|
112
|
+
h2,
|
|
113
|
+
h3,
|
|
114
|
+
h4,
|
|
115
|
+
h5,
|
|
116
|
+
h6,
|
|
117
|
+
p,
|
|
118
|
+
a,
|
|
119
|
+
small,
|
|
120
|
+
blockquote,
|
|
121
|
+
pre,
|
|
122
|
+
hr,
|
|
123
|
+
ul,
|
|
124
|
+
ol,
|
|
125
|
+
dl,
|
|
126
|
+
li,
|
|
127
|
+
dt,
|
|
128
|
+
dd,
|
|
129
|
+
LiveExample,
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
<Stack hasGutter>
|
|
133
|
+
<StackItem>
|
|
134
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
135
|
+
</StackItem>
|
|
136
|
+
<StackItem>
|
|
137
|
+
<CSSTable cssPrefix={cssPrefix} server:defer />
|
|
138
|
+
</StackItem>
|
|
139
|
+
</Stack>
|
|
73
140
|
</PageSection>
|
|
74
141
|
</MainLayout>
|