@patternfly/patternfly-doc-core 1.6.0 → 1.8.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 +19 -0
- package/.astro/collections/textContent.schema.json +19 -0
- package/.astro/content-modules.mjs +1 -0
- package/dist/client/_astro/{PageContext.D1pNBMhh.js → Button.IBWho7ny.js} +2 -2
- package/dist/client/_astro/CSSTable.V4xaGXjj.js +1185 -0
- package/dist/client/_astro/Content.Dv9vgAns.js +1 -0
- package/dist/client/_astro/DropdownGroup.DmTizX-Q.js +1 -0
- package/dist/client/_astro/DropdownList.BUcpBUVP.js +1 -0
- package/dist/client/_astro/LiveExample.CiM2pGMB.js +18 -0
- package/dist/client/_astro/Navigation.CnvE1VCH.js +1 -0
- package/dist/client/_astro/PageContext.ipir86Hm.js +1 -0
- package/dist/client/_astro/PageSidebarBody.vGxFk_DU.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.BwWsXfyf.js +1 -0
- package/dist/client/_astro/SectionGallery.DqD5bUWQ.js +1 -0
- package/dist/client/_astro/Toolbar.BmilfRHR.js +1 -0
- package/dist/client/_astro/ToolbarContent.Cd-kqxku.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/angle-left-icon.C3MzYN3k.js +1 -0
- package/dist/client/_astro/{client.CTJTt880.js → client.zs76E0tG.js} +1 -1
- package/dist/client/_astro/divider.O4WEhuBq.js +1 -0
- package/dist/client/_astro/help-icon.Du6t7nyh.js +8 -0
- package/dist/client/_astro/{index.Dhi-S4Ah.js → index.BQFV5hT1.js} +1 -1
- package/dist/client/_astro/index.BkswdOFP.js +16 -0
- package/dist/client/_astro/index.CAChmxYj.js +1 -0
- package/dist/client/_astro/{index.Dkaqzkgy.js → index.eCxJ45ll.js} +2 -2
- package/dist/client/_astro/page.BTC3Kf3x.js +1 -0
- package/dist/client/components/accordion/index.html +42 -17
- package/dist/client/components/accordion/react/index.html +110 -0
- package/dist/client/components/all-components/index.html +97 -0
- package/dist/client/design-foundations/typography/index.html +36 -9
- package/dist/client/design-foundations/usage-and-behavior/index.html +36 -9
- package/dist/client/get-started/contribute/index.html +36 -9
- package/dist/client/index.html +3 -4
- 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_IgCNCQTX.mjs → PropsTables_DUo7F9VR.mjs} +36 -47
- package/dist/server/chunks/Stack_Xm3fJVbK.mjs +22 -0
- package/dist/server/chunks/_astro_data-layer-content_D4Ib_RjR.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_C5YQ7k8s.mjs → angle-down-icon_DtGGiMR5.mjs} +5 -637
- package/dist/server/chunks/content-modules_fX1c2JRG.mjs +1 -0
- package/dist/server/entry.mjs +3 -2
- package/dist/server/{manifest_DoNTQyvZ.mjs → manifest_CXkcH4VT.mjs} +1 -1
- package/jest.config.ts +1 -1
- package/package.json +1 -1
- 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/NavEntry.tsx +3 -0
- package/src/components/Navigation.astro +16 -9
- package/src/components/section-gallery/SectionGallery.astro +19 -0
- package/src/components/section-gallery/SectionGallery.css +20 -0
- package/src/components/section-gallery/SectionGallery.tsx +111 -0
- package/src/components/section-gallery/SectionGalleryGridLayout.tsx +97 -0
- package/src/components/section-gallery/SectionGalleryListLayout.tsx +108 -0
- package/src/components/section-gallery/SectionGalleryToolbar.tsx +93 -0
- package/src/content.config.ts +11 -3
- package/src/layouts/Main.astro +12 -8
- package/src/pages/[section]/[...page].astro +20 -6
- package/src/pages/[section]/[page]/[...tab].astro +29 -23
- 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/AllComponents.mdx +16 -0
- package/textContent/components-data.js +476 -0
- package/textContent/contribute.md +19 -13
- package/textContent/examples/Accordion/Accordion.mdx +1 -0
- package/dist/client/_astro/LiveExample.Df-EUsee.js +0 -40
- package/dist/client/_astro/Navigation.CabjIYg4.js +0 -1
- package/dist/client/_astro/PageSidebarBody.Y-7d6zQM.js +0 -1
- package/dist/client/_astro/PageToggle.CbfM9bJB.js +0 -1
- package/dist/client/_astro/PageToggleButton.CZ3xPbcc.js +0 -1
- package/dist/client/_astro/Toolbar.9-YSFh3P.js +0 -1
- package/dist/client/_astro/ToolbarContent.BXdFKbs9.js +0 -1
- package/dist/client/_astro/_page_.B8cBYNKa.css +0 -1
- package/dist/client/_astro/_tab_.YrfmckTJ.css +0 -1
- package/dist/client/_astro/divider.DjbDHO_6.js +0 -1
- package/dist/client/_astro/page.CDtWFZb5.js +0 -1
- /package/dist/client/_astro/{_tab_.DxJDkZPc.css → _page_.DxJDkZPc.css} +0 -0
- /package/dist/server/chunks/{Accordion_CGgMUho2.mjs → Accordion_BJka4Qvb.mjs} +0 -0
- /package/dist/server/chunks/{Accordion_DlM2LvlF.mjs → Accordion_BQIphkaZ.mjs} +0 -0
- /package/dist/server/chunks/{_astro_data-layer-content_Ni7IDnLe.mjs → AllComponents_CRhgTsiT.mjs} +0 -0
- /package/dist/server/chunks/{content-modules_BzUEG69n.mjs → AllComponents_CjOtwUH6.mjs} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { SectionGalleryToolbar } from './SectionGalleryToolbar'
|
|
4
|
+
import { SectionGalleryGridLayout } from './SectionGalleryGridLayout'
|
|
5
|
+
import { SectionGalleryListLayout } from './SectionGalleryListLayout'
|
|
6
|
+
import { snakeCase } from 'change-case'
|
|
7
|
+
|
|
8
|
+
import './SectionGallery.css'
|
|
9
|
+
|
|
10
|
+
export interface SectionGalleryItem {
|
|
11
|
+
/** Name of the gallery item. Should match the page name of the item for routing, or an item should provide a link property in the SectionGalleryItemData. */
|
|
12
|
+
name: string
|
|
13
|
+
/** Image file import */
|
|
14
|
+
img: any
|
|
15
|
+
/** Data of the gallery item */
|
|
16
|
+
data: SectionGalleryItemData
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SectionGalleryItemData {
|
|
20
|
+
/** Path to the item illustration */ // TODO: remove if img method is fine
|
|
21
|
+
illustration: string
|
|
22
|
+
/** Summary text of the item */
|
|
23
|
+
summary: string
|
|
24
|
+
/** Label included in the item footer. Choose from a preset or pass a custom label. */
|
|
25
|
+
label?: 'beta' | 'demo' | 'deprecated'
|
|
26
|
+
/** Link to the item, relative to the section, e.g. "/{section}/{page}" */
|
|
27
|
+
link?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface SectionGalleryProps {
|
|
31
|
+
/** Collection of illustations for the gallery */
|
|
32
|
+
illustrations?: any
|
|
33
|
+
/** Section where the gallery is located */
|
|
34
|
+
section: string
|
|
35
|
+
/** Data of all gallery items */
|
|
36
|
+
galleryItemsData: Record<string, SectionGalleryItemData>
|
|
37
|
+
/** Placeholder text for the gallery search input */
|
|
38
|
+
placeholderText?: string
|
|
39
|
+
/** Text for the amount of gallery items */
|
|
40
|
+
countText?: string
|
|
41
|
+
/** Starting layout for the gallery */
|
|
42
|
+
initialLayout?: 'grid' | 'list'
|
|
43
|
+
/** Indicates the grid layout has item summary text */
|
|
44
|
+
hasGridText?: boolean
|
|
45
|
+
/** Indicates the grid layout has item images */
|
|
46
|
+
hasGridImages?: boolean
|
|
47
|
+
/** Indicates the list layout has item summary text */
|
|
48
|
+
hasListText?: boolean
|
|
49
|
+
/** Indicates the list layout has item images */
|
|
50
|
+
hasListImages?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const SectionGallery = ({
|
|
54
|
+
illustrations,
|
|
55
|
+
section,
|
|
56
|
+
galleryItemsData,
|
|
57
|
+
placeholderText,
|
|
58
|
+
countText,
|
|
59
|
+
initialLayout = 'grid',
|
|
60
|
+
hasGridText = false,
|
|
61
|
+
hasGridImages = false,
|
|
62
|
+
hasListText = false,
|
|
63
|
+
hasListImages = false,
|
|
64
|
+
}: SectionGalleryProps) => {
|
|
65
|
+
const [searchTerm, setSearchTerm] = useState('')
|
|
66
|
+
const [layoutView, setLayoutView] = useState(initialLayout)
|
|
67
|
+
|
|
68
|
+
const galleryItems: SectionGalleryItem[] = Object.entries(galleryItemsData)
|
|
69
|
+
.map(([galleryItem, galleryItemData]) => ({
|
|
70
|
+
name: galleryItem,
|
|
71
|
+
img: illustrations ? illustrations[snakeCase(galleryItem)] : undefined,
|
|
72
|
+
data: galleryItemData,
|
|
73
|
+
}))
|
|
74
|
+
.sort((item1, item2) => item1.name.localeCompare(item2.name))
|
|
75
|
+
|
|
76
|
+
const nonCharsRegex = /[^A-Z0-9]+/gi
|
|
77
|
+
const filteringTerm = searchTerm.replace(nonCharsRegex, '')
|
|
78
|
+
const filteredItems: SectionGalleryItem[] = galleryItems.filter((item) =>
|
|
79
|
+
new RegExp(filteringTerm).test(item.name.replace(nonCharsRegex, '')),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div className="ws-section-gallery">
|
|
84
|
+
<SectionGalleryToolbar
|
|
85
|
+
galleryItemCount={galleryItems.length}
|
|
86
|
+
searchTerm={searchTerm}
|
|
87
|
+
setSearchTerm={setSearchTerm}
|
|
88
|
+
layoutView={layoutView}
|
|
89
|
+
setLayoutView={setLayoutView}
|
|
90
|
+
placeholderText={placeholderText}
|
|
91
|
+
countText={countText}
|
|
92
|
+
/>
|
|
93
|
+
{layoutView === 'grid' && (
|
|
94
|
+
<SectionGalleryGridLayout
|
|
95
|
+
section={section}
|
|
96
|
+
galleryItems={filteredItems}
|
|
97
|
+
hasGridText={hasGridText}
|
|
98
|
+
hasGridImages={hasGridImages}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
{layoutView === 'list' && (
|
|
102
|
+
<SectionGalleryListLayout
|
|
103
|
+
section={section}
|
|
104
|
+
galleryItems={filteredItems}
|
|
105
|
+
hasListText={hasListText}
|
|
106
|
+
hasListImages={hasListImages}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Gallery,
|
|
4
|
+
GalleryItem,
|
|
5
|
+
Card,
|
|
6
|
+
CardHeader,
|
|
7
|
+
CardTitle,
|
|
8
|
+
CardBody,
|
|
9
|
+
CardFooter,
|
|
10
|
+
Label,
|
|
11
|
+
Content,
|
|
12
|
+
} from '@patternfly/react-core'
|
|
13
|
+
import { SectionGalleryItem } from './SectionGallery'
|
|
14
|
+
import { sentenceCase } from 'change-case'
|
|
15
|
+
import { convertToReactComponent } from '@patternfly/ast-helpers'
|
|
16
|
+
|
|
17
|
+
interface SectionGalleryGridLayoutProps {
|
|
18
|
+
/** Section where the gallery is located */
|
|
19
|
+
section: string
|
|
20
|
+
/** List of gallery items */
|
|
21
|
+
galleryItems: SectionGalleryItem[]
|
|
22
|
+
/** Indicates the grid layout has item summary text */
|
|
23
|
+
hasGridText: boolean
|
|
24
|
+
/** Indicates the grid layout has item images */
|
|
25
|
+
hasGridImages: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SectionGalleryGridLayout = ({
|
|
29
|
+
section,
|
|
30
|
+
galleryItems,
|
|
31
|
+
hasGridText,
|
|
32
|
+
hasGridImages,
|
|
33
|
+
}: SectionGalleryGridLayoutProps) => (
|
|
34
|
+
<Gallery hasGutter>
|
|
35
|
+
{galleryItems.map(({ name, img, data }, idx) => {
|
|
36
|
+
const itemLink = data.link || `/${section}/${name}`
|
|
37
|
+
|
|
38
|
+
//TODO: rethink how JSX / enriched content is passed to framework
|
|
39
|
+
const summaryNoLinks = data.summary.replace(
|
|
40
|
+
/<a[^>]*>([^<]+)<\/a>/gm,
|
|
41
|
+
'$1',
|
|
42
|
+
)
|
|
43
|
+
const { code } = convertToReactComponent(`<>${summaryNoLinks}</>`)
|
|
44
|
+
const getSummaryComponent = new Function('React', code)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<GalleryItem span={4} key={idx}>
|
|
48
|
+
<Card id={name} key={idx} isClickable>
|
|
49
|
+
<CardHeader
|
|
50
|
+
selectableActions={{
|
|
51
|
+
to: itemLink,
|
|
52
|
+
selectableActionId: `${name}-input`,
|
|
53
|
+
selectableActionAriaLabelledby: name,
|
|
54
|
+
name: `clickable-card-${idx}`,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<CardTitle>{sentenceCase(name)}</CardTitle>
|
|
58
|
+
</CardHeader>
|
|
59
|
+
{(hasGridImages || hasGridText) && (
|
|
60
|
+
<CardBody>
|
|
61
|
+
{hasGridImages && img && (
|
|
62
|
+
<img src={img.src} alt={`${name} illustration`} /> // verify whether this img.src approach is correct
|
|
63
|
+
)}
|
|
64
|
+
{hasGridText && (
|
|
65
|
+
<Content isEditorial>
|
|
66
|
+
<Content component="p">
|
|
67
|
+
{getSummaryComponent(React)}
|
|
68
|
+
</Content>
|
|
69
|
+
</Content>
|
|
70
|
+
)}
|
|
71
|
+
</CardBody>
|
|
72
|
+
)}
|
|
73
|
+
{data.label && (
|
|
74
|
+
<CardFooter>
|
|
75
|
+
{data.label === 'beta' && (
|
|
76
|
+
<Label color="blue" isCompact>
|
|
77
|
+
Beta
|
|
78
|
+
</Label>
|
|
79
|
+
)}
|
|
80
|
+
{data.label === 'deprecated' && (
|
|
81
|
+
<Label color="grey" isCompact>
|
|
82
|
+
Deprecated
|
|
83
|
+
</Label>
|
|
84
|
+
)}
|
|
85
|
+
{data.label === 'demo' && (
|
|
86
|
+
<Label color="purple" isCompact>
|
|
87
|
+
Demo
|
|
88
|
+
</Label>
|
|
89
|
+
)}
|
|
90
|
+
</CardFooter>
|
|
91
|
+
)}
|
|
92
|
+
</Card>
|
|
93
|
+
</GalleryItem>
|
|
94
|
+
)
|
|
95
|
+
})}
|
|
96
|
+
</Gallery>
|
|
97
|
+
)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
DataList,
|
|
4
|
+
DataListItem,
|
|
5
|
+
DataListItemRow,
|
|
6
|
+
DataListItemCells,
|
|
7
|
+
DataListCell,
|
|
8
|
+
Split,
|
|
9
|
+
SplitItem,
|
|
10
|
+
Label,
|
|
11
|
+
Content,
|
|
12
|
+
ContentVariants,
|
|
13
|
+
} from '@patternfly/react-core'
|
|
14
|
+
import { SectionGalleryItem } from './SectionGallery'
|
|
15
|
+
import { sentenceCase } from 'change-case'
|
|
16
|
+
import { convertToReactComponent } from '@patternfly/ast-helpers'
|
|
17
|
+
|
|
18
|
+
interface SectionGalleryListLayoutProps {
|
|
19
|
+
/** Section where the gallery is located */
|
|
20
|
+
section: string
|
|
21
|
+
/** List of gallery items */
|
|
22
|
+
galleryItems: SectionGalleryItem[]
|
|
23
|
+
/** Indicates the list layout has item summary text */
|
|
24
|
+
hasListText: boolean
|
|
25
|
+
/** Indicates the list layout has item images */
|
|
26
|
+
hasListImages: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SectionGalleryListLayout = ({
|
|
30
|
+
section,
|
|
31
|
+
galleryItems,
|
|
32
|
+
hasListText,
|
|
33
|
+
hasListImages,
|
|
34
|
+
}: SectionGalleryListLayoutProps) => (
|
|
35
|
+
<DataList onSelectDataListItem={() => {}} aria-label="gallery-list">
|
|
36
|
+
{galleryItems.map(({ name, img, data }, idx) => {
|
|
37
|
+
const itemLink = data.link || `/${section}/${name}`
|
|
38
|
+
|
|
39
|
+
//TODO: rethink how JSX / enriched content is passed to framework
|
|
40
|
+
const summaryNoLinks = data.summary.replace(
|
|
41
|
+
/<a[^>]*>([^<]+)<\/a>/gm,
|
|
42
|
+
'$1',
|
|
43
|
+
)
|
|
44
|
+
const { code } = convertToReactComponent(`<>${summaryNoLinks}</>`)
|
|
45
|
+
const getSummaryComponent = new Function('React', code)
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<a href={itemLink} key={idx} className="ws-section-gallery-item">
|
|
49
|
+
<DataListItem>
|
|
50
|
+
<DataListItemRow>
|
|
51
|
+
<DataListItemCells
|
|
52
|
+
dataListCells={[
|
|
53
|
+
hasListImages && img && (
|
|
54
|
+
<DataListCell width={1} key="illustration">
|
|
55
|
+
<div>
|
|
56
|
+
<img
|
|
57
|
+
src={img.src} // same as GridLayout, check whether this is the best method
|
|
58
|
+
alt={`${name} illustration`}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</DataListCell>
|
|
62
|
+
),
|
|
63
|
+
<DataListCell width={5} key="text-description">
|
|
64
|
+
<Split
|
|
65
|
+
className={hasListText ? 'pf-v6-u-mb-md' : undefined}
|
|
66
|
+
>
|
|
67
|
+
<SplitItem isFilled>
|
|
68
|
+
<Content isEditorial>
|
|
69
|
+
<Content component={ContentVariants.h2}>
|
|
70
|
+
<span>{sentenceCase(name)}</span>
|
|
71
|
+
</Content>
|
|
72
|
+
</Content>
|
|
73
|
+
</SplitItem>
|
|
74
|
+
<SplitItem>
|
|
75
|
+
{data.label === 'beta' && (
|
|
76
|
+
<Label color="blue" isCompact>
|
|
77
|
+
Beta
|
|
78
|
+
</Label>
|
|
79
|
+
)}
|
|
80
|
+
{data.label === 'deprecated' && (
|
|
81
|
+
<Label color="grey" isCompact>
|
|
82
|
+
Deprecated
|
|
83
|
+
</Label>
|
|
84
|
+
)}
|
|
85
|
+
{data.label === 'demo' && (
|
|
86
|
+
<Label color="purple" isCompact>
|
|
87
|
+
Demo
|
|
88
|
+
</Label>
|
|
89
|
+
)}
|
|
90
|
+
</SplitItem>
|
|
91
|
+
</Split>
|
|
92
|
+
{hasListText && (
|
|
93
|
+
<Content isEditorial>
|
|
94
|
+
<Content component="p">
|
|
95
|
+
{getSummaryComponent(React)}
|
|
96
|
+
</Content>
|
|
97
|
+
</Content>
|
|
98
|
+
)}
|
|
99
|
+
</DataListCell>,
|
|
100
|
+
]}
|
|
101
|
+
/>
|
|
102
|
+
</DataListItemRow>
|
|
103
|
+
</DataListItem>
|
|
104
|
+
</a>
|
|
105
|
+
)
|
|
106
|
+
})}
|
|
107
|
+
</DataList>
|
|
108
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CSSProperties, Dispatch, SetStateAction } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
SearchInput,
|
|
5
|
+
Toolbar,
|
|
6
|
+
ToolbarContent,
|
|
7
|
+
ToolbarItem,
|
|
8
|
+
Content,
|
|
9
|
+
ContentVariants,
|
|
10
|
+
ToggleGroup,
|
|
11
|
+
ToggleGroupItem,
|
|
12
|
+
} from '@patternfly/react-core'
|
|
13
|
+
import ListIcon from '@patternfly/react-icons/dist/esm/icons/list-icon'
|
|
14
|
+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon'
|
|
15
|
+
|
|
16
|
+
interface SectionGalleryToolbarProps {
|
|
17
|
+
/** Total count of gallery items */
|
|
18
|
+
galleryItemCount: number
|
|
19
|
+
/** Current search term */
|
|
20
|
+
searchTerm: string
|
|
21
|
+
/** Setter for search term */
|
|
22
|
+
setSearchTerm: Dispatch<SetStateAction<string>>
|
|
23
|
+
/** Current layout */
|
|
24
|
+
layoutView: 'grid' | 'list'
|
|
25
|
+
/** Setter for layout */
|
|
26
|
+
setLayoutView: Dispatch<SetStateAction<'grid' | 'list'>>
|
|
27
|
+
/** Placeholder text for the gallery search input */
|
|
28
|
+
placeholderText?: string
|
|
29
|
+
/** Text for the amount of gallery items */
|
|
30
|
+
countText?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const SectionGalleryToolbar = ({
|
|
34
|
+
galleryItemCount,
|
|
35
|
+
searchTerm,
|
|
36
|
+
setSearchTerm,
|
|
37
|
+
layoutView,
|
|
38
|
+
setLayoutView,
|
|
39
|
+
placeholderText = 'Search by name',
|
|
40
|
+
countText = ' items',
|
|
41
|
+
}: SectionGalleryToolbarProps) => (
|
|
42
|
+
<Toolbar isSticky>
|
|
43
|
+
<ToolbarContent>
|
|
44
|
+
<ToolbarItem>
|
|
45
|
+
<SearchInput
|
|
46
|
+
value={searchTerm}
|
|
47
|
+
placeholder={placeholderText}
|
|
48
|
+
onChange={(_evt, val) => {
|
|
49
|
+
setSearchTerm(val)
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
</ToolbarItem>
|
|
53
|
+
{searchTerm && (
|
|
54
|
+
<ToolbarItem>
|
|
55
|
+
<Button variant="link" onClick={() => setSearchTerm('')}>
|
|
56
|
+
Reset
|
|
57
|
+
</Button>
|
|
58
|
+
</ToolbarItem>
|
|
59
|
+
)}
|
|
60
|
+
<ToolbarItem>
|
|
61
|
+
<ToggleGroup>
|
|
62
|
+
<ToggleGroupItem
|
|
63
|
+
icon={<ThIcon />}
|
|
64
|
+
aria-label="grid icon button"
|
|
65
|
+
isSelected={layoutView === 'grid'}
|
|
66
|
+
onChange={() => setLayoutView('grid')}
|
|
67
|
+
></ToggleGroupItem>
|
|
68
|
+
<ToggleGroupItem
|
|
69
|
+
icon={<ListIcon />}
|
|
70
|
+
aria-label="list icon button"
|
|
71
|
+
isSelected={layoutView === 'list'}
|
|
72
|
+
onChange={() => setLayoutView('list')}
|
|
73
|
+
></ToggleGroupItem>
|
|
74
|
+
</ToggleGroup>
|
|
75
|
+
</ToolbarItem>
|
|
76
|
+
<ToolbarItem
|
|
77
|
+
variant="pagination"
|
|
78
|
+
gap={{ default: 'gapMd', md: 'gapNone' }}
|
|
79
|
+
style={
|
|
80
|
+
{
|
|
81
|
+
'--pf-v6-c-toolbar__item--MinWidth': 'max-content',
|
|
82
|
+
} as CSSProperties
|
|
83
|
+
}
|
|
84
|
+
className="pf-m-align-self-center"
|
|
85
|
+
>
|
|
86
|
+
<Content isEditorial component={ContentVariants.small}>
|
|
87
|
+
{galleryItemCount}
|
|
88
|
+
{countText}
|
|
89
|
+
</Content>
|
|
90
|
+
</ToolbarItem>
|
|
91
|
+
</ToolbarContent>
|
|
92
|
+
</Toolbar>
|
|
93
|
+
)
|
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,15 @@ 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]), // for component tabs
|
|
32
|
+
sortValue: z.number().optional(), // used for sorting nav entries,
|
|
33
|
+
cssPrefix: z
|
|
34
|
+
.union([
|
|
35
|
+
z.string().transform((val) => [val]),
|
|
36
|
+
z.array(z.string()),
|
|
37
|
+
z.null().transform(() => undefined),
|
|
38
|
+
])
|
|
39
|
+
.optional(),
|
|
32
40
|
}),
|
|
33
41
|
})
|
|
34
42
|
}
|
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,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title } from '@patternfly/react-core'
|
|
3
|
+
import { Title, PageSection, 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'
|
|
10
|
+
import SectionGallery from '../../components/section-gallery/SectionGallery.astro'
|
|
9
11
|
|
|
10
12
|
export async function getStaticPaths() {
|
|
11
13
|
const collections = await Promise.all(
|
|
@@ -20,15 +22,16 @@ export async function getStaticPaths() {
|
|
|
20
22
|
entry,
|
|
21
23
|
title: entry.data.title,
|
|
22
24
|
propComponents: entry.data.propComponents,
|
|
25
|
+
cssPrefix: entry.data.cssPrefix,
|
|
23
26
|
},
|
|
24
27
|
}))
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
const { entry, propComponents } = Astro.props
|
|
30
|
+
const { entry, propComponents, cssPrefix } = Astro.props
|
|
28
31
|
const { title, id, section } = entry.data
|
|
29
32
|
const { Content } = await render(entry)
|
|
30
33
|
|
|
31
|
-
if(section === 'components') { // if section is components, rewrite to first tab content
|
|
34
|
+
if(section === 'components' && componentTabs[id]) { // if section is components & tab exists, rewrite to first tab content
|
|
32
35
|
return Astro.rewrite(`/components/${kebabCase(id)}/${componentTabs[id][0]}`);
|
|
33
36
|
}
|
|
34
37
|
---
|
|
@@ -37,10 +40,21 @@ 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
|
-
|
|
45
|
-
|
|
47
|
+
<PageSection id="main-content" isFilled>
|
|
48
|
+
<Content components={{
|
|
49
|
+
SectionGallery
|
|
50
|
+
}}/>
|
|
51
|
+
<Stack hasGutter>
|
|
52
|
+
<StackItem>
|
|
53
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
54
|
+
</StackItem>
|
|
55
|
+
<StackItem>
|
|
56
|
+
<CSSTable cssPrefix={cssPrefix} server:defer />
|
|
57
|
+
</StackItem>
|
|
58
|
+
</Stack>
|
|
59
|
+
</PageSection>
|
|
46
60
|
</MainLayout>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title, PageSection } from '@patternfly/react-core'
|
|
3
|
+
import { Title, PageSection, 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'
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
dd,
|
|
28
28
|
} from '../../../components/Content'
|
|
29
29
|
import LiveExample from '../../../components/LiveExample.astro'
|
|
30
|
+
import CSSTable from '../../../components/CSSTable.astro'
|
|
30
31
|
|
|
31
32
|
export async function getStaticPaths() {
|
|
32
33
|
const collections = await Promise.all(
|
|
@@ -35,34 +36,32 @@ export async function getStaticPaths() {
|
|
|
35
36
|
),
|
|
36
37
|
)
|
|
37
38
|
|
|
38
|
-
const flatCol =
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const flatCol = collections.flat()
|
|
40
|
+
.filter((entry) => entry.data.tab) // only pages with a tab should match this route
|
|
41
|
+
.map((entry) => {
|
|
42
|
+
// Build tabs dictionary
|
|
43
|
+
let tab = entry.data.tab;
|
|
44
|
+
if(tab) { // check for demos/deprecated
|
|
45
|
+
if(entry.id.includes('demos')) {
|
|
46
|
+
tab = `${tab}-demos`;
|
|
47
|
+
} else if (entry.id.includes('deprecated')) {
|
|
48
|
+
tab = `${tab}-deprecated`;
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
buildTab(entry, tab)
|
|
51
|
+
buildTab(entry, tab);
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
props: { entry, ...entry.data },
|
|
58
|
-
}
|
|
59
|
-
})
|
|
53
|
+
return {
|
|
54
|
+
params: { page: kebabCase(entry.data.id), section: entry.data.section, tab },
|
|
55
|
+
props: { entry, ...entry.data },
|
|
56
|
+
}
|
|
57
|
+
})
|
|
60
58
|
|
|
61
59
|
sortTabs()
|
|
62
60
|
return flatCol
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
const { entry, propComponents } = Astro.props
|
|
63
|
+
const { entry, propComponents, cssPrefix } = Astro.props
|
|
64
|
+
|
|
66
65
|
const { title, id, section } = entry.data
|
|
67
66
|
const { Content } = await render(entry)
|
|
68
67
|
const currentPath = Astro.url.pathname
|
|
@@ -127,6 +126,13 @@ const currentPath = Astro.url.pathname
|
|
|
127
126
|
LiveExample,
|
|
128
127
|
}}
|
|
129
128
|
/>
|
|
130
|
-
<
|
|
129
|
+
<Stack hasGutter>
|
|
130
|
+
<StackItem>
|
|
131
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
132
|
+
</StackItem>
|
|
133
|
+
<StackItem>
|
|
134
|
+
<CSSTable cssPrefix={cssPrefix} server:defer />
|
|
135
|
+
</StackItem>
|
|
136
|
+
</Stack>
|
|
131
137
|
</PageSection>
|
|
132
138
|
</MainLayout>
|
package/src/pages/index.astro
CHANGED
package/src/styles/global.scss
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
.circle {
|
|
2
|
+
height: 1em;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
aspect-ratio: 1 / 1;
|
|
5
|
+
border-radius: 50%;
|
|
6
|
+
border: var(--pf-t--global--border--width--regular) solid
|
|
7
|
+
var(--pf-t--global--background--color--inverse--default);
|
|
8
|
+
box-shadow: var(--pf-t--global--box-shadow--sm);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.rotate-90-deg {
|
|
12
|
+
transform: rotate(90deg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ws-heading {
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ws-heading-anchor {
|
|
20
|
+
color: var(--pf-t--global--icon--color--regular);
|
|
21
|
+
transform: translate(calc(-100% - var(--pf-t--global--spacer--xs)), -50%);
|
|
22
|
+
opacity: 0;
|
|
23
|
+
position: absolute;
|
|
24
|
+
left: 0;
|
|
25
|
+
top: 50%;
|
|
26
|
+
--pf-v6-c-content--a--Color: var(--pf-t--global--icon--color--regular);
|
|
27
|
+
--pf-v6-c-button--m-plain--PaddingInlineEnd: 0;
|
|
28
|
+
--pf-v6-c-button--m-plain--PaddingInlineStart: 0;
|
|
29
|
+
--pf-v6-c-button--MinWidth: unset;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ws-heading-anchor.pf-v6-c-button:hover,
|
|
33
|
+
.ws-heading-anchor.pf-v6-c-button:focus {
|
|
34
|
+
--pf-v6-c-button--hover--Color: var(--pf-t--global--icon--color--regular);
|
|
35
|
+
--pf-v6-c-button--BackgroundColor: transparent;
|
|
36
|
+
--pf-v6-c-content--a--hover--Color: var(--pf-t--global--icon--color--regular);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ws-heading-anchor-icon {
|
|
40
|
+
height: 0.75rem;
|
|
41
|
+
width: 0.75rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ws-heading:hover .ws-heading-anchor,
|
|
45
|
+
.ws-heading-anchor:focus {
|
|
46
|
+
opacity: 1;
|
|
47
|
+
}
|
package/src/utils/index.ts
CHANGED