Skip to content

Commit 376b249

Browse files
authored
Merge pull request #1 from jeff-phillips-18/ai_enabled
Update AI documentation with various fixes and additions
2 parents 5ff6f3e + 3f9fc32 commit 376b249

File tree

7 files changed

+202
-29
lines changed

7 files changed

+202
-29
lines changed

.cursor/rules/patternfly-vibe-coding.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This rule applies to all code generation, refactoring, and review tasks involvin
1313

1414
## Documentation to Reference
1515
- The root `README.md`
16-
- The `documentation/README.md` file, which serves as the table of contents for all documentation in the `documentation/` directory and its subdirectories. Use this file to discover and navigate all relevant rules, guidelines, and best practices for PatternFly development.
17-
- All markdown files referenced by `documentation/README.md`.
16+
- The `ai-documentation/README.md` file, which serves as the table of contents for all documentation in the `ai-documentation/` directory and its subdirectories. Use this file to discover and navigate all relevant rules, guidelines, and best practices for PatternFly development.
17+
- All markdown files referenced by `ai-documentation/README.md`.
1818

1919
## Rule
2020
- **Always consult the above documentation before generating or editing any PatternFly code.**

ai-documentation/charts/README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ npm install @patternfly/react-charts victory
1515

1616
# ✅ ECharts-based charts (alternative)
1717
npm install @patternfly/react-charts echarts
18+
19+
# ✅ Patternfly for charts css variables (recommended)
20+
npm install @patternfly/patternfly
1821
```
1922

2023
### Import Rules
@@ -31,6 +34,12 @@ import { EChart } from '@patternfly/react-charts/echarts';
3134
import { ChartDonut } from '@patternfly/react-charts';
3235
```
3336

37+
### Import PatternFly Charts CSS
38+
```jsx
39+
// In your main App.js or index.js
40+
import '@patternfly/patternfly/patternfly-charts.css';
41+
```
42+
3443
### Critical Import Path Troubleshooting
3544

3645
**⚠️ MOST COMMON ISSUE**: Chart components cannot be found
@@ -77,9 +86,9 @@ Module not found: Can't resolve '@patternfly/react-charts'
7786
```jsx
7887
// ✅ Correct - Use PatternFly color tokens
7988
const chartColors = [
80-
'var(--pf-v6-chart-color-blue-300)',
81-
'var(--pf-v6-chart-color-green-300)',
82-
'var(--pf-v6-chart-color-orange-300)'
89+
'var(--pf-t--chart--color--blue--300)',
90+
'var(--pf-t--chart--color--green--300)',
91+
'var(--pf-t--chart--color--orange--300)'
8392
];
8493
8594
<ChartDonut data={data} colorScale={chartColors} />
@@ -210,6 +219,23 @@ const LazyChart = lazy(() => import('./HeavyChart'));
210219
- **Implement lazy loading**: For heavy chart components
211220
- **Optimize re-renders**: Use React.memo for chart components
212221
222+
#### Issue: Chart colors not correct
223+
```bash
224+
# Symptoms: Chart color variables (--pf-v6-chart-color-blue-100, --pf-t--chart--color--blue--300) are not defined
225+
```
226+
227+
**Solutions**:
228+
1. **Install patternfly package**:
229+
```bash
230+
npm install @patternfly/patternfly
231+
```
232+
233+
2. **Import PatternFly Charts CSS**:
234+
```jsx
235+
// In your main App.js or index.js
236+
import '@patternfly/patternfly/patternfly-charts.css';
237+
```
238+
213239
## Quick Reference
214240
- **[PatternFly Charts README](https://github.com/patternfly/patternfly-react/tree/main/packages/react-charts#readme)** - Installation and usage
215241
- **[Victory.js Documentation](https://formidable.com/open-source/victory/)** - Chart library documentation

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,11 @@ Key integration patterns from this example include:
212212
213213
> **Note:** Always consult the latest PatternFly Data View documentation and demo source code for the most up-to-date usage patterns and best practices.
214214
- [PatternFly React Data View GitHub](https://github.com/patternfly/react-data-view)
215-
- [PatternFly Data View NPM](https://www.npmjs.com/package/@patternfly/react-data-view)
215+
- [PatternFly Data View NPM](https://www.npmjs.com/package/@patternfly/react-data-view)
216+
217+
## Empty State Button Placement Rules
218+
219+
- ✅ **Place all buttons in an EmptyState inside the `EmptyStateFooter` component.**
220+
- ✅ **Group each row of buttons within an `EmptyStateActions` container inside the `EmptyStateFooter`.**
221+
- ✅ **Use a separate `EmptyStateActions` for each row of actions if multiple rows are needed.**
222+
- ❌ **Do not place buttons directly inside `EmptyState` or `EmptyStateBody`.**

ai-documentation/guidelines/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Core development rules for AI coders building PatternFly React applications.
2222
-**Compose components** - Build complex UIs by combining PatternFly components
2323
-**Don't override component internals** - Use provided props and APIs
2424

25+
### Tokenss
26+
-**ALWAYS use PatternFly tokens** - Use `pf-t-` prefixed classes over `pf-v6-` classes (e.g., `var(--pf-t--global--spacer--sm)` not `var(--pf-v6-global--spacer--sm)`)
27+
2528
### Text Components (v6+)
2629
```jsx
2730
// ✅ Correct
@@ -43,7 +46,7 @@ import { UserIcon } from '@patternfly/react-icons';
4346
### Styling Rules
4447

4548
-**Use PatternFly utilities** - Before writing custom CSS
46-
-**Use semantic design tokens** for custom CSS (e.g., `var(--pf-v6-global--primary-color--light)`), not base tokens with numbers (e.g., `--pf-v6-global--Color--100`) or hardcoded values
49+
-**Use semantic design tokens** for custom CSS (e.g., `var(--pf-t--global--text--color--regular)`), not base tokens with numbers (e.g., `--pf-t--global--text--color--100`) or hardcoded values
4750
-**Don't mix PatternFly versions** - Stick to v6 throughout
4851

4952
### Documentation Requirements

ai-documentation/guidelines/styling-standards.md

Lines changed: 111 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ Essential CSS and styling rules for PatternFly React applications.
1111

1212
### PatternFly v6 Requirements
1313
-**ALWAYS use `pf-v6-` prefix** - All PatternFly v6 classes
14-
-**NEVER use legacy prefixes** - No `pf-v5-`, `pf-v4-`, or `pf-c-`
14+
-**NEVER use legacy prefixes** - No `pf-v5-`, `pf-v4-`, `pf-u` or `pf-c-`
1515

1616
```css
1717
/* ✅ Correct v6 classes */
1818
.pf-v6-c-button /* Components */
19-
.pf-v6-u-margin-md /* Utilities */
19+
.pf-v6-u-m-md /* Utilities */
2020
.pf-v6-l-grid /* Layouts */
2121

2222
/* ❌ Wrong - Don't use these */
2323
.pf-v5-c-button
24+
.pf-u-m-md
2425
.pf-c-button
2526
```
2627

@@ -39,8 +40,8 @@ Essential CSS and styling rules for PatternFly React applications.
3940
</PageSection>
4041

4142
// ❌ Wrong - Utility classes for basic layout
42-
<div className="pf-v6-u-margin-md">
43-
<div className="pf-v6-u-margin-bottom-sm">Dashboard</div>
43+
<div className="pf-v6-u-m-md">
44+
<div className="pf-v6-u-mb-sm">Dashboard</div>
4445
<div>Dashboard content</div>
4546
</div>
4647
```
@@ -62,8 +63,8 @@ Essential CSS and styling rules for PatternFly React applications.
6263
</ActionGroup>
6364

6465
// ❌ Wrong - Utility classes when component props exist
65-
<Table className="pf-v6-u-margin-md">
66-
<Button className="pf-v6-u-margin-right-sm">Save</Button>
66+
<Table className="pf-v6-u-m-md">
67+
<Button className="pf-v6-u-mr-sm">Save</Button>
6768
<Button>Cancel</Button>
6869
</Table>
6970
```
@@ -104,7 +105,7 @@ Use utility classes only when:
104105

105106
```jsx
106107
// ✅ Acceptable utility usage - when component props aren't sufficient
107-
<Card className="pf-v6-u-height-100"> {/* Force card to full height */}
108+
<Card className="pf-v6-u-h-100"> {/* Force card to full height */}
108109
<CardBody>
109110
<Text className="pf-v6-u-text-align-center"> {/* Center text when component doesn't provide prop */}
110111
Centered content
@@ -116,35 +117,35 @@ Use utility classes only when:
116117
## Design Token Rules
117118

118119
### Use Semantic PatternFly Tokens for Custom CSS
119-
- ✅ **Use semantic tokens** (e.g., `--pf-v6-global--primary-color--light`) for custom CSS. These tokens do not end in numbers and are intended for application-level styling.
120-
- ❌ **Don't use base tokens** (which end in numbers, e.g., `--pf-v6-global--Color--100`) for custom CSS. Base tokens are for internal PatternFly use and may change.
120+
- ✅ **Use semantic tokens** (e.g., `--pf-t--global--text--color--regular`) for custom CSS. These tokens do not end in numbers and are intended for application-level styling.
121+
- ❌ **Don't use base tokens** (which end in numbers, e.g., `--pf-t--global--text--color--100`) for custom CSS. Base tokens are for internal PatternFly use and may change.
121122

122123
```css
123124
.custom-component {
124125
/* ✅ Correct - Use semantic tokens */
125-
color: var(--pf-v6-global--primary-color--light);
126-
margin: var(--pf-v6-global--spacer--md);
126+
color: var(--pf-t--global--text--color--regular);
127+
margin: var(--pf-t-global--spacer--md);
127128

128129
/* ❌ Wrong - Hardcoded values or base tokens */
129130
/* color: #333333; */
130-
/* color: var(--pf-v6-global--Color--100); */
131+
/* color: var`--pf-t--global--text--color--100); */
131132
/* margin: 16px; */
132133
}
133134
```
134135

135136
### Essential Token Categories
136137
```css
137138
/* Semantic Colors */
138-
--pf-v6-global--primary-color--light
139-
--pf-v6-global--primary-color--dark
140-
--pf-v6-global--background-color--light
139+
--pf-t--global--text--color--regular
140+
--pf-t--global--text--color--subtle
141+
--pf-t--global--background--color--primary--default
141142

142143
/* Spacing */
143-
--pf-v6-global--spacer--{xs|sm|md|lg|xl}
144+
--pf-t-global--spacer--{xs|sm|md|lg|xl}
144145

145146
/* Typography */
146-
--pf-v6-global--FontFamily--text
147-
--pf-v6-global--FontSize--md
147+
--pf-t--global--font--family--body
148+
--pf-t--global--font--size--md
148149
```
149150

150151
## Responsive Design Rules
@@ -324,4 +325,95 @@ import { Title, Content } from '@patternfly/react-core';
324325

325326
---
326327

327-
> **Note:** `PageHeader` is not a PatternFly component in v6+. Use `PageSection`, `Title`, and layout components instead.
328+
> **Note:** `PageHeader` is not a PatternFly component in v6+. Use `PageSection`, `Title`, and layout components instead.
329+
330+
## Spacing and Inline Styles
331+
332+
-**Always use PatternFly spacing variables (design tokens) for all spacing, including in inline style props.**
333+
-**Do not use hardcoded numbers for margin, padding, or other spacing in inline styles.**
334+
335+
**Correct:**
336+
```jsx
337+
<div style={{ marginBottom: 'var(--pf-t--global--spacer-lg)' }} />
338+
```
339+
340+
**Incorrect:**
341+
```jsx
342+
<div style={{ marginBottom: 24 }} />
343+
```
344+
345+
## Utility Classes vs Inline Styles
346+
347+
-**Prefer using PatternFly utility classes for spacing, alignment, and layout instead of inline styles.**
348+
-**Only use inline styles if a PatternFly utility class does not exist for the required spacing or layout.**
349+
350+
**Correct:**
351+
```jsx
352+
<div className="pf-v6-u-mb-lg" />
353+
```
354+
355+
**Incorrect:**
356+
```jsx
357+
<div style={{ marginBottom: 'var(--pf-t--global--spacer-lg)' }} />
358+
```
359+
360+
## External Link Buttons
361+
362+
-**Always add an external link icon to the right of the text for external link buttons.**
363+
-**Do not omit the external link icon for buttons that open external sites.**
364+
365+
**Correct:**
366+
```jsx
367+
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
368+
<Button
369+
variant="link"
370+
component="a"
371+
href="https://patternfly.org"
372+
target="_blank"
373+
rel="noopener noreferrer"
374+
icon={<ExternalLinkAltIcon />}
375+
iconPosition="right"
376+
>
377+
Learn more
378+
</Button>
379+
```
380+
381+
**Incorrect:**
382+
```jsx
383+
<Button
384+
variant="link"
385+
component="a"
386+
href="https://patternfly.org"
387+
target="_blank"
388+
rel="noopener noreferrer"
389+
>
390+
Learn more
391+
</Button>
392+
```
393+
394+
## Toolbar Alignment
395+
396+
-**When right-aligning content in a PatternFly Toolbar, use the ToolbarItem align={{ default: 'alignEnd' }} prop.**
397+
-**Do not use custom Flex wrappers or utility classes to right-align Toolbar content.**
398+
399+
**Correct:**
400+
```jsx
401+
<Toolbar>
402+
<ToolbarContent>
403+
<ToolbarItem>Left content</ToolbarItem>
404+
<ToolbarItem align={{ default: 'alignEnd' }}>Right-aligned content</ToolbarItem>
405+
</ToolbarContent>
406+
</Toolbar>
407+
```
408+
409+
**Incorrect:**
410+
```jsx
411+
<Toolbar>
412+
<ToolbarContent>
413+
<ToolbarItem>Left content</ToolbarItem>
414+
<Flex style={{ flex: 1 }} justifyContent={{ default: 'justifyContentFlexEnd' }}>
415+
<FlexItem>Right-aligned content</FlexItem>
416+
</Flex>
417+
</ToolbarContent>
418+
</Toolbar>
419+
```

ai-documentation/resources/external-links.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ External resources are essential for staying current with PatternFly updates, fi
2929
- **[Page Component](https://www.patternfly.org/components/page)** - Page layout and structure
3030
- **[Icon Component](https://www.patternfly.org/components/icon)** - Icon usage and sizing
3131

32+
### Utility Classes Documentation
33+
- **[Accessibility](https://www.patternfly.org/utility-classes/accessibility)** - Accessibilty utility classes
34+
- **[Alignment](https://www.patternfly.org/utility-classes/alignment)** - Alignment utility classes
35+
- **[Background color](https://www.patternfly.org/utility-classes/background-color)** - Background utility classes
36+
- **[Box shadow](https://www.patternfly.org/utility-classes/box-shadow)** - Box shadow utility classes
37+
- **[Display](https://www.patternfly.org/utility-classes/accessibility)** - Display utility classes
38+
- **[Flex](https://www.patternfly.org/utility-classes/flex)** - Flex utility classes
39+
- **[Float](https://www.patternfly.org/utility-classes/float)** - Float utility classes
40+
- **[Sizing](https://www.patternfly.org/utility-classes/sizing)** - Sizing utility classes
41+
- **[Spacing](https://www.patternfly.org/utility-classes/spacing)** - Spacing utility classes
42+
- **[Text](https://www.patternfly.org/utility-classes/text)** - Text utility classes
43+
44+
3245
### Specialized Features
3346
- **[PatternFly Charts](https://www.patternfly.org/charts/about)** - Data visualization guidelines
3447
- **[PatternFly AI - Chatbot](https://www.patternfly.org/patternfly-ai/chatbot/overview)** - AI chatbot components

ai-documentation/troubleshooting/common-issues.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ PatternFly development can present various challenges ranging from setup issues
5757
2. **Use CSS-in-JS for custom styles**:
5858
```jsx
5959
// ✅ Alternative - Inline styles when utilities don't exist
60-
<div style={{ margin: 'var(--pf-v6-global--spacer--md)' }}>
60+
<div style={{ margin: 'var(--pf-t--global--spacer--md)' }}>
6161
```
6262

6363
#### Issue: AI uses inline styles instead of PatternFly utilities
@@ -82,8 +82,8 @@ PatternFly development can present various challenges ranging from setup issues
8282
```jsx
8383
// ✅ Only when component composition isn't sufficient
8484
<div style={{
85-
margin: 'var(--pf-v6-global--spacer--md)',
86-
color: 'var(--pf-v6-global--primary-color--light)'
85+
margin: 'var(--pf-t--global--spacer--md)',
86+
color: 'var(--pf-t--global--text--color--regular)'
8787
}}>
8888
```
8989

@@ -538,6 +538,38 @@ Module not found: Can't resolve '@patternfly/chatbot/dist/dynamic/Chatbot'
538538
<Button variant="primary">Click me</Button>
539539
```
540540

541+
#### Issue: PatternFly utility class styles not applied
542+
```bash
543+
# Symptoms: Adding utility classes (pf-v6-u-*) do not have any apparent effect
544+
```
545+
546+
**Solutions**:
547+
1. **Install patternfly package**:
548+
```bash
549+
npm install @patternfly/patternfly
550+
```
551+
552+
2. **Import PatternFly Utility CSS**:
553+
```jsx
554+
// In your main App.js or index.js
555+
import '@patternfly/patternfly/patternfly-addons.css';
556+
```
557+
558+
3. **Verify webpack CSS handling**:
559+
```javascript
560+
// webpack.config.js
561+
module.exports = {
562+
module: {
563+
rules: [
564+
{
565+
test: /\.css$/,
566+
use: ['style-loader', 'css-loader']
567+
}
568+
]
569+
}
570+
};
571+
```
572+
541573
### Layout and Responsive Issues
542574

543575
#### Issue: Components not responsive

0 commit comments

Comments
 (0)