-
Notifications
You must be signed in to change notification settings - Fork 267
feat(patternfly): add PatternFly migration plugin #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d9172ba
cf5f44f
bd5abca
54e272b
95100b4
bbf1ce7
cf22178
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "patternfly", | ||
| "description": "PatternFly v5 to v6 migration and glass theme implementation", | ||
| "version": "1.2.0", | ||
| "author": { | ||
| "name": "github.com/openshift-eng" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| approvers: | ||
| - anandkuma77 | ||
| reviewers: | ||
| - anandkuma77 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # PatternFly Plugin | ||
|
|
||
| A Claude Code plugin for migrating and working with PatternFly React components. | ||
|
|
||
| ## Overview | ||
|
|
||
| PatternFly is Red Hat's open source design system for enterprise product experiences. This plugin helps developers migrate from PatternFly v5 to v6 and implement modern glass theme (glassmorphism) effects in React applications. | ||
|
|
||
| ## Commands | ||
|
|
||
| ### `/patternfly:migrate` | ||
|
|
||
| Migrate React components from PatternFly 5 to PatternFly 6. | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| /patternfly:migrate [file-path] | ||
| ``` | ||
|
|
||
| **Examples:** | ||
| ```bash | ||
| # Migrate a specific file | ||
| /patternfly:migrate src/components/Dashboard.tsx | ||
|
|
||
| # Migrate current working directory | ||
| /patternfly:migrate | ||
| ``` | ||
|
|
||
| **What it does:** | ||
| - Analyzes code for PatternFly v5 patterns | ||
| - Applies automated migrations for component renames, prop updates, and import changes | ||
| - Identifies manual updates needed for structural changes | ||
| - Provides testing recommendations | ||
|
|
||
| ## Skills | ||
|
|
||
| ### `pf-react-migration` | ||
|
|
||
| Migrate PatternFly React components, CSS classes, and tokens from v5 to v6. | ||
|
|
||
| **Coverage includes:** | ||
| - React component and prop migrations (Text → Content, Chip → Label, prop renames) | ||
| - CSS class migrations (pf-v5-* → pf-v6-*, legacy classes) | ||
| - Token migrations (--pf-global-* → --pf-t--*) | ||
| - Import path updates and deprecated component guidance | ||
| - Automated codemod integration | ||
| - Actionable scan commands for finding migration issues | ||
|
|
||
| ### `pf-glass-theme` | ||
|
|
||
| Enable PatternFly 6 glass theme (glassmorphism) for React applications. | ||
|
|
||
| **Features:** | ||
| - Add `.pf-v6-theme-glass` class to enable glass effects | ||
| - Global or component-level glass theme support | ||
| - Optional runtime theme toggle component | ||
| - Dark mode compatibility (`.pf-v6-theme-glass.pf-v6-theme-dark`) | ||
| - Glass token usage examples (backdrop blur, transparency) | ||
| - Template components for glass UI patterns | ||
|
|
||
| ## Installation | ||
|
|
||
| This plugin is part of the `ai-helpers` repository and is automatically available when the repository is loaded. | ||
|
|
||
| ## Related Tools | ||
|
|
||
| The plugin complements these official PatternFly migration tools: | ||
|
|
||
| - **[@patternfly/pf-codemods](https://github.com/patternfly/pf-codemods)** - Automated code transformations | ||
| - **@patternfly/class-name-updater** - CSS class name updates | ||
| - **@patternfly/css-vars-updater** - CSS variable migrations | ||
|
|
||
| Use this plugin for: | ||
| - AI-assisted analysis of complex migration scenarios | ||
| - One-off component migrations | ||
| - Understanding breaking changes | ||
| - Migration planning and strategy | ||
|
|
||
| Use official codemods for: | ||
| - Comprehensive codebase-wide migrations | ||
| - Batch processing of many files | ||
| - Standardized transformations | ||
|
|
||
| ## Resources | ||
|
|
||
| - [PatternFly v6 Documentation](https://www.patternfly.org/) | ||
| - [Migration Guide](https://www.patternfly.org/get-started/upgrade/) | ||
| - [Token Reference](https://www.patternfly.org/tokens/all-patternfly-tokens) | ||
| - [Component Examples](https://www.patternfly.org/components/all-components) | ||
|
|
||
| ## Contributing | ||
|
|
||
| See the main [CLAUDE.md](../../CLAUDE.md) for contribution guidelines. | ||
|
|
||
| When adding new commands or skills: | ||
| 1. Bump version in `.claude-plugin/plugin.json` | ||
| 2. Run `make lint` to validate | ||
| 3. Run `make update` to sync marketplace.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| --- | ||
| description: Migrate PatternFly v5 to v6 (React components, CSS classes, tokens) | ||
| argument-hint: "[file-path]" | ||
| skill: pf-react-migration | ||
| --- | ||
|
|
||
| ## Name | ||
| patternfly:migrate | ||
|
|
||
| ## Synopsis | ||
| ``` | ||
| /patternfly:migrate [file-path] | ||
| ``` | ||
|
Comment on lines
+11
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language specifiers to code blocks. The code blocks in Synopsis and Examples sections should specify 📝 Proposed fix ## Synopsis
-```
+```bash
/patternfly:migrate [file-path] 2. **Migrate current working directory**:
- ```
+ ```bash
/patternfly:migrate
``` 3. **Analyze before migrating**:
- ```
+ ```bash
/patternfly:migrate src/components --dry-run
```Also applies to: 62-64, 68-70, 74-77 🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 11-11: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||
|
|
||
| ## Description | ||
| The `patternfly:migrate` command migrates PatternFly v5 to v6 across React components, CSS classes, and design tokens. It scans for legacy patterns, applies fixes, and identifies items requiring manual updates. | ||
|
|
||
| This command provides: | ||
| - Automated detection of v5 patterns (components, CSS classes, tokens) | ||
| - Actionable scan commands using ripgrep for remaining issues | ||
| - Integration guidance for official @patternfly codemods | ||
| - Clear output with file:line references and confidence levels | ||
|
|
||
| ## Implementation | ||
| The command uses the `pf-react-migration` skill to: | ||
|
|
||
| 1. **Scan** for PatternFly v5 patterns using ripgrep commands | ||
| 2. **Categorize** findings: React code, CSS classes, tokens, deprecated components | ||
| 3. **Guide** codemod usage: pf-codemods, class-name-updater, css-vars-updater | ||
| 4. **Apply** manual fixes for non-automatable changes | ||
| 5. **Report** with confidence levels and testing recommendations | ||
|
|
||
| Follows the concise, actionable pattern of the pf-class-migration-scanner skill. | ||
|
|
||
| ## Migration Scope | ||
|
|
||
| ### React Components & Props | ||
| - Component replacements: Text/TextContent → Content, Chip → Label, KebabToggle → MenuToggle | ||
| - Prop updates: isActive → isClicked, labelIcon → labelHelp | ||
| - Import paths: Charts /victory, deprecated → /deprecated | ||
| - Toolbar chip → label prop renames | ||
|
|
||
| ### CSS Classes & Tokens | ||
| - Legacy classes: pf-v5-*, pf-v4-*, pf-c-*, pf-u-*, pf-l-* | ||
| - Legacy tokens: --pf-v6-*, --pf-global-* → --pf-t--* (semantic) | ||
| - Color tokens requiring manual updates | ||
|
|
||
| ### Manual Verification Required | ||
| - Markup changes (EmptyState, Masthead, Button icons) | ||
| - Deprecated components (ApplicationLauncher, old Dropdown/Select, PageHeader, Tile) | ||
| - UI testing and accessibility | ||
|
|
||
| ## Return Value | ||
| - **Scan results**: File paths, current patterns, PF6 replacements | ||
| - **Confidence levels**: high/medium/low for each finding | ||
| - **Code changes**: Applied fixes with explanations (Why + How to apply) | ||
| - **Manual updates**: Items requiring manual verification with testing guidance | ||
|
|
||
| ## Examples | ||
|
|
||
| 1. **Migrate a single component file**: | ||
| ``` | ||
| /patternfly:migrate src/components/Dashboard.tsx | ||
| ``` | ||
| Analyzes and migrates PatternFly components in Dashboard.tsx | ||
|
|
||
| 2. **Migrate current working directory**: | ||
| ``` | ||
| /patternfly:migrate | ||
| ``` | ||
| Scans and migrates PatternFly v5 patterns in all files from the current directory | ||
|
|
||
| 3. **Analyze before migrating**: | ||
| ``` | ||
| /patternfly:migrate src/components --dry-run | ||
| ``` | ||
| Shows migration plan without applying changes (if user wants to review first) | ||
|
|
||
| ## Arguments | ||
| - `$1`: (Optional) File path or directory to migrate. If not provided, analyzes the current context or prompts for clarification. | ||
|
|
||
| ## Related Commands | ||
| After running migrations, consider: | ||
| - Running the official codemods: `npx @patternfly/pf-codemods --v6 --fix ./src` | ||
| - Updating CSS class names: `npx @patternfly/class-name-updater --v6 --fix ./src` | ||
| - Updating CSS variables: `npx @patternfly/css-vars-updater --fix ./src` | ||
| - Running tests to verify functionality | ||
|
|
||
| ## Notes | ||
| - This command complements but does not replace the official `@patternfly/pf-codemods` tool | ||
| - Use AI analysis for complex cases and one-off migrations | ||
| - Use official codemods for comprehensive codebase-wide migrations | ||
| - Always test migrated components, especially for markup changes | ||
| - Review color token replacements (watch for `t_temp_dev_tbd` placeholders) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| name: pf-react-migration | ||
| description: Migrate PatternFly React components from v5 to v6. Scans for component renames, prop updates, and import changes. | ||
| --- | ||
|
|
||
| # PatternFly React Migration | ||
|
|
||
| Migrate PatternFly React components from version 5 to version 6. | ||
|
|
||
| Query the PatternFly MCP server when migration recommendations are ambiguous to verify the latest supported component patterns and tokens. | ||
|
|
||
| ## Migration scope | ||
|
|
||
| ### React Components and Props | ||
| - Component renames: `Text`/`TextContent`/`TextList` → `Content`, `Chip` → `Label`, `KebabToggle` → `MenuToggle` | ||
| - Prop updates: `isActive` → `isClicked`, `labelIcon` → `labelHelp`, `isOverflowLabel` → `variant="overflow"` | ||
| - Import paths: Charts `/victory`, deprecated → `/deprecated`, promoted "next" components to base | ||
| - Toolbar: Chip props → Label props (`deleteChip` → `deleteLabel`) | ||
| - Color props: `cyan` → `teal`, `gold` → `yellow` | ||
|
|
||
| ### CSS Classes and Tokens | ||
| - Legacy versioned classes: `pf-v5-*`, `pf-v4-*` | ||
| - Unversioned legacy classes: `pf-c-*`, `pf-u-*`, `pf-l-*` | ||
| - Legacy token patterns: `--pf-v6-*`, `--pf-global-*` → `--pf-t--*` (semantic tokens) | ||
|
|
||
| ### Deprecated Components | ||
| - ApplicationLauncher, ContextSelector, old Dropdown/Select, OptionsMenu, PageHeader, Tile, DragDrop | ||
|
|
||
| ## Scan commands | ||
|
|
||
| ```bash | ||
| # Find v5 imports and component usage | ||
| rg "@patternfly/react-core(?!/deprecated)" --type tsx --type jsx | ||
|
|
||
| # Find legacy CSS classes | ||
| rg "pf-v5-|pf-v4-|pf-c-|pf-u-|pf-l-" src | ||
|
|
||
| # Find legacy CSS tokens | ||
| rg "--pf-v6-|--pf-global-" src | ||
|
|
||
| # Find deprecated component imports | ||
| rg "from.*@patternfly/react-core/deprecated" --type tsx --type jsx | ||
|
|
||
| # Find specific component patterns to migrate | ||
| rg "<(Text|TextContent|TextList|Chip|KebabToggle)\b" --type tsx --type jsx | ||
| ``` | ||
|
|
||
| ## Migration workflow | ||
|
|
||
| 1. **Run automated codemods first**: | ||
| ```bash | ||
| npx @patternfly/pf-codemods --v6 --fix ./src | ||
| npx @patternfly/class-name-updater --v6 --fix ./src | ||
| npx @patternfly/css-vars-updater --fix ./src | ||
| ``` | ||
|
|
||
| 2. **Scan for remaining issues** using commands above | ||
|
|
||
| 3. **Apply manual fixes** for: | ||
| - Markup changes (EmptyState, Masthead, Button icons) | ||
| - Deprecated components requiring custom replacements | ||
| - Color tokens (`t_temp_dev_tbd` → semantic tokens) | ||
|
|
||
| 4. **Test** UI behavior, accessibility, and responsive design | ||
|
|
||
| ## Replacement guidance | ||
|
|
||
| - **Prefer** PatternFly React component props over CSS classes | ||
| - **Use** semantic tokens (`--pf-t--*`) over legacy tokens | ||
| - **Consult** [v6 token docs](https://www.patternfly.org/tokens/all-patternfly-tokens) for color replacements | ||
| - **Run** official codemods for comprehensive coverage before manual updates | ||
|
|
||
| ## Output format | ||
|
|
||
| For each finding include: | ||
|
|
||
| - file path and line number | ||
| - current component/class/token | ||
| - recommended PF6 replacement | ||
| - confidence (`high`, `medium`, `low`) | ||
| - whether manual testing required | ||
|
|
||
| **Why:** Explain breaking change or deprecation reason | ||
|
|
||
| **How to apply:** Provide code example if replacement is non-obvious |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep
--dry-rundiscoverable or remove the example.Line 75 advertises
--dry-run, but the command hint, synopsis, generated registries, and Arguments section only document[file-path]. If dry-run is supported, include it consistently and define that no edits are applied; otherwise remove the example. While touching this block, add fence languages to satisfy MD040.📝 Proposed docs update if dry-run is supported
@@
@@
@@
@@
--
$1: (Optional) File path or directory to migrate. If not provided, analyzes the current context or prompts for clarification.+-
$1: (Optional) File path or directory to migrate. If not provided, analyzes the current context or prompts for clarification.+-
--dry-run: (Optional) Analyze and report the migration plan without applying edits.Verify each finding against the current code and only fix it if needed.
In
@plugins/patternfly/commands/migrate.mdat line 3, Update the/patternfly:migrate command docs to consistently document the --dry-run flag:
add [--dry-run] to the command hint/synopsis and examples shown (the usages
around /patternfly:migrate [file-path], /patternfly:migrate
src/components/Dashboard.tsx, and /patternfly:migrate src/components --dry-run),
add a bullet for
--dry-runin the Arguments section explaining it analyzes andreports the migration plan without applying edits, and add bash fence languages
to the code blocks to satisfy MD040; then regenerate/update the related
registries/docs (docs/data.json, PLUGINS.md, plugins/patternfly/README.md) so
the synopsis and argument hints for /patternfly:migrate remain aligned.