Skip to content

Commit e63eeef

Browse files
committed
some further updates to piping SectionGallery
1 parent c790470 commit e63eeef

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
import { SectionGallery as SectionGalleryBase } from './SectionGallery'
3+
4+
const { illustrations, section, galleryItemsData, placeholderText, countText, initialLayout, hasGridText, hasGridImages, hasListText, hasListImages } = Astro.props
5+
---
6+
7+
<SectionGalleryBase
8+
illustrations={illustrations}
9+
section={section}
10+
galleryItemsData={galleryItemsData}
11+
placeholderText={placeholderText}
12+
countText={countText}
13+
initialLayout={initialLayout}
14+
hasGridText={hasGridText}
15+
hasGridImages={hasGridImages}
16+
hasListText={hasListText}
17+
hasListImages={hasListImages}
18+
client:only="react"
19+
/>

src/components/section-gallery/SectionGallery.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface SectionGalleryItemData {
2222
/** Summary text of the item */
2323
summary: JSX.Element
2424
/** Label included in the item footer. Choose from a preset or pass a custom label. */
25-
label?: 'beta' | 'demo' | 'deprecated' | JSX.Element
25+
label?: 'beta' | 'demo' | 'deprecated'
2626
/** Link to the item, relative to the section, e.g. "/{section}/{page}" */
2727
link?: string
2828
}
@@ -58,17 +58,17 @@ export const SectionGallery = ({
5858
countText,
5959
initialLayout = 'grid',
6060
hasGridText = false,
61-
hasGridImages = true,
62-
hasListText = true,
63-
hasListImages = true,
61+
hasGridImages = false,
62+
hasListText = false,
63+
hasListImages = false,
6464
}: SectionGalleryProps) => {
6565
const [searchTerm, setSearchTerm] = useState('')
6666
const [layoutView, setLayoutView] = useState(initialLayout)
6767

6868
const galleryItems: SectionGalleryItem[] = Object.entries(galleryItemsData)
6969
.map(([galleryItem, galleryItemData]) => ({
7070
name: galleryItem,
71-
img: illustrations[snakeCase(galleryItem)],
71+
img: illustrations ? illustrations[snakeCase(galleryItem)] : undefined,
7272
data: galleryItemData,
7373
}))
7474
.sort((item1, item2) => item1.name.localeCompare(item2.name))

src/components/section-gallery/SectionGalleryGridLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export const SectionGalleryGridLayout = ({
7575
Demo
7676
</Label>
7777
)}
78-
{typeof data.label !== 'string' && <>{data.label}</>}
7978
</CardFooter>
8079
)}
8180
</Card>
8281
</GalleryItem>
83-
)})}
82+
)
83+
})}
8484
</Gallery>
8585
)

src/components/section-gallery/SectionGalleryListLayout.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export const SectionGalleryListLayout = ({
5151
</DataListCell>
5252
),
5353
<DataListCell width={5} key="text-description">
54-
<Split className={hasListText ? "pf-v6-u-mb-md" : undefined}>
54+
<Split
55+
className={hasListText ? 'pf-v6-u-mb-md' : undefined}
56+
>
5557
<SplitItem isFilled>
5658
<Content isEditorial>
5759
<Content component={ContentVariants.h2}>
@@ -75,7 +77,6 @@ export const SectionGalleryListLayout = ({
7577
Demo
7678
</Label>
7779
)}
78-
{typeof data.label !== 'string' && <>{data.label}</>}
7980
</SplitItem>
8081
</Split>
8182
{hasListText && (
@@ -89,6 +90,7 @@ export const SectionGalleryListLayout = ({
8990
</DataListItemRow>
9091
</DataListItem>
9192
</a>
92-
)})}
93+
)
94+
})}
9395
</DataList>
9496
)

src/pages/[section]/[...page].astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { content } from '../../content'
66
import { kebabCase } from 'change-case'
77
import { componentTabs } from '../../globals'
88
import PropsTables from '../../components/PropsTables.astro'
9+
import SectionGallery from '../../components/section-gallery/SectionGallery.astro'
910
1011
export async function getStaticPaths() {
1112
const collections = await Promise.all(
@@ -40,12 +41,14 @@ if(section === 'components' && componentTabs[id]) { // if section is components
4041
{
4142
title && (
4243
<Title headingLevel="h1" size="4xl">
43-
{title}
44+
{title}
4445
</Title>
4546
)
4647
}
4748
<PageSection id="main-content" isFilled>
48-
<Content />
49+
<Content components={{
50+
SectionGallery
51+
}}/>
4952
<PropsTables propComponents={propComponents} server:defer />
5053
</PageSection>
5154
</MainLayout>

textContent/AllComponents.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ section: components
55
sortValue: 1
66
---
77

8-
import { SectionGallery } from '../src/components/section-gallery/SectionGallery'
9-
import componentsData from './components-data.jsx'
8+
import { componentsData } from './components-data.jsx'
109

1110
<SectionGallery
1211
section="components"
1312
galleryItemsData={componentsData}
1413
placeholderText="Search components by name"
14+
hasGridText
15+
hasListText
1516
/>

textContent/components-data.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const componentsData = {
1010
product version numbers and any appropriate legal text.
1111
</>
1212
),
13-
label: <p>testing custom content</p>,
1413
},
1514
'accordion': {
1615
illustration: './images/component-illustrations/accordion.png',

textContent/examples/Accordion/Accordion.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ propComponents:
1010
'AccordionToggle',
1111
AccordionExpandableContentBody,
1212
]
13+
tab: react
1314
---
1415

1516
## Examples

0 commit comments

Comments
 (0)