Skip to content

Commit b920ccc

Browse files
committed
update guidance ahead of workshop
1 parent ec0b5ca commit b920ccc

File tree

10 files changed

+394
-869
lines changed

10 files changed

+394
-869
lines changed

ai-documentation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Essential rules and guidelines for AI coders working with PatternFly React appli
1616
- [**PatternFly Guidelines**](./guidelines/README.md) - Core development principles
1717
- [**Component Rules**](./guidelines/component-architecture.md) - Component structure requirements
1818
- [**Styling Rules**](./guidelines/styling-standards.md) - CSS and styling requirements
19+
- [**Deployment Guide**](./guidelines/deployment-guide.md) - How to deploy prototypes
1920

2021
### 🧩 Component Rules
2122
- [**Layout Rules**](./components/layout/README.md) - Page structure requirements
@@ -31,7 +32,6 @@ Essential rules and guidelines for AI coders working with PatternFly React appli
3132

3233
### 📖 Resources
3334
- [**External Links**](./resources/external-links.md) - Official documentation links
34-
- [**Local Files**](./resources/local-files.md) - Project-specific resources
3535

3636
## Usage Rules for AI Coders
3737

ai-documentation/chatbot/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Essential rules for PatternFly Chatbot implementation and integration patterns.
44

55
## Related Files
66

7-
- [**Local Resources**](../resources/local-files.md) - Reference to patternfly-chatbot.txt
8-
- [**Component Architecture**](../guidelines/component-architecture.md) - Component structure guidelines
7+
- [**Component Architecture**](../guidelines/component-architecture.md) - Chatbot component structure rules
8+
- [**Styling Standards**](../guidelines/styling-standards.md) - CSS and styling best practices
99

1010
## Installation Rules
1111

@@ -188,4 +188,9 @@ const createMessage = (content, role) => ({
188188
- [PatternFly Chatbot on PatternFly.org](https://www.patternfly.org/patternfly-ai/chatbot/overview)
189189
- [PatternFly Chatbot GitHub Repository](https://github.com/patternfly/chatbot)
190190

191-
> For the most up-to-date documentation and code examples, consult both PatternFly.org and the official GitHub repository. When using AI tools, leverage context7 to fetch the latest docs from these sources.
191+
> For the most up-to-date documentation and code examples, consult both PatternFly.org and the official GitHub repository. When using AI tools, leverage context7 to fetch the latest docs from these sources.
192+
193+
### Further Reading
194+
- **[PatternFly Chatbot Docs](https://www.patternfly.org/chatbot/overview/)**
195+
- **[Component API](https://github.com/patternfly/patternfly-react/tree/main/packages/react-core/src/components/ChipGroup)** - ChipGroup component API for tags
196+
- **[Accessibility Guide](https://www.patternfly.org/get-started/accessibility-guide)**

ai-documentation/components/data-display/README.md

Lines changed: 46 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,14 @@ if (!data?.length) return <EmptyState><EmptyStateHeader titleText="No data" /></
9494
## Performance Rules
9595
9696
### Required Optimizations
97-
- ✅ **Use virtualization for 1000+ rows** - react-window library
9897
- ✅ **Use pagination for large datasets** - Better UX than virtualization
9998
- ✅ **Memoize table rows** - React.memo for performance
10099
- ✅ **Use useCallback for handlers** - Stable references
101100
102101
```jsx
103102
// ✅ Required for large datasets
104-
import { FixedSizeList as List } from 'react-window';
105103
import { Pagination } from '@patternfly/react-core';
106104

107-
// For 1000+ items, use virtualization
108-
<List height={400} itemCount={data.length} itemSize={50}>
109-
{Row}
110-
</List>
111-
112105
// For better UX, use pagination
113106
<Pagination itemCount={data.length} perPage={20} page={page} />
114107
```
@@ -155,127 +148,68 @@ import { Pagination } from '@patternfly/react-core';
155148
- **[Toolbar Component](https://www.patternfly.org/components/toolbar)** - Toolbar with filters
156149
- **[Dropdown Component](https://www.patternfly.org/components/menus/dropdown)** - Dropdown positioning
157150
158-
## Data View Component Rules
151+
## Using the Data View Component
159152
160-
PatternFly Data View provides a standardized way to present and interact with tabular or list-based data, following PatternFly design and accessibility guidelines.
153+
The `@patternfly/react-data-view` component is a powerful, opinionated tool for building consistent data-driven tables and lists. It composes standard PatternFly components like `Table`, `Toolbar`, and `Pagination` into a single, streamlined API.
161154
162-
### Installation
163-
```bash
164-
npm install @patternfly/react-data-view
165-
```
155+
### When to Use Data View
156+
- ✅ **Use for standard list pages**: When you need to display a list of resources with common functionality like filtering, sorting, selection, and actions.
157+
- ✅ **To enforce consistency**: Use it across your application to ensure all data tables look and behave the same.
158+
- ❌ **Not for highly custom layouts**: If your layout deviates significantly from a standard table or list view, composing individual PatternFly components may be a better approach.
166159
167-
### Required CSS Import
168-
```jsx
169-
import '@patternfly/react-data-view/dist/css/main.css';
170-
```
160+
## Data view documentation
161+
- **[Data view](https://www.patternfly.org/extensions/data-view/overview)** - Official data view documentation
162+
- **[Table Component](https://www.patternfly.org/extensions/data-view/table)** - Data view's table documentation and examples
163+
- **[Toolbar Component](https://www.patternfly.org/extensions/data-view/toolbar/)** - Data view's toolbar documentation and examples
171164
172-
### Import Pattern
173-
- ✅ **Use dynamic imports** from `/dist/dynamic/` paths
174-
- ❌ **Don't use standard imports**
175-
176-
```jsx
177-
// ✅ Correct
178-
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
179-
```
165+
### Required Setup
180166
181-
### Basic Usage Example
182-
```jsx
183-
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
167+
1. **Installation**:
168+
```bash
169+
npm install @patternfly/react-data-view
170+
```
184171
185-
<DataView
186-
data={data}
187-
columns={columns}
188-
onRowClick={handleRowClick}
189-
/>
190-
```
172+
2. **CSS Import**:
173+
```jsx
174+
// Import required CSS in your application's entrypoint
175+
import '@patternfly/react-data-view/dist/css/main.css';
176+
```
191177
192-
### Component API
193-
- Use PatternFly naming conventions for props (e.g., `variant`, `onClick`)
194-
- Extend PatternFly types when possible
195-
- Document all props and usage examples
196-
- Avoid unnecessary external dependencies
178+
3. **Component Import**:
179+
```jsx
180+
// Use dynamic imports for better performance
181+
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
182+
```
197183
198-
#### Example API Extension
199-
```ts
200-
// when possible, extend available PatternFly types
201-
export interface DataViewProps extends TableProps {
202-
customLabel?: string;
203-
}
184+
### Best Practices
204185
205-
export const DataView: React.FunctionComponent<DataViewProps> = ({ customLabel, ...props }) => ( /* ... */ );
206-
```
186+
- **Provide stable data and columns**: For performance, memoize the `data` and `columns` props passed to `DataView`, especially if they are derived from other state.
187+
```jsx
188+
const columns = useMemo(() => [...], []);
189+
const data = useMemo(() => [...], [sourceData]);
207190

208-
### Directory Structure
209-
```
210-
src
211-
|- DataView
212-
|- index.ts
213-
|- DataView.tsx
214-
```
191+
<DataView data={data} columns={columns} />
192+
```
215193
216-
### OUIA ID Convention
217-
For testing, use the component name as the default OUIA ID, and for subcomponents, use `ComponentName-element-specification`.
218-
```ts
219-
ouiaId="DataView-actions-button"
220-
```
194+
- **Leverage the built-in toolbar**: `DataView` includes a `Toolbar` with filtering capabilities. Provide filter configurations instead of building your own toolbar from scratch.
221195
222-
### Testing & Linting
223-
- Add unit tests to `DataView.test.tsx`
224-
- Add Cypress component/E2E tests to `cypress/component/DataView.cy.tsx` and `cypress/e2e/DataView.spec.cy.ts`
225-
- Run tests and linting:
226-
```bash
227-
npm run test
228-
npm run lint
229-
```
196+
- **Use the provided action resolver**: For row actions, use the `onRowAction` prop and provide an action resolver function. This ensures actions are handled consistently.
230197
231-
### Accessibility
232-
- Provide proper ARIA labels and roles
233-
- Ensure keyboard navigation and screen reader support
234-
- Run accessibility tests:
235-
```bash
236-
npm run build:docs
237-
npm run serve:docs
238-
npm run test:a11y
239-
npm run serve:a11y
240-
```
241-
242-
### Documentation Example (Markdown)
243-
```md
244-
---
245-
section: extensions
246-
subsection: Data view
247-
id: DataView
248-
propComponents: ['DataView']
249-
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md
250-
---
251-
252-
import DataView from "@patternfly/react-data-view/dist/dynamic/DataView";
198+
### Real-World Example: OpenShift Console
253199
254-
## Component usage
200+
A production example of PatternFly Data View usage can be found in the OpenShift Console codebase. It's an excellent resource for seeing how `DataView` is integrated with live Kubernetes data and Redux for state management.
255201
256-
<DataView ... />
202+
- **[DataViewPodList.tsx on GitHub](https://github.com/openshift/console/blob/79d29bca8440a5ad82b5257bb0f37bc24384eb0e/frontend/public/components/data-view-poc/DataViewPodList.tsx)**
257203
258-
### DataView component example label
204+
Key integration patterns from this example include:
205+
- Integrating Data View with live Kubernetes data and application state.
206+
- Passing dynamic data and columns to the component.
207+
- Handling loading, error, and empty states in a production context.
208+
- Using PatternFly composable components for custom row rendering and actions.
209+
- Connecting Data View to Redux or other state management solutions.
259210
260-
```js file="./DataViewExample.tsx"```
261-
```
211+
> For advanced usage, review the linked file to see how Data View is composed with other PatternFly and application-specific components.
262212
263-
### References
213+
> **Note:** Always consult the latest PatternFly Data View documentation and demo source code for the most up-to-date usage patterns and best practices.
264214
- [PatternFly React Data View GitHub](https://github.com/patternfly/react-data-view)
265-
- [PatternFly Data View NPM](https://www.npmjs.com/package/@patternfly/react-data-view)
266-
267-
> **Note:** Always consult the latest PatternFly Data View documentation and demo source code for up-to-date usage patterns and best practices.
268-
269-
### Real-World Example: OpenShift Console
270-
271-
A production example of PatternFly Data View usage can be found in the OpenShift Console codebase:
272-
- [DataViewPodList.tsx on GitHub](https://github.com/openshift/console/blob/79d29bca8440a5ad82b5257bb0f37bc24384eb0e/frontend/public/components/data-view-poc/DataViewPodList.tsx)
273-
274-
**Key integration patterns and best practices from this example:**
275-
- Integrates Data View with live Kubernetes data (pods) and application state.
276-
- Demonstrates how to pass dynamic data and columns to the Data View component.
277-
- Shows how to handle loading, error, and empty states in a real product context.
278-
- Illustrates the use of PatternFly composable components for custom row rendering and actions.
279-
- Provides a template for connecting Data View to Redux or other state management solutions.
280-
281-
> For advanced usage, review the linked file to see how Data View is composed with other PatternFly and application-specific components.
215+
- [PatternFly Data View NPM](https://www.npmjs.com/package/@patternfly/react-data-view)

ai-documentation/components/data-display/table.md

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,94 @@ const isPartiallySelected = selectedItems.size > 0 && selectedItems.size < data.
6262
/>
6363
```
6464

65+
## Column and Header Management
66+
67+
PatternFly provides powerful props for controlling column widths and making headers and columns "sticky" for better usability with wide or long tables.
68+
69+
### Column Width Control
70+
Use the `width` modifier on the `<Th>` component to specify column widths as a percentage of the table's total width.
71+
72+
-**Use `width(percentage)`**: Best for flexible, responsive layouts.
73+
-**Avoid fixed pixel widths**: Can break responsiveness.
74+
75+
```jsx
76+
import { Table, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';
77+
import { width } from '@patternfly/react-table';
78+
79+
<Table>
80+
<Thead>
81+
<Tr>
82+
<Th width={40}>User ID</Th>
83+
<Th width={30}>Name</Th>
84+
<Th width={30}>Email</Th>
85+
</Tr>
86+
</Thead>
87+
<Tbody>
88+
{/* ... */}
89+
</Tbody>
90+
</Table>
91+
```
92+
93+
### Controlling Text and Column Width
94+
In addition to setting explicit widths, you can control how text behaves within cells using the `modifier` prop on `<Th>` and `<Td>` components. This influences column dimensions and text overflow.
95+
96+
Key text modifiers include:
97+
- **`truncate`**: Truncates text with an ellipsis.
98+
- **`wrap`**: Forces text to wrap, which is useful for long header text.
99+
- **`nowrap`**: Prevents text from wrapping.
100+
- **`breakWord`**: Forces long, unbreakable strings (like URLs) to break.
101+
- **`fitContent`**: Shrinks the column to fit its content.
102+
103+
For detailed usage and code examples, see the official PatternFly documentation and the example in the PatternFly React repository.
104+
105+
- [**Controlling Text in Tables (PatternFly Docs)**](https://www.patternfly.org/components/table/controlling-text)
106+
- [**TableControllingText.tsx Example on GitHub**](https://github.com/patternfly/patternfly-react/blob/main/packages/react-table/src/components/Table/examples/TableControllingText.tsx)
107+
108+
### Sticky Headers and Columns
109+
For tables that scroll horizontally or vertically, you can make the header, specific columns, or the action column "sticky."
110+
111+
- **`isStickyHeader`**: Add this prop to the `<Table>` component to make the header row stick to the top during vertical scrolling.
112+
- **`isSticky`**: Add this prop to a `<Th>` or `<Td>` component to make an entire column sticky during horizontal scrolling. This is commonly used for the first column (e.g., selection checkbox or ID), or last column (e.g. columns containing actions menus).
113+
114+
```jsx
115+
// ✅ Sticky header, first column, and action column
116+
import { Table, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table';
117+
118+
<Table isStickyHeader>
119+
<Thead>
120+
<Tr>
121+
<Th isSticky>ID</Th>
122+
<Th>Name</Th>
123+
{/* ... more columns */}
124+
<Th>Actions</Th>
125+
</Tr>
126+
</Thead>
127+
<Tbody>
128+
{data.map(item => (
129+
<Tr key={item.id}>
130+
<Td isSticky>{item.id}</Td>
131+
<Td>{item.name}</Td>
132+
{/* ... more cells */}
133+
<Td isSticky>
134+
<ActionsDropdown />
135+
</Td>
136+
</Tr>
137+
))}
138+
</Tbody>
139+
</Table>
140+
```
141+
65142
## Performance Rules
66-
-**Use virtualization for 1000+ rows** - react-window library
143+
-**Use Skeleton for loading states** - Provide visual feedback
144+
-**Ensure responsive behavior** - Test on multiple screen sizes
67145
-**Use pagination for large datasets** - Better UX than virtualization
68146
-**Memoize table rows** - React.memo for performance
69147
-**Use useCallback for handlers** - Stable references
70148

71149
```jsx
72150
// ✅ Required for large datasets
73-
import { FixedSizeList as List } from 'react-window';
74151
import { Pagination } from '@patternfly/react-core';
75152

76-
// For 1000+ items, use virtualization
77-
<List height={400} itemCount={data.length} itemSize={50}>
78-
{Row}
79-
</List>
80-
81153
// For better UX, use pagination
82154
<Pagination itemCount={data.length} perPage={20} page={page} />
83155
```
@@ -109,11 +181,6 @@ import { Pagination } from '@patternfly/react-core';
109181
<Dropdown popperProps={{ appendTo: () => document.body }}>
110182
```
111183

112-
### Performance Issues
113-
- **1000+ rows**: Use virtualization with react-window
114-
- **Large datasets**: Implement pagination
115-
- **Slow rendering**: Memoize components with React.memo
116-
117184
### Selection Issues
118185
- **Use Set not Array**: More efficient for selection state
119186
- **Handle indeterminate**: For "select all" checkbox state

0 commit comments

Comments
 (0)