svgfusion 1.22.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  # SVGFusion
5
5
 
6
- **Transform SVG files into production-ready React and Vue 3 components**
6
+ **SVGs to React & Vue 3 Components**
7
7
 
8
- A powerful Node.js CLI tool and library that converts SVG files into optimized React and Vue components with native SVG props inheritance, TypeScript integration, and smart optimization for modern development workflows.
8
+ Convert SVG files into blazing-fast React and Vue 3 components with automatic color extraction, full TypeScript support, and seamless integration into any modern workflow.
9
9
 
10
10
  [![npm version](https://img.shields.io/npm/v/svgfusion)](https://www.npmjs.com/package/svgfusion)
11
11
  [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
@@ -18,42 +18,22 @@ A powerful Node.js CLI tool and library that converts SVG files into optimized R
18
18
 
19
19
  ## Features
20
20
 
21
- **Stroke Width Splitting**: Extract and convert stroke widths to props for responsive design
22
- **Browser API**: Use SVGFusion directly in the browser with full feature support
23
- **Smart Component Naming**: Automatic prefix/suffix handling with proper PascalCase conversion
24
- **Advanced Color Splitting**: Intelligent color extraction with fill/stroke optimization
25
- **Native SVG Props**: Generated components extend React.SVGProps\<SVGSVGElement\> and Vue SVGAttributes
26
- **React & Vue Support**: Generate both React and Vue 3 components from the same SVG
27
- **Complex SVG Support**: Handles gradients, masks, filters, patterns, and Figma exports
28
- **TypeScript Ready**: Full TypeScript support with proper type definitions
29
- **Batch Processing**: Convert entire directories of SVG files
30
- **Production Ready**: Optimized output, error handling, and accessibility
31
- **Simple CLI**: Direct, intuitive command structure
32
-
33
- ### Stroke Width Splitting
34
-
35
- Extract stroke widths from SVG elements and convert them to component props for responsive designs:
36
-
37
- ```jsx
38
- // Original SVG: <path stroke-width="2" d="..."/>
39
- // Generated React component:
40
- <MyIcon strokeWidth1={4} /> // Scales the stroke width
41
- ```
42
-
43
- ### Color Splitting (splitColors)
44
-
45
- Extracts all unique fill, stroke, and gradient colors from your SVG and generates props for each color and color class. Automatically adds `fill="none"` or `stroke="none"` to prevent unwanted browser defaults:
46
-
47
- - Path with only fill → gets `stroke="none"`
48
- - Path with only stroke → gets `fill="none"`
49
- - Path with both → keeps both as props
50
- - Path with neither → stays unchanged
21
+ - **Advanced Transformations**: Comprehensive transformation options including color splitting, stroke width extraction, fixed stroke width, and fill/stroke normalization
22
+ - **Stroke Width Splitting**: Extract and convert stroke widths to props for responsive design
23
+ - **Browser API**: Use SVGFusion directly in the browser with full feature support
24
+ - **Smart Component Naming**: Automatic prefix/suffix handling with proper PascalCase conversion
25
+ - **Advanced Color Splitting**: Intelligent color extraction with fill/stroke optimization
26
+ - **Native SVG Props**: Generated components extend React.SVGProps\<SVGSVGElement\> and Vue SVGAttributes
27
+ - **React & Vue Support**: Generate both React and Vue 3 components from the same SVG
28
+ - **Complex SVG Support**: Handles gradients, masks, filters, patterns, and Figma exports
29
+ - **TypeScript Ready**: Full TypeScript support with proper type definitions
30
+ - **Batch Processing**: Convert entire directories of SVG files
31
+ - **Production Ready**: Optimized output, error handling, and accessibility
32
+ - **Simple CLI**: Direct, intuitive command structure
51
33
 
52
34
  ## Try It Live
53
35
 
54
- **Experience SVGFusion instantly in your browser!**
55
-
56
- [**Launch Interactive Playground →**](https://svgfusion.dev/playground)
36
+ **Experience SVGFusion instantly in your browser!** - [**Launch Interactive Playground →**](https://svgfusion.dev/playground)
57
37
 
58
38
  Upload your SVG files, experiment with different options, and see the generated React/Vue components in real-time. No installation required!
59
39
 
@@ -68,7 +48,7 @@ npx svgfusion ./icons --output ./components
68
48
  # Add prefixes, suffixes, and generate index file
69
49
  npx svgfusion ./icons --prefix Icon --suffix Component --index
70
50
 
71
- # Advanced: Split colors for Tailwind CSS with fixed stroke width
51
+ # Advanced: Split colors for Custom CSS Class with fixed stroke width
72
52
  npx svgfusion ./icons --split-colors --fixed-stroke-width --prefix Icon
73
53
  ```
74
54
 
@@ -203,7 +183,7 @@ npx svgfusion ./assets/icons --output ./src/components --recursive --index
203
183
  # Convert with custom naming
204
184
  npx svgfusion ./assets/icons --output ./src/components --prefix Icon --suffix Component --index
205
185
 
206
- # Advanced: Split colors for Tailwind CSS compatibility
186
+ # Advanced: Split colors for Custom CSS Class compatibility
207
187
  npx svgfusion ./assets/icons --output ./src/components --split-colors --prefix Icon
208
188
 
209
189
  # Advanced: Fixed stroke width with split colors
@@ -409,9 +389,31 @@ const result = await convertToReact(svgContent, {
409
389
  - Empty attribute values (`fill=""`) are treated as non-existent
410
390
  ````
411
391
 
412
- ### Fixed Stroke Width Support
392
+ ### Transformation Options
413
393
 
414
- The `isFixedStrokeWidth` option adds support for non-scaling stroke width:
394
+ SVGFusion provides comprehensive transformation capabilities through the transformation options API:
395
+
396
+ ```typescript
397
+ const result = await engine.convert(svgContent, {
398
+ framework: 'react',
399
+ transformation: {
400
+ splitColors: true, // Extract color props
401
+ splitStrokeWidths: true, // Extract stroke width props
402
+ fixedStrokeWidth: true, // Non-scaling stroke support
403
+ normalizeFillStroke: true, // Normalize fill/stroke attributes
404
+ accessibility: true, // Add accessibility features
405
+ optimize: true, // Apply SVG optimizations
406
+ removeComments: true, // Remove XML comments
407
+ removeDuplicates: true, // Remove duplicate elements
408
+ minifyPaths: false, // Minify path data
409
+ },
410
+ generator: { componentName: 'MyIcon', typescript: true },
411
+ });
412
+ ```
413
+
414
+ #### Fixed Stroke Width Support
415
+
416
+ The `fixedStrokeWidth` transformation adds support for non-scaling stroke width:
415
417
 
416
418
  ```typescript
417
419
  const result = await convertToReact(svgContent, {
@@ -424,6 +426,14 @@ const result = await convertToReact(svgContent, {
424
426
  // - vector-effect="non-scaling-stroke" when prop is true
425
427
  ```
426
428
 
429
+ #### Fill/Stroke Normalization
430
+
431
+ The `normalizeFillStroke` transformation intelligently handles fill and stroke attributes:
432
+
433
+ - Normalizes attribute values across all SVG elements
434
+ - Ensures consistent color and stroke width application
435
+ - Optimizes attribute inheritance and cascading
436
+
427
437
  ### Custom SVGO Configuration
428
438
 
429
439
  ```typescript
@@ -635,5 +645,6 @@ console.log(vueResult.code); // Generated Vue component code
635
645
  - Works in all modern browsers
636
646
  - **Interactive Playground** with Monaco Editor
637
647
 
638
- [Full Browser API Documentation](./docs/docs/browser-api.md)
639
- [Full Node API Documentation](./docs/docs/node-api.md)
648
+ #### [Browser API Documentation](./docs/docs/browser-api.md)
649
+
650
+ #### [Node API Documentation](./docs/docs/node-api.md)
@@ -143,6 +143,7 @@ interface BrowserConversionOptions {
143
143
  splitColors?: boolean;
144
144
  splitStrokeWidths?: boolean;
145
145
  fixedStrokeWidth?: boolean;
146
+ normalizeFillStroke?: boolean;
146
147
  memo?: boolean;
147
148
  forwardRef?: boolean;
148
149
  sfc?: boolean;