svgfusion 1.25.1 → 1.26.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.
Files changed (2) hide show
  1. package/README.md +55 -604
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,661 +3,112 @@
3
3
 
4
4
  # SVGFusion
5
5
 
6
- **SVGs to React & Vue 3 Components**
7
-
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.
6
+ **Convert SVG files into React and Vue 3 components**
9
7
 
10
8
  [![npm version](https://img.shields.io/npm/v/svgfusion)](https://www.npmjs.com/package/svgfusion)
11
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
12
10
  [![React](https://img.shields.io/badge/React-20232A?style=flat&logo=react&logoColor=61DAFB)](https://reactjs.org/)
13
11
  [![Vue.js](https://img.shields.io/badge/Vue.js-35495E?style=flat&logo=vue.js&logoColor=4FC08D)](https://vuejs.org/)
14
12
 
15
- [Documentation](https://svgfusion.netlify.app) • [CLI Reference](https://svgfusion.netlify.app/docs/cli-usage) • [NPM](https://www.npmjs.com/package/svgfusion) • **[Try Interactive Playground](https://svgfusion.netlify.app/playground)**
13
+ [Documentation](https://svgfusion.netlify.app) • [CLI Reference](https://svgfusion.netlify.app/docs/cli-usage) • [Interactive Playground](https://svgfusion.netlify.app/playground)
16
14
 
17
15
  </div>
18
16
 
19
- ## 📦 SVGFusion Packages
20
-
21
- SVGFusion is now available as a monorepo with specialized packages:
22
-
23
- - **[svgfusion](https://www.npmjs.com/package/svgfusion)** - Complete toolkit (this package)
24
- - **[svgfusion-cli](https://www.npmjs.com/package/svgfusion-cli)** - Command-line interface
25
- - **[svgfusion-browser](https://www.npmjs.com/package/svgfusion-browser)** - Browser-optimized package
26
- - **[svgfusion-core](https://www.npmjs.com/package/svgfusion-core)** - Core engine
27
- - **[svgfusion-react](https://www.npmjs.com/package/svgfusion-react)** - React utilities
28
- - **[svgfusion-vue](https://www.npmjs.com/package/svgfusion-vue)** - Vue utilities
29
-
30
- > **Note**: This package (`svgfusion`) includes everything you need. Install individual packages only if you need specific functionality.
31
-
32
17
  ## Features
33
18
 
34
- - **Advanced Transformations**: Comprehensive transformation options including color splitting, stroke width extraction, fixed stroke width, and fill/stroke normalization
35
- - **Stroke Width Splitting**: Extract and convert stroke widths to props for responsive design
36
- - **Browser API**: Use SVGFusion directly in the browser with full feature support
37
- - **Smart Component Naming**: Automatic prefix/suffix handling with proper PascalCase conversion
38
- - **Advanced Color Splitting**: Intelligent color extraction with fill/stroke optimization
39
- - **Native SVG Props**: Generated components extend React.SVGProps\<SVGSVGElement\> and Vue SVGAttributes
40
- - **React & Vue Support**: Generate both React and Vue 3 components from the same SVG
41
- - **Complex SVG Support**: Handles gradients, masks, filters, patterns, and Figma exports
19
+ - **React & Vue Support**: Generate components for both frameworks from the same SVG
42
20
  - **TypeScript Ready**: Full TypeScript support with proper type definitions
21
+ - **Advanced Color Splitting**: Intelligent color extraction with fill/stroke optimization
22
+ - **Stroke Width Splitting**: Extract stroke widths as component props
23
+ - **Native SVG Props**: Components extend React.SVGProps and Vue SVGAttributes
43
24
  - **Batch Processing**: Convert entire directories of SVG files
44
- - **Production Ready**: Optimized output, error handling, and accessibility
45
- - **Simple CLI**: Direct, intuitive command structure
46
-
47
- ## Try It Live
48
-
49
- **Experience SVGFusion instantly in your browser!** - [**Launch Interactive Playground →**](https://svgfusion.dev/playground)
50
-
51
- Upload your SVG files, experiment with different options, and see the generated React/Vue components in real-time. No installation required!
52
-
53
- ## Quick Start
25
+ - **Browser Support**: Use directly in browsers with full feature support
54
26
 
55
- ### Simple as One Command
27
+ ## Installation
56
28
 
57
29
  ```bash
58
- # Convert all SVG files in a directory to React components
59
- npx svgfusion ./icons --output ./components
60
-
61
- # Add prefixes, suffixes, and generate index file
62
- npx svgfusion ./icons --prefix Icon --suffix Component --index
63
-
64
- # Advanced: Split colors for Custom CSS Class with fixed stroke width
65
- npx svgfusion ./icons --split-colors --fixed-stroke-width --prefix Icon
66
- ```
67
-
68
- ### Installation
69
-
70
- ```bash
71
- # Install globally (recommended for CLI usage)
72
- npm install -g svgfusion
73
-
74
- # Or use npx (no installation needed)
75
- npx svgfusion ./icons --output ./components
76
-
77
- # Or install locally for programmatic usage
78
30
  npm install svgfusion
79
- # or
80
- yarn add svgfusion
81
- # or
82
- pnpm add svgfusion
83
- ```
84
-
85
- ## CLI Options
86
-
87
- <img src="https://i.ibb.co/mfRb84x/cli.png" alt="SVGFusion CLI" width="512" >
88
-
89
- svgfusion ./icons --output ./components --prefix Icon --suffix Svg
90
-
91
- You can add a prefix and/or suffix to the generated component names using the `--prefix` and `--suffix` options:
92
-
93
- ```sh
94
- npx svgfusion ./svgs --prefix Icon --suffix Svg
95
- ```
96
-
97
- This will generate components like `IconStarSvg`, `IconUserSvg`, etc.
98
-
99
- Both options sanitize input to remove symbols and spaces. If omitted, no prefix/suffix is added.
100
-
101
- #### Example
102
-
103
- ```sh
104
- npx svgfusion ./svgs --prefix App --suffix Widget
105
- # Output: AppStarWidget, AppUserWidget, ...
106
- ```
107
-
108
- For more details, run:
109
-
110
- ```sh
111
- npx svgfusion --help
112
- ```
113
-
114
- ### CLI Usage
115
-
116
- ```bash
117
- # Convert to React components (default)
118
- svgfusion ./icons --output ./components
119
-
120
- # Convert to Vue 3 components
121
- svgfusion ./icons --output ./components --framework vue
122
-
123
- # Single file conversion with TypeScript
124
- svgfusion ./star.svg --output ./components --typescript
125
-
126
- # Batch processing with recursive directory scanning
127
- svgfusion ./icons --output ./components --recursive
128
-
129
- # Generate index file for tree-shaking
130
- svgfusion ./icons --output ./components --index
131
-
132
- # Advanced: Split colors for maximum customization
133
- svgfusion ./icons --output ./components --split-colors
134
-
135
- # Advanced: Fixed stroke width with split colors
136
- svgfusion ./icons --output ./components --split-colors --fixed-stroke-width
137
-
138
- # Using npx (no global install needed)
139
- npx svgfusion ./icons --output ./components --framework react
140
- ```
141
-
142
- ### Available CLI Options
143
-
144
- ```bash
145
- svgfusion <input> [options]
146
-
147
- Arguments:
148
- <input> SVG file or directory to convert
149
-
150
- Options:
151
- -o, --output <dir> Output directory for generated components (default: "./components")
152
- -f, --framework <framework> Target framework: react or vue (default: "react")
153
- --typescript Generate TypeScript components (default: true)
154
- --javascript Generate JavaScript components
155
- --split-colors Enable color splitting feature
156
- --fixed-stroke-width Enable fixed stroke width feature
157
- --memo Wrap component with React.memo (default: true)
158
- --no-memo Disable React.memo wrapping
159
- --forward-ref Enable forwardRef support (default: true)
160
- --no-forward-ref Disable forwardRef support
161
- -n, --name <name> Custom component name
162
- --optimize Enable SVG optimization (default: true)
163
- --no-optimize Disable SVG optimization
164
- --recursive Process directories recursively
165
- --prefix <prefix> Add prefix to component names
166
- --suffix <suffix> Add suffix to component names
167
- --index Generate index.ts file for directory processing
168
- -h, --help Show help
169
31
  ```
170
32
 
171
- --prefix `<prefix>` Add prefix to component name (sanitized)
172
- --suffix `<suffix>` Add suffix to component name (sanitized)
173
- --split-colors Extract individual color props for each SVG color
174
- --fixed-stroke-width Add support for non-scaling stroke width
175
- -h, --help Show help
176
-
177
- ````
178
-
179
- ### Using with npx (No Installation Required)
180
-
181
- Perfect for trying out SVGFusion or one-time conversions:
182
-
183
- ```bash
184
- # Convert React components
185
- npx svgfusion ./assets/icons --output ./src/components/icons
186
-
187
- # Convert Vue components with TypeScript
188
- npx svgfusion ./assets/icons --output ./src/components --framework vue --typescript
189
-
190
- # Convert single file
191
- npx svgfusion ./logo.svg --output ./src/components --framework react
192
-
193
- # Batch convert with index generation
194
- npx svgfusion ./assets/icons --output ./src/components --recursive --index
195
-
196
- # Convert with custom naming
197
- npx svgfusion ./assets/icons --output ./src/components --prefix Icon --suffix Component --index
198
-
199
- # Advanced: Split colors for Custom CSS Class compatibility
200
- npx svgfusion ./assets/icons --output ./src/components --split-colors --prefix Icon
201
-
202
- # Advanced: Fixed stroke width with split colors
203
- npx svgfusion ./assets/icons --output ./src/components --split-colors --fixed-stroke-width
204
- ````
205
-
206
- ### Programmatic Usage
33
+ ## Quick Start
207
34
 
208
- #### Single File Conversion
35
+ ### React Component
209
36
 
210
37
  ```typescript
211
- import { SVGFusion } from 'svgfusion';
212
-
213
- const engine = new SVGFusion();
214
- const svgContent = `<svg viewBox="0 0 24 24"><path fill="#FF0000" stroke="#00FF00" d="..."/></svg>`;
215
-
216
- const result = await engine.convert(svgContent, {
217
- framework: 'react', // or 'vue'
218
- transformation: { splitColors: true },
219
- generator: { componentName: 'MyIcon', typescript: true },
220
- });
221
-
222
- console.log(result.code); // The generated component code
223
- ```
224
-
225
- ## API Reference
226
-
227
- For the complete API documentation, visit [svgfusion.netlify.app](https://svgfusion.netlify.app/docs/api-reference).
228
-
229
- ## Examples
230
-
231
- ### Input SVG
232
-
233
- ```svg
234
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
235
- <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
236
- fill="currentColor" class="star-fill"/>
237
- </svg>
238
- ```
239
-
240
- ### Generated React Component
241
-
242
- ```tsx
243
- import type { SVGProps } from 'react';
244
-
245
- interface StarIconProps extends SVGProps<SVGSVGElement> {}
246
-
247
- const StarIcon = (props: StarIconProps) => {
248
- return (
249
- <svg viewBox="0 0 24 24" {...props}>
250
- <path
251
- d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
252
- fill="currentColor"
253
- className="star-fill"
254
- />
255
- </svg>
256
- );
257
- };
258
-
259
- export { StarIcon };
260
- ```
261
-
262
- ### Generated React Component with Color Splitting
263
-
264
- ```tsx
265
- import type { SVGProps } from 'react';
266
-
267
- interface StarIconProps extends SVGProps<SVGSVGElement> {
268
- fillColor?: string;
269
- }
270
-
271
- const StarIcon = ({ fillColor = 'currentColor', ...props }: StarIconProps) => {
272
- return (
273
- <svg viewBox="0 0 24 24" {...props}>
274
- <path
275
- d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
276
- fill={fillColor}
277
- className="star-fill"
278
- />
279
- </svg>
280
- );
281
- };
282
-
283
- export { StarIcon };
284
- ```
285
-
286
- ### Generated Vue Component
287
-
288
- ```vue
289
- <script setup lang="ts">
290
- import type { SVGAttributes } from 'vue';
291
-
292
- interface StarIconProps extends SVGAttributes {}
293
-
294
- defineOptions({ inheritAttrs: false });
295
- </script>
296
-
297
- <template>
298
- <svg v-bind="$attrs" viewBox="0 0 24 24">
299
- <path
300
- d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
301
- fill="currentColor"
302
- class="star-fill"
303
- />
304
- </svg>
305
- </template>
306
- ```
307
-
308
- ### Generated Vue Component with Color Splitting
309
-
310
- ```vue
311
- <script setup lang="ts">
312
- import type { SVGAttributes } from 'vue';
313
-
314
- interface StarIconProps extends SVGAttributes {
315
- fillColor?: string;
316
- }
38
+ import { convertSvgToReact } from 'svgfusion';
317
39
 
318
- const props = withDefaults(defineProps<StarIconProps>(), {
319
- fillColor: 'currentColor',
320
- });
321
-
322
- defineOptions({ inheritAttrs: false });
323
- </script>
324
-
325
- <template>
326
- <svg v-bind="$attrs" viewBox="0 0 24 24">
327
- <path
328
- d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
329
- :fill="fillColor"
330
- class="star-fill"
331
- />
332
- </svg>
333
- </template>
334
- ```
335
-
336
- </script>
337
-
338
- <template>
339
- <svg v-bind="$attrs" viewBox="0 0 24 24">
340
- <path
341
- d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z"
342
- fill="currentColor"
343
- class="star-fill"
344
- />
345
- </svg>
346
- </template>
347
-
348
- <style scoped>
349
- /* Add component-specific styles here */
350
- </style>
351
-
352
- ````
353
-
354
- ## Advanced Configuration
355
-
356
- ### Split Colors with Intelligent Attribute Handling
40
+ const svgCode = `<svg viewBox="0 0 24 24"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`;
357
41
 
358
- The `splitColors` option extracts individual color properties from SVG elements and intelligently manages fill/stroke attributes:
359
-
360
- ```typescript
361
- // Input SVG with mixed attributes
362
- const svgContent = `
363
- <svg viewBox="0 0 24 24">
364
- <path fill="#FF0000" d="..." /> <!-- Has fill only -->
365
- <path stroke="#00FF00" d="..." /> <!-- Has stroke only -->
366
- <path fill="#0000FF" stroke="#FFFF00" /> <!-- Has both -->
367
- <path d="..." /> <!-- Has neither -->
368
- </svg>
369
- `;
370
-
371
- // Convert with split colors
372
- const result = await convertToReact(svgContent, {
373
- name: 'MultiColorIcon',
374
- splitColors: true,
42
+ const result = await convertSvgToReact(svgCode, {
43
+ componentName: 'StarIcon',
375
44
  typescript: true,
45
+ splitColors: true,
376
46
  });
377
47
 
378
- // Generated component behavior:
379
- // - Path with fill only: gets stroke="none" (prevents unwanted stroke)
380
- // - Path with stroke only: gets fill="none" (prevents black fill default)
381
- // - Path with both: keeps both as dynamic props
382
- // - Path with neither: remains unchanged (no unnecessary attributes)
383
-
384
- // Generated component props:
385
- // - color, color2, color3 (for extracted colors in order)
386
- // - colorClass, color2Class, color3Class (for CSS classes)
387
- // - Colors are automatically converted to hex format
388
- ```
389
-
390
- **Color Extraction Rules:**
391
- - Colors are extracted from `fill`, `stroke`, and `stop-color` attributes
392
- - All colors are converted to lowercase hex format (e.g., `#ff0000`)
393
- - Empty or invalid color values are ignored
394
- - Duplicate colors are automatically deduplicated
395
- - Colors are assigned as `color`, `color2`, `color3`, etc. in order
396
-
397
- **Intelligent Attribute Handling:**
398
- - Elements with `fill` only → adds `stroke="none"`
399
- - Elements with `stroke` only → adds `fill="none"`
400
- - Elements with both `fill` and `stroke` → keeps both as props
401
- - Elements with neither → no attributes added
402
- - Empty attribute values (`fill=""`) are treated as non-existent
403
- ````
404
-
405
- ### Transformation Options
406
-
407
- SVGFusion provides comprehensive transformation capabilities through the transformation options API:
408
-
409
- ```typescript
410
- const result = await engine.convert(svgContent, {
411
- framework: 'react',
412
- transformation: {
413
- splitColors: true, // Extract color props
414
- splitStrokeWidths: true, // Extract stroke width props
415
- fixedStrokeWidth: true, // Non-scaling stroke support
416
- normalizeFillStroke: true, // Normalize fill/stroke attributes
417
- accessibility: true, // Add accessibility features
418
- optimize: true, // Apply SVG optimizations
419
- removeComments: true, // Remove XML comments
420
- removeDuplicates: true, // Remove duplicate elements
421
- minifyPaths: false, // Minify path data
422
- },
423
- generator: { componentName: 'MyIcon', typescript: true },
424
- });
425
- ```
426
-
427
- #### Fixed Stroke Width Support
428
-
429
- The `fixedStrokeWidth` transformation adds support for non-scaling stroke width:
430
-
431
- ```typescript
432
- const result = await convertToReact(svgContent, {
433
- name: 'StrokeIcon',
434
- isFixedStrokeWidth: true,
435
- });
436
-
437
- // Generated component includes:
438
- // - isFixedStrokeWidth prop
439
- // - vector-effect="non-scaling-stroke" when prop is true
48
+ console.log(result.component);
440
49
  ```
441
50
 
442
- #### Fill/Stroke Normalization
443
-
444
- The `normalizeFillStroke` transformation intelligently handles fill and stroke attributes:
445
-
446
- - Normalizes attribute values across all SVG elements
447
- - Ensures consistent color and stroke width application
448
- - Optimizes attribute inheritance and cascading
449
-
450
- ### Custom SVGO Configuration
51
+ ### Vue Component
451
52
 
452
53
  ```typescript
453
- import { createSvgoConfig, optimizeSvg } from 'svgfusion';
54
+ import { convertSvgToVue } from 'svgfusion';
454
55
 
455
- const customConfig = createSvgoConfig({
456
- removeViewBox: false,
457
- preserveColors: true,
458
- preserveClasses: true,
56
+ const result = await convertSvgToVue(svgCode, {
57
+ componentName: 'StarIcon',
58
+ typescript: true,
59
+ splitColors: true,
459
60
  });
460
61
 
461
- const optimizedSvg = optimizeSvg(svgContent, customConfig);
462
- ```
463
-
464
- ### Batch Processing with SVGFusion Engine
465
-
466
- ```typescript
467
- import { SVGFusion, readSvgDirectory } from 'svgfusion';
468
- import { writeFileSync } from 'fs';
469
- import path from 'path';
470
-
471
- const engine = new SVGFusion();
472
- const svgFiles = await readSvgDirectory('./icons', true); // recursive
473
-
474
- for (const svgFile of svgFiles) {
475
- const svgContent = readFileSync(svgFile, 'utf-8');
476
- const result = await engine.convert(svgContent, {
477
- framework: 'react',
478
- generator: {
479
- componentName: path.basename(svgFile, '.svg'),
480
- typescript: true,
481
- },
482
- transformation: {
483
- splitColors: true,
484
- },
485
- });
486
-
487
- writeFileSync(`./components/${result.filename}`, result.code);
488
- }
489
- ```
490
-
491
- ### Index File Generation
492
-
493
- When using the `--index` flag or `generateIndex: true` option, SVGFusion creates an optimized index file for tree-shaking:
494
-
495
- #### Named Exports (Default)
496
-
497
- ```typescript
498
- // Auto-generated index file for tree-shaking
499
- // This file exports all components for optimal bundling
500
-
501
- export { default as IconStar } from './IconStar';
502
- export { default as IconUser } from './IconUser';
503
- export { default as IconHome } from './IconHome';
504
-
505
- // Barrel export for convenience
506
- export { IconStar, IconUser, IconHome };
507
-
508
- // TypeScript component types
509
- export type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;
510
- export type IconComponents = {
511
- IconStar: IconComponent;
512
- IconUser: IconComponent;
513
- IconHome: IconComponent;
514
- };
515
- ```
516
-
517
- #### Default Exports
518
-
519
- ```typescript
520
- // Auto-generated index file
521
- // Warning: Default exports are less tree-shakeable
522
-
523
- import IconStar from './IconStar';
524
- import IconUser from './IconUser';
525
- import IconHome from './IconHome';
526
-
527
- export default {
528
- IconStar,
529
- IconUser,
530
- IconHome,
531
- };
532
-
533
- // Individual exports for flexibility
534
- export { default as IconStar } from './IconStar';
535
- export { default as IconUser } from './IconUser';
536
- export { default as IconHome } from './IconHome';
537
- ```
538
-
539
- #### Usage
540
-
541
- ```typescript
542
- // Tree-shakeable named imports (recommended)
543
- import { IconStar, IconUser } from './components';
544
-
545
- // Default import
546
- import * as Icons from './components';
547
- const { IconStar, IconUser } = Icons;
62
+ console.log(result.component);
548
63
  ```
549
64
 
550
- ## Complex Filename Support
65
+ ### CLI Usage
551
66
 
552
- SVGFusion handles complex filenames from design systems:
67
+ Coming soon! For now, clone the repository and use:
553
68
 
554
69
  ```bash
555
- # Design system metadata
556
- "Size=xl, Color=Brand, Type=Glass.svg" → GlassBrandXl
557
- "User Profile Avatar, Type=Solid.svg" → UserProfileAvatarTypeSolid
558
-
559
- # Standard patterns
560
- "icon-star.svg" → IconStar
561
- "user-profile-avatar.svg" → UserProfileAvatar
70
+ git clone https://github.com/lolvOid/svgfusion
71
+ cd svgfusion
72
+ pnpm install
73
+ pnpm build
74
+ pnpm --filter=svgfusion-bundle exec svgfusion icon.svg --react --typescript
562
75
  ```
563
76
 
564
- ## Styling Support
565
-
566
- ### CSS Classes
567
-
568
- ```svg
569
- <path class="primary-color" />
570
- <circle class="bg-blue-500" /> <!-- Tailwind -->
571
- ```
572
-
573
- ### CSS Variables
574
-
575
- ```svg
576
- <path fill="var(--primary-color)" />
577
- <circle fill="currentColor" />
578
- ```
579
-
580
- ### Gradients & Patterns
581
-
582
- ```svg
583
- <defs>
584
- <linearGradient id="gradient">
585
- <stop offset="0%" style="stop-color:#ff6b6b" />
586
- <stop offset="100%" style="stop-color:#4ecdc4" />
587
- </linearGradient>
588
- </defs>
589
- <path fill="url(#gradient)" />
590
- ```
77
+ ### Browser Usage
591
78
 
592
- ## Testing
79
+ ```html
80
+ <script type="module">
81
+ import {
82
+ convertSvgToReact,
83
+ convertSvgToVue,
84
+ } from 'https://cdn.jsdelivr.net/npm/svgfusion@1.25.2/+esm';
593
85
 
594
- ```bash
595
- npm test # Run tests
596
- npm run test:coverage # Run with coverage
597
- ```
86
+ const svgCode = `<svg viewBox="0 0 24 24"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`;
598
87
 
599
- ## Development
88
+ const result = await convertSvgToReact(svgCode, {
89
+ componentName: 'StarIcon',
90
+ typescript: true,
91
+ });
600
92
 
601
- ```bash
602
- npm run dev # Watch mode
603
- npm run build # Build for production
604
- npm run lint # Lint code
605
- npm run format # Format code
93
+ console.log(result.component);
94
+ </script>
606
95
  ```
607
96
 
608
- ## License
609
-
610
- MIT © SVGFusion Contributors
611
-
612
- ## Contributing
613
-
614
- Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
615
-
616
- ## Changelog
617
-
618
- See [CHANGELOG.md](./CHANGELOG.md) for details.
619
-
620
- ### Browser Usage
621
-
622
- SVGFusion now supports browser environments! Convert SVG strings to component code without writing files.
623
-
624
- **Try the Interactive Playground**: [svgfusion.netlify.app/playground](https://svgfusion.netlify.app/playground)
97
+ Or import the browser-optimized version:
625
98
 
626
99
  ```javascript
627
- import { convertToReact, convertToVue } from 'svgfusion/browser';
628
-
629
- const svgContent = `<svg viewBox="0 0 24 24"><path fill="#3B82F6" d="..."/></svg>`;
630
-
631
- // Convert to React component string
632
- const reactResult = await convertToReact(svgContent, {
633
- componentName: 'MyIcon',
634
- typescript: true,
635
- splitColors: true,
636
- });
637
-
638
- console.log(reactResult.code); // Generated React component code
639
-
640
- // Convert to Vue component string
641
- const vueResult = await convertToVue(svgContent, {
642
- componentName: 'MyIcon',
643
- typescript: true,
644
- sfc: true,
645
- });
646
-
647
- console.log(vueResult.code); // Generated Vue component code
100
+ import { convertSvgToReact, convertSvgToVue } from 'svgfusion/browser';
101
+ // No Node.js dependencies required
648
102
  ```
649
103
 
650
- **Browser Features:**
104
+ ## Documentation
651
105
 
652
- - All conversion features (color splitting, stroke fixing, etc.)
653
- - React and Vue component generation
654
- - TypeScript support
655
- - Batch conversion
656
- - Color extraction and validation
657
- - Index file generation
658
- - Works in all modern browsers
659
- - **Interactive Playground** with Monaco Editor
106
+ - **[Full Documentation](https://svgfusion.netlify.app)** - Complete guides and API reference
107
+ - **[Interactive Playground](https://svgfusion.netlify.app/playground)** - Try SVGFusion in your browser
108
+ - **[CLI Reference](https://svgfusion.netlify.app/docs/cli-usage)** - Command-line documentation
109
+ - **[API Reference](https://svgfusion.netlify.app/docs/api)** - Programmatic usage
110
+ - **[Examples](https://svgfusion.netlify.app/docs/examples)** - Real-world use cases
660
111
 
661
- #### [Browser API Documentation](./docs/docs/browser-api.md)
112
+ ## License
662
113
 
663
- #### [Node API Documentation](./docs/docs/node-api.md)
114
+ MIT License - see [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svgfusion",
3
- "version": "1.25.1",
3
+ "version": "1.26.0",
4
4
  "description": "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.",
5
5
  "type": "module",
6
6
  "publishConfig": {