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 +52 -41
- package/dist/browser.d.mts +1 -0
- package/dist/browser.mjs +45 -45
- package/dist/cli.js +56 -39
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
# SVGFusion
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**SVGs to React & Vue 3 Components**
|
|
7
7
|
|
|
8
|
-
|
|
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
|
[](https://www.npmjs.com/package/svgfusion)
|
|
11
11
|
[](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
|
-
**
|
|
22
|
-
**
|
|
23
|
-
**
|
|
24
|
-
**
|
|
25
|
-
**
|
|
26
|
-
**
|
|
27
|
-
**
|
|
28
|
-
**
|
|
29
|
-
**
|
|
30
|
-
**
|
|
31
|
-
**
|
|
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
|
|
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
|
|
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
|
-
###
|
|
392
|
+
### Transformation Options
|
|
413
393
|
|
|
414
|
-
|
|
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
|
-
[
|
|
639
|
-
|
|
648
|
+
#### [Browser API Documentation](./docs/docs/browser-api.md)
|
|
649
|
+
|
|
650
|
+
#### [Node API Documentation](./docs/docs/node-api.md)
|
package/dist/browser.d.mts
CHANGED