svgfusion 1.21.1 → 1.23.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
@@ -18,6 +18,7 @@ A powerful Node.js CLI tool and library that converts SVG files into optimized R
18
18
 
19
19
  ## Features
20
20
 
21
+ **Advanced Transformations**: Comprehensive transformation options including color splitting, stroke width extraction, fixed stroke width, and fill/stroke normalization
21
22
  **Stroke Width Splitting**: Extract and convert stroke widths to props for responsive design
22
23
  **Browser API**: Use SVGFusion directly in the browser with full feature support
23
24
  **Smart Component Naming**: Automatic prefix/suffix handling with proper PascalCase conversion
@@ -30,25 +31,6 @@ A powerful Node.js CLI tool and library that converts SVG files into optimized R
30
31
  **Production Ready**: Optimized output, error handling, and accessibility
31
32
  **Simple CLI**: Direct, intuitive command structure
32
33
 
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
51
-
52
34
  ## Try It Live
53
35
 
54
36
  **Experience SVGFusion instantly in your browser!**
@@ -68,7 +50,7 @@ npx svgfusion ./icons --output ./components
68
50
  # Add prefixes, suffixes, and generate index file
69
51
  npx svgfusion ./icons --prefix Icon --suffix Component --index
70
52
 
71
- # Advanced: Split colors for Tailwind CSS with fixed stroke width
53
+ # Advanced: Split colors for Custom CSS Class with fixed stroke width
72
54
  npx svgfusion ./icons --split-colors --fixed-stroke-width --prefix Icon
73
55
  ```
74
56
 
@@ -203,7 +185,7 @@ npx svgfusion ./assets/icons --output ./src/components --recursive --index
203
185
  # Convert with custom naming
204
186
  npx svgfusion ./assets/icons --output ./src/components --prefix Icon --suffix Component --index
205
187
 
206
- # Advanced: Split colors for Tailwind CSS compatibility
188
+ # Advanced: Split colors for Custom CSS Class compatibility
207
189
  npx svgfusion ./assets/icons --output ./src/components --split-colors --prefix Icon
208
190
 
209
191
  # Advanced: Fixed stroke width with split colors
@@ -409,9 +391,31 @@ const result = await convertToReact(svgContent, {
409
391
  - Empty attribute values (`fill=""`) are treated as non-existent
410
392
  ````
411
393
 
412
- ### Fixed Stroke Width Support
394
+ ### Transformation Options
395
+
396
+ SVGFusion provides comprehensive transformation capabilities through the transformation options API:
397
+
398
+ ```typescript
399
+ const result = await engine.convert(svgContent, {
400
+ framework: 'react',
401
+ transformation: {
402
+ splitColors: true, // Extract color props
403
+ splitStrokeWidths: true, // Extract stroke width props
404
+ fixedStrokeWidth: true, // Non-scaling stroke support
405
+ normalizeFillStroke: true, // Normalize fill/stroke attributes
406
+ accessibility: true, // Add accessibility features
407
+ optimize: true, // Apply SVG optimizations
408
+ removeComments: true, // Remove XML comments
409
+ removeDuplicates: true, // Remove duplicate elements
410
+ minifyPaths: false, // Minify path data
411
+ },
412
+ generator: { componentName: 'MyIcon', typescript: true },
413
+ });
414
+ ```
413
415
 
414
- The `isFixedStrokeWidth` option adds support for non-scaling stroke width:
416
+ #### Fixed Stroke Width Support
417
+
418
+ The `fixedStrokeWidth` transformation adds support for non-scaling stroke width:
415
419
 
416
420
  ```typescript
417
421
  const result = await convertToReact(svgContent, {
@@ -424,6 +428,14 @@ const result = await convertToReact(svgContent, {
424
428
  // - vector-effect="non-scaling-stroke" when prop is true
425
429
  ```
426
430
 
431
+ #### Fill/Stroke Normalization
432
+
433
+ The `normalizeFillStroke` transformation intelligently handles fill and stroke attributes:
434
+
435
+ - Normalizes attribute values across all SVG elements
436
+ - Ensures consistent color and stroke width application
437
+ - Optimizes attribute inheritance and cascading
438
+
427
439
  ### Custom SVGO Configuration
428
440
 
429
441
  ```typescript
@@ -8,6 +8,7 @@ interface TransformationOptions {
8
8
  splitColors?: boolean;
9
9
  splitStrokeWidths?: boolean;
10
10
  fixedStrokeWidth?: boolean;
11
+ normalizeFillStroke?: boolean;
11
12
  accessibility?: boolean;
12
13
  removeComments?: boolean;
13
14
  removeDuplicates?: boolean;
@@ -53,6 +54,7 @@ interface VueGeneratorOptions extends GeneratorOptions {
53
54
  scriptSetup?: boolean;
54
55
  sfc?: boolean;
55
56
  defineComponent?: boolean;
57
+ useDefineOptions?: boolean;
56
58
  }
57
59
 
58
60
  /**
@@ -141,6 +143,7 @@ interface BrowserConversionOptions {
141
143
  splitColors?: boolean;
142
144
  splitStrokeWidths?: boolean;
143
145
  fixedStrokeWidth?: boolean;
146
+ normalizeFillStroke?: boolean;
144
147
  memo?: boolean;
145
148
  forwardRef?: boolean;
146
149
  sfc?: boolean;