Skip to content

Commit 3b8fe71

Browse files
committed
feat(CC-icons): added support scripts
1 parent f2ef4f7 commit 3b8fe71

File tree

10 files changed

+2619
-1
lines changed

10 files changed

+2619
-1
lines changed

packages/react-core/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/deprecated
33
/components
44
/layouts
5-
/helpers
5+
/helpers
6+
.env
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# PatternFly React Icon Generation System
2+
3+
## Overview
4+
5+
The PatternFly React icon generation system automates the process of creating and managing icon components, including generation, Figma connections, and consistent integration.
6+
7+
## Components
8+
9+
### 1. Icon Data Source (`iconsData.json`)
10+
Defines the metadata for each icon in the library.
11+
12+
```npm run figma:icons:fetch FIGMA_ACCESS_TOKEN```
13+
14+
#### JSON Structure
15+
```json
16+
[
17+
{
18+
"iconName": "angle-down",
19+
"fileName": "angle-down-icon",
20+
"reactName": "AngleDownIcon",
21+
"url": "Optional Figma design URL",
22+
"svgPath": "SVG path data for the icon"
23+
}
24+
]
25+
```
26+
27+
### 2. Scripts
28+
29+
#### `iconConnector.mjs`
30+
Generates Figma connection files for icons.
31+
32+
## Workflow
33+
34+
### 1. Prepare Icon Data
35+
Create or update `iconsData.json` with icon specifications.
36+
37+
### 2. Generation Commands
38+
39+
#### Generate Icons
40+
```bash
41+
# Generate iconData.json
42+
yarn run figma:fetch
43+
44+
# Generate icon components and Figma connections
45+
yarn run figma:sync
46+
```
47+
48+
## Best Practices
49+
50+
- Keep `iconsData.json` updated with the latest icon information
51+
- Ensure SVG paths are clean and optimized
52+
- Maintain consistent naming conventions
53+
- Validate icon designs in Figma before generation
54+
55+
## Troubleshooting
56+
57+
### Common Issues
58+
- **SVG Path Errors**: Check SVG path syntax and completeness
59+
- **Naming Conflicts**: Ensure unique `reactName` for each icon
60+
61+
### Logging
62+
The system uses a comprehensive logging utility that provides:
63+
- Timestamped logs
64+
- Contextual information
65+
- Color-coded output for different log levels
66+
67+
## Extensibility
68+
69+
The modular design allows easy extension:
70+
- Add new icons by updating `iconsData.json`
71+
- Modify configuration as project needs evolve
72+
73+
## Contributing
74+
75+
1. Update `iconsData.json` with new icon specifications
76+
2. Validate SVG paths and icon designs
77+
3. Run generation scripts
78+
4. Review generated components
79+
5. Commit changes
80+
81+
## Dependencies
82+
83+
- Node.js
84+
- Figma Code Connect
85+
- PatternFly React ecosystem
86+
87+
## License
88+
89+
PatternFly React is licensed under the [MIT License](https://github.com/patternfly/patternfly-react/tree/main/LICENSE).
90+
91+
## Support
92+
93+
For issues or questions, please file a GitHub issue in the PatternFly React repository.

packages/react-core/codeConnect/data/iconsData.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { SVGProps } from 'react';
2+
3+
export interface IconProps extends SVGProps<SVGSVGElement> {
4+
/** Additional classes added to the icon */
5+
className?: string;
6+
/** Icon title for accessibility */
7+
title?: string;
8+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { IconWrapper } from 'src/components/Icon/IconWrapper.tsx';
2+
import figma from '@figma/code-connect';
3+
4+
figma.connect(
5+
IconWrapper,
6+
'https://www.figma.com/design/VMEX8Xg2nzhBX8rfBx53jp/branch/9QzcMKMR7FX7HXlc0sRUSp/PatternFly-6--Components?node-id=198-1573&t=dP3Et2mI3FtI6IEP-11',
7+
{
8+
props: {
9+
// Icon instance from Figma
10+
icon: figma.instance('🖼️ Icon'),
11+
12+
// Comprehensive icon size mapping
13+
iconSize: figma.enum('Icon Size', {
14+
// Standalone Sizes
15+
'Standalone - Small': 'sm',
16+
'Standalone - Medium': 'md',
17+
'Standalone - Large': 'lg',
18+
'Standalone - XL': 'xl',
19+
'Standalone - 2XL': '2xl',
20+
'Standalone - 3XL': '3xl',
21+
22+
// Body Sizes
23+
'Body - Small': 'body---small',
24+
'Body - Default': 'body---default',
25+
'Body - Large': 'body---large',
26+
27+
// Heading Sizes
28+
'Heading - H1': 'heading---h1',
29+
'Heading - H2': 'heading---h2',
30+
'Heading - H3': 'heading---h3',
31+
'Heading - H4': 'heading---h4',
32+
'Heading - H5': 'heading---h5',
33+
'Heading - H6': 'heading---h6',
34+
35+
// Font Sizes
36+
'Font size - XS': 'font-size---xs',
37+
'Font size - Sm': 'font-size---sm',
38+
'Font size - Med': 'font-size---med',
39+
'Font size - Lg': 'font-size---lg',
40+
'Font size - XL': 'font-size---xl',
41+
'Font size - 2XL': 'font-size---2xl',
42+
'Font size - 3XL': 'font-size---3xl',
43+
'Font size - 4XL': 'font-size---4xl'
44+
})
45+
46+
// // Add state support
47+
// states: figma.string('State', {
48+
// default: '',
49+
// empty: 'pf-m-empty'
50+
// })
51+
},
52+
53+
// example: (props) => <IconWrapper iconSize={props.iconSize} icon={props.icon} className={props.states} />
54+
example: (props) => <IconWrapper iconSize={props.iconSize} icon={props.icon} />
55+
}
56+
);
57+
58+
export default IconWrapper;

0 commit comments

Comments
 (0)