);
}
```
--------------------------------
### CatalogTileBadge Usage Example
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/api-reference/CatalogTileBadge.md
Example demonstrating how to use the CatalogTileBadge component with and without a tooltip, integrated within a CatalogTile.
```typescript
import { CatalogTile, CatalogTileBadge } from '@patternfly/react-catalog-view-extension';
import { CheckCircleIcon, LockIcon, WarningTriangleIcon } from '@patternfly/react-icons';
// Badge with tooltip
,
,
]}
/>
// Simple badge without tooltip
```
--------------------------------
### Default Exports Example
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/imports.md
Demonstrates default exports, noting that named imports are recommended.
```typescript
// These work but are less idiomatic
import FilterSidePanel from '@patternfly/react-catalog-view-extension';
import FilterSidePanelCategory from '@patternfly/react-catalog-view-extension';
import FilterSidePanelCategoryItem from '@patternfly/react-catalog-view-extension';
```
--------------------------------
### PropertyItem Usage Example
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/api-reference/PropertyItem.md
An example demonstrating how to use the PropertyItem component within a PropertiesSidePanel, showcasing various prop usages including simple strings, rich content, and elements as labels/values.
```typescript
import { PropertiesSidePanel, PropertyItem } from '@patternfly/react-catalog-view-extension';
import { CheckIcon, ExclamationIcon } from '@patternfly/react-icons';
{/* Simple string values */}
{/* Rich content as values */}
Ready}
/>
{/* Element as label */}
Critical}
value={ Update Required}
/>
{/* Complex value component */}
MongoDB Inc.
support@mongodb.com
}
/>
{/* Property without value */}
```
--------------------------------
### Custom Router Integration
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/examples.md
Use with React Router for navigation.
```typescript
import { useNavigate } from 'react-router-dom';
import { CatalogTile } from '@patternfly/react-catalog-view-extension';
import { VerticalTabs, VerticalTabsTab } from '@patternfly/react-catalog-view-extension';
export function RouterIntegratedCatalog() {
const navigate = useNavigate();
const handleTileClick = (itemId) => {
navigate(`/catalog/${itemId}`);
};
return (
{
// Only handle non-link clicks
if (e.metaKey || e.ctrlKey || e.shiftKey) {
// Let browser handle it
return;
}
handleTileClick(1);
}}
/>
);
}
export function RouterIntegratedTabs() {
const navigate = useNavigate();
return (
navigate('/docs/overview')}
active={false}
/>
navigate('/docs/install')}
active={false}
/>
);
}
```
--------------------------------
### Conditional Properties
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/component-guide.md
Illustrates how to conditionally render PropertyItems based on data availability.
```typescript
{item.vendor && }
{item.version && }
{item.supportedPlatforms && (
)}
```
--------------------------------
### Restrict Tabs Mode Example
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/component-guide.md
Example of using the 'restrictTabs' prop in VerticalTabs to create a collapsible tree where only the active branch is shown.
```typescript
```
--------------------------------
### Checkbox State Management Example
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/component-guide.md
Example of managing the checked state for FilterSidePanelCategoryItem components using React's useState hook.
```typescript
const [filters, setFilters] = useState({
typeDatabase: false,
typeCache: false,
vendorRedHat: false,
});
function handleFilterChange(key) {
setFilters(prev => ({
...prev,
[key]: !prev[key]
}));
}
// Render:
handleFilterChange('typeDatabase')}
>
Database
handleFilterChange('typeCache')}
>
Cache
```
--------------------------------
### Package Information
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/START-HERE.md
Package.json information for the @patternfly/react-catalog-view-extension.
```json
{
"name": "@patternfly/react-catalog-view-extension",
"version": "6.1.0-prerelease.0",
"main": "dist/js/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"dependencies": {
"@patternfly/react-core": "^6.1.0",
"@patternfly/react-styles": "^6.1.0"
},
"peerDependencies": {
"react": "^17 || ^18 || ^19",
"react-dom": "^17 || ^18 || ^19"
}
}
```
--------------------------------
### Modal Header Usage
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/component-guide.md
Example of using CatalogItemHeader within a modal's title.
```typescript
}
>
{/* Modal content */}
```
--------------------------------
### Multi-Select Catalog with Bulk Actions
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/examples.md
Select multiple items and perform batch operations.
```typescript
import { useState, useCallback } from 'react';
import { CatalogTile, CatalogTileBadge } from '@patternfly/react-catalog-view-extension';
import { CheckCircleIcon, TrashIcon } from '@patternfly/react-icons';
import { Button, Toolbar, ToolbarContent } from '@patternfly/react-core';
const ITEMS = [
{ id: 1, name: 'PostgreSQL' },
{ id: 2, name: 'MongoDB' },
{ id: 3, name: 'Redis' },
];
export function SelectableCatalog() {
const [selected, setSelected] = useState(new Set());
const handleToggle = useCallback((id) => {
setSelected(prev => {
const next = new Set(prev);
if (next.has(id)) {
next.delete(id);
} else {
next.add(id);
}
return next;
});
}, []);
const handleSelectAll = useCallback(() => {
if (selected.size === ITEMS.length) {
setSelected(new Set());
} else {
setSelected(new Set(ITEMS.map(item => item.id)));
}
}, [selected.size]);
const handleDelete = useCallback(() => {
console.log('Delete items:', Array.from(selected));
// Handle deletion...
setSelected(new Set());
}, [selected]);
return (
<>
{selected.size > 0 && (
{selected.size} selected
)}
>
);
}
```
--------------------------------
### Featured Items with Badges
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/examples.md
Showcase featured items with certification and rating badges.
```typescript
import { CatalogTile, CatalogTileBadge } from '@patternfly/react-catalog-view-extension';
import {
CheckCircleIcon,
StarIcon,
WarningTriangleIcon
} from '@patternfly/react-icons';
const FEATURED_ITEMS = [
{
id: 1,
name: 'PostgreSQL',
certified: true,
rating: 5,
promoted: true
},
{
id: 2,
name: 'MongoDB',
certified: false,
rating: 4,
promoted: true
}
];
export function FeaturedSection() {
return (
Featured Services
{FEATURED_ITEMS.map(item => (
),
]}
/>
))}
);
}
```
--------------------------------
### Building
Source: https://github.com/patternfly/react-catalog-view/blob/main/README.md
Builds the project using Yarn.
```bash
yarn build
```
--------------------------------
### Basic Tile
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/index.md
A basic example of how to use the CatalogTile component.
```typescript
import { CatalogTile } from '@patternfly/react-catalog-view-extension';
```
--------------------------------
### Detailed Item View with Properties Panel
Source: https://github.com/patternfly/react-catalog-view/blob/main/_autodocs/examples.md
Display item details in a properties panel.
```typescript
import { PropertiesSidePanel, PropertyItem, CatalogItemHeader } from '@patternfly/react-catalog-view-extension';
const ITEM = {
id: 1,
name: 'PostgreSQL',
vendor: 'PostgreSQL Global Development Group',
version: '14.0',
license: 'PostgreSQL License',
description: 'A powerful, open source object-relational database system',
url: 'https://www.postgresql.org',
icon: '/images/postgres-icon.png'
};
export function ItemDetailsView() {
return (
{/* Main Content */}
{ITEM.description}
{/* Properties Panel */}
Official Site}
/>
Active}
/>
);
}
```
--------------------------------
### FilterSidePanel example
Source: https://github.com/patternfly/react-catalog-view/blob/main/packages/module/patternfly-docs/content/examples/FilterSidePanel.md
This is an example of how to use the FilterSidePanel component with various categories and items.
```javascript
import { FilterSidePanel, FilterSidePanelCategory, FilterSidePanelCategoryItem } from '@patternfly/react-catalog-view-extension';
import StarIcon from '@patternfly/react-icons/dist/esm/icons/star-icon';
import CcPaypalIcon from '@patternfly/react-icons/dist/esm/icons/cc-paypal-icon';
import CcAmexIcon from '@patternfly/react-icons/dist/esm/icons/cc-amex-icon';
import CcDiscoverIcon from '@patternfly/react-icons/dist/esm/icons/cc-discover-icon';
import CcVisaIcon from '@patternfly/react-icons/dist/esm/icons/cc-visa-icon';
import CcMastercardIcon from '@patternfly/react-icons/dist/esm/icons/cc-mastercard-icon';
import CcDinersClubIcon from '@patternfly/react-icons/dist/esm/icons/cc-diners-club-icon';
Item 1Item 2} isChecked>
Item 3
} isChecked>
Item 4
}>
Item 5
}>
Item 6
}>
Item 7
}>
Item 8
}>
Item 9
```