@patternfly/patternfly-doc-core 1.7.0 → 1.8.1
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 +3 -0
- package/.astro/collections/textContent.schema.json +3 -0
- package/.astro/content-modules.mjs +1 -0
- package/dist/client/_astro/{CSSTable.DHtMmTtQ.js → CSSTable.V4xaGXjj.js} +2 -2
- 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.zYUnVsp7.js +1 -0
- package/dist/client/_astro/PageSidebarBody.vGxFk_DU.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 → _page_.D1z73Byz.css} +1 -1
- package/dist/client/_astro/angle-left-icon.C3MzYN3k.js +1 -0
- package/dist/client/_astro/divider.O4WEhuBq.js +1 -0
- package/dist/client/_astro/help-icon.Du6t7nyh.js +8 -0
- package/dist/client/_astro/index.BkswdOFP.js +16 -0
- package/dist/client/_astro/index.CAChmxYj.js +1 -0
- package/dist/client/components/accordion/index.html +18 -18
- 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 +13 -11
- package/dist/client/design-foundations/usage-and-behavior/index.html +13 -11
- package/dist/client/get-started/contribute/index.html +13 -11
- package/dist/client/index.html +2 -2
- package/dist/server/chunks/CSSTable_C1yGETxF.mjs +4 -0
- package/dist/server/chunks/{CSSTable_CG80uW98.mjs → CSSTable_CM0NKE3J.mjs} +2 -2
- package/dist/server/chunks/{PropsTables_DUo7F9VR.mjs → PropsTables_WcioWlx5.mjs} +3 -3
- package/dist/server/chunks/{Stack_Xm3fJVbK.mjs → Stack_80ickdCi.mjs} +1 -1
- package/dist/server/chunks/_astro_data-layer-content_D4Ib_RjR.mjs +1 -0
- package/dist/server/chunks/{angle-down-icon_DtGGiMR5.mjs → angle-down-icon_BO1Ed-9Z.mjs} +1 -1
- package/dist/server/chunks/content-modules_fX1c2JRG.mjs +1 -0
- package/dist/server/entry.mjs +3 -3
- package/dist/server/{manifest_Dpwo8Jjv.mjs → manifest_zgA_NEEc.mjs} +1 -1
- package/package.json +1 -1
- package/src/components/NavEntry.tsx +3 -0
- package/src/components/Navigation.astro +18 -12
- package/src/components/Navigation.tsx +12 -10
- 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 +2 -1
- package/src/layouts/Main.astro +28 -0
- package/src/pages/[section]/[...page].astro +17 -13
- package/src/pages/[section]/[page]/[...tab].astro +17 -20
- package/src/styles/global.scss +1 -0
- package/textContent/AllComponents.mdx +16 -0
- package/textContent/components-data.js +476 -0
- package/textContent/examples/Accordion/Accordion.mdx +1 -0
- package/dist/client/_astro/LiveExample.CwKQ5TSc.js +0 -33
- package/dist/client/_astro/Navigation.BSSYIa2f.js +0 -1
- package/dist/client/_astro/PageSidebarBody.tzSXGYXP.js +0 -1
- package/dist/client/_astro/SearchInput.BjY-zTwj.js +0 -1
- package/dist/client/_astro/Toolbar.D4TQG77s.js +0 -1
- package/dist/client/_astro/ToolbarContent.DzYW_pmy.js +0 -1
- package/dist/client/_astro/divider.DTvtnAAt.js +0 -1
- package/dist/client/_astro/help-icon.CDKTE3GW.js +0 -8
- package/dist/server/chunks/CSSTable_Dj2CroFz.mjs +0 -4
- /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_1EAcQtZj.mjs → AllComponents_CRhgTsiT.mjs} +0 -0
- /package/dist/server/chunks/{content-modules_BzUEG69n.mjs → AllComponents_CjOtwUH6.mjs} +0 -0
- /package/dist/server/chunks/{Button_DVSwQ8oX.mjs → Button_BKhHR-ak.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
|
@@ -28,7 +28,8 @@ 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,
|
|
32
33
|
cssPrefix: z
|
|
33
34
|
.union([
|
|
34
35
|
z.string().transform((val) => [val]),
|
package/src/layouts/Main.astro
CHANGED
|
@@ -38,4 +38,32 @@ import Navigation from '../components/Navigation.astro'
|
|
|
38
38
|
?.querySelector('html')
|
|
39
39
|
?.classList.toggle('pf-v6-theme-dark', themePreference === 'dark')
|
|
40
40
|
})
|
|
41
|
+
|
|
42
|
+
const scrollToHash = (hash: string) => {
|
|
43
|
+
const targetElement = document.querySelector(hash)
|
|
44
|
+
if (targetElement) {
|
|
45
|
+
targetElement.scrollIntoView({ behavior: 'smooth' })
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
50
|
+
if (window.location.hash) {
|
|
51
|
+
const hash = window.location.hash
|
|
52
|
+
|
|
53
|
+
// Without this, page would focus on anchor link without scrolling to it
|
|
54
|
+
history.replaceState(null, '', ' ')
|
|
55
|
+
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
scrollToHash(hash)
|
|
58
|
+
history.replaceState(null, '', hash)
|
|
59
|
+
}, 500)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// Handle changes that happen after the initial page load
|
|
64
|
+
window.addEventListener('hashchange', () => {
|
|
65
|
+
if (window.location.hash) {
|
|
66
|
+
scrollToHash(window.location.hash)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
41
69
|
</script>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
-
import { Title, Stack, StackItem } 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
9
|
import CSSTable from '../../components/CSSTable.astro'
|
|
10
|
+
import SectionGallery from '../../components/section-gallery/SectionGallery.astro'
|
|
10
11
|
|
|
11
12
|
export async function getStaticPaths() {
|
|
12
13
|
const collections = await Promise.all(
|
|
@@ -30,9 +31,8 @@ const { entry, propComponents, cssPrefix } = Astro.props
|
|
|
30
31
|
const { title, id, section } = entry.data
|
|
31
32
|
const { Content } = await render(entry)
|
|
32
33
|
|
|
33
|
-
if
|
|
34
|
-
|
|
35
|
-
return Astro.rewrite(`/components/${kebabCase(id)}/${componentTabs[id][0]}`)
|
|
34
|
+
if(section === 'components' && componentTabs[id]) { // if section is components & tab exists, rewrite to first tab content
|
|
35
|
+
return Astro.rewrite(`/components/${kebabCase(id)}/${componentTabs[id][0]}`);
|
|
36
36
|
}
|
|
37
37
|
---
|
|
38
38
|
|
|
@@ -44,13 +44,17 @@ if (section === 'components') {
|
|
|
44
44
|
</Title>
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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>
|
|
56
60
|
</MainLayout>
|
|
@@ -36,28 +36,25 @@ export async function getStaticPaths() {
|
|
|
36
36
|
),
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
-
const flatCol =
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
}
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
buildTab(entry, tab)
|
|
51
|
+
buildTab(entry, tab);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
props: { entry, ...entry.data },
|
|
59
|
-
}
|
|
60
|
-
})
|
|
53
|
+
return {
|
|
54
|
+
params: { page: kebabCase(entry.data.id), section: entry.data.section, tab },
|
|
55
|
+
props: { entry, ...entry.data },
|
|
56
|
+
}
|
|
57
|
+
})
|
|
61
58
|
|
|
62
59
|
sortTabs()
|
|
63
60
|
return flatCol
|
package/src/styles/global.scss
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: All components
|
|
3
|
+
title: All components
|
|
4
|
+
section: components
|
|
5
|
+
sortValue: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
import { componentsData } from './components-data.js'
|
|
9
|
+
|
|
10
|
+
<SectionGallery
|
|
11
|
+
section="components"
|
|
12
|
+
galleryItemsData={componentsData}
|
|
13
|
+
placeholderText="Search components by name"
|
|
14
|
+
hasGridText
|
|
15
|
+
hasListText
|
|
16
|
+
/>
|