import React from 'react' import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell, Split, SplitItem, Label, Content, ContentVariants, } from '@patternfly/react-core' import { SectionGalleryItem } from './SectionGallery' import { sentenceCase } from 'change-case' import { convertToReactComponent } from '@patternfly/ast-helpers' interface SectionGalleryListLayoutProps { /** Section where the gallery is located */ section: string /** List of gallery items */ galleryItems: SectionGalleryItem[] /** Indicates the list layout has item summary text */ hasListText: boolean /** Indicates the list layout has item images */ hasListImages: boolean } export const SectionGalleryListLayout = ({ section, galleryItems, hasListText, hasListImages, }: SectionGalleryListLayoutProps) => ( {}} aria-label="gallery-list"> {galleryItems.map(({ name, img, data }, idx) => { const itemLink = data.link || `/${section}/${name}` //TODO: rethink how JSX / enriched content is passed to framework const summaryNoLinks = data.summary.replace( /]*>([^<]+)<\/a>/gm, '$1', ) const { code } = convertToReactComponent(`<>${summaryNoLinks}`) const getSummaryComponent = new Function('React', code) return (
{`${name}
), {sentenceCase(name)} {data.label === 'beta' && ( )} {data.label === 'deprecated' && ( )} {data.label === 'demo' && ( )} {hasListText && ( {getSummaryComponent(React)} )} , ]} />
) })}
)