├── .node-version
├── .husky
└── pre-push
├── tests
├── fixtures
│ ├── pct-unit.svg
│ ├── with-style-and-data.svg
│ ├── edge-case-width.svg
│ ├── simple.svg
│ ├── with-stroke.svg
│ ├── matrix-negative.svg
│ ├── with-fill.svg
│ ├── clean.svg
│ └── sketch-export.svg
└── components
│ ├── with-web
│ ├── SVGPctUnit.js
│ ├── SVGWithStyleAndData.js
│ ├── SVGEdgeCaseWidth.js
│ ├── SVGSimple.js
│ ├── SVGWithStroke.js
│ ├── SVGClean.js
│ ├── SVGWithFill.js
│ ├── SVGMatrixNegative.js
│ └── SVGSketchExport.js
│ ├── with-native_with-web
│ ├── SVGPctUnit.web.js
│ ├── SVGWithStyleAndData.web.js
│ ├── SVGEdgeCaseWidth.web.js
│ ├── SVGSimple.web.js
│ ├── SVGPctUnit.js
│ ├── SVGWithStyleAndData.js
│ ├── SVGEdgeCaseWidth.js
│ ├── SVGWithStroke.web.js
│ ├── SVGSimple.js
│ ├── SVGClean.web.js
│ ├── SVGWithFill.web.js
│ ├── SVGMatrixNegative.web.js
│ ├── SVGSketchExport.web.js
│ ├── SVGWithStroke.js
│ ├── SVGClean.js
│ ├── SVGWithFill.js
│ ├── SVGMatrixNegative.js
│ └── SVGSketchExport.js
│ ├── with-web-for-typescript
│ ├── SVGPctUnit.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGSimple.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithFill.tsx
│ ├── SVGMatrixNegative.tsx
│ └── SVGSketchExport.tsx
│ ├── with-native-for-typescript_with-web-for-typescript
│ ├── SVGPctUnit.web.tsx
│ ├── SVGWithStyleAndData.web.tsx
│ ├── SVGEdgeCaseWidth.web.tsx
│ ├── SVGSimple.web.tsx
│ ├── SVGPctUnit.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGWithStroke.web.tsx
│ ├── SVGClean.web.tsx
│ ├── SVGSimple.tsx
│ ├── SVGWithFill.web.tsx
│ ├── SVGMatrixNegative.web.tsx
│ ├── SVGSketchExport.web.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithFill.tsx
│ ├── SVGMatrixNegative.tsx
│ └── SVGSketchExport.tsx
│ ├── with-native
│ ├── SVGPctUnit.js
│ ├── SVGWithStyleAndData.js
│ ├── SVGEdgeCaseWidth.js
│ ├── SVGSimple.js
│ ├── SVGWithStroke.js
│ ├── SVGClean.js
│ ├── SVGWithFill.js
│ ├── SVGMatrixNegative.js
│ └── SVGSketchExport.js
│ ├── with-native-for-typescript
│ ├── SVGPctUnit.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGSimple.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithFill.tsx
│ ├── SVGMatrixNegative.tsx
│ └── SVGSketchExport.tsx
│ ├── with-native-for-typescript_remove-fill
│ ├── SVGPctUnit.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGSimple.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGWithFill.tsx
│ ├── SVGClean.tsx
│ ├── SVGSketchExport.tsx
│ └── SVGMatrixNegative.tsx
│ ├── with-native-for-typescript_remove-stroke
│ ├── SVGPctUnit.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGSimple.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithFill.tsx
│ ├── SVGSketchExport.tsx
│ └── SVGMatrixNegative.tsx
│ ├── with-native-for-typescript_allow-override-fill
│ ├── SVGPctUnit.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGSimple.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGMatrixNegative.tsx
│ ├── SVGSketchExport.tsx
│ └── SVGWithFill.tsx
│ └── with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill
│ ├── SVGPctUnit.tsx
│ ├── SVGEdgeCaseWidth.tsx
│ ├── SVGWithStyleAndData.tsx
│ ├── SVGSimple.tsx
│ ├── SVGClean.tsx
│ ├── SVGWithStroke.tsx
│ ├── SVGMatrixNegative.tsx
│ ├── SVGSketchExport.tsx
│ └── SVGWithFill.tsx
├── .gitignore
├── src
├── case.ts
├── bin.ts
├── templates.ts
├── adjust-svg.ts
├── all-combinations.test.ts
└── transformer.ts
├── tsconfig.json
├── .github
└── workflows
│ └── build.yml
├── LICENSE
├── package.json
├── README.md
└── CHANGELOG.md
/.node-version:
--------------------------------------------------------------------------------
1 | 24
2 |
--------------------------------------------------------------------------------
/.husky/pre-push:
--------------------------------------------------------------------------------
1 | npm test
2 |
--------------------------------------------------------------------------------
/tests/fixtures/pct-unit.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # macos crap
2 | .DS_Store
3 |
4 | # node
5 | node_modules
6 |
7 | # build
8 | dist
9 |
--------------------------------------------------------------------------------
/tests/fixtures/with-style-and-data.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/case.ts:
--------------------------------------------------------------------------------
1 | import camelCase from "camelcase";
2 |
3 | export const toCamel = (s: string): string =>
4 | camelCase(s, { pascalCase: false });
5 | export const toPascal = (s: string): string =>
6 | camelCase(s, { pascalCase: true });
7 |
--------------------------------------------------------------------------------
/tests/fixtures/edge-case-width.svg:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGPctUnit.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGPctUnit = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGPctUnit;
12 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGPctUnit.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGPctUnit = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGPctUnit;
12 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGPctUnit = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGPctUnit;
12 |
--------------------------------------------------------------------------------
/tests/fixtures/simple.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGPctUnit.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGPctUnit = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGPctUnit;
12 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGWithStyleAndData.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStyleAndData = (props) => {
3 | return (
4 |
9 | );
10 | };
11 |
12 | export default SVGWithStyleAndData;
13 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithStyleAndData.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStyleAndData = (props) => {
3 | return (
4 |
9 | );
10 | };
11 |
12 | export default SVGWithStyleAndData;
13 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGEdgeCaseWidth.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGEdgeCaseWidth = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGEdgeCaseWidth;
12 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStyleAndData = (props: React.SVGProps) => {
3 | return (
4 |
9 | );
10 | };
11 |
12 | export default SVGWithStyleAndData;
13 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGEdgeCaseWidth.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGEdgeCaseWidth = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGEdgeCaseWidth;
12 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithStyleAndData.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStyleAndData = (props: React.SVGProps) => {
3 | return (
4 |
9 | );
10 | };
11 |
12 | export default SVGWithStyleAndData;
13 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGEdgeCaseWidth = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGEdgeCaseWidth;
12 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "NodeNext",
4 | "moduleResolution": "NodeNext",
5 | "esModuleInterop": false,
6 | "allowSyntheticDefaultImports": true,
7 | "strict": true,
8 | "skipLibCheck": true,
9 | "jsx": "react",
10 | "outDir": "dist",
11 | "rootDir": "src"
12 | },
13 | "ts-node": {
14 | "compilerOptions": {
15 | "module": "NodeNext"
16 | }
17 | },
18 | "exclude": ["tests/**"]
19 | }
20 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGEdgeCaseWidth.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGEdgeCaseWidth = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGEdgeCaseWidth;
12 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGSimple.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSimple = (props) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGSimple;
20 |
--------------------------------------------------------------------------------
/tests/fixtures/with-stroke.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGSimple.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSimple = (props) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGSimple;
20 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSimple = (props: React.SVGProps) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGSimple;
20 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGSimple.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSimple = (props: React.SVGProps) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGSimple;
20 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGPctUnit.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGPctUnit = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGPctUnit;
37 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGPctUnit.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGPctUnit = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGPctUnit;
37 |
--------------------------------------------------------------------------------
/tests/fixtures/matrix-negative.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGPctUnit = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGPctUnit;
38 |
--------------------------------------------------------------------------------
/tests/fixtures/with-fill.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGPctUnit = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGPctUnit;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGPctUnit = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGPctUnit;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGPctUnit = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGPctUnit;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGWithStyleAndData.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithStyleAndData = (props) => {
28 | return (
29 |
34 | );
35 | };
36 |
37 | export default SVGWithStyleAndData;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithStyleAndData.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithStyleAndData = (props) => {
28 | return (
29 |
34 | );
35 | };
36 |
37 | export default SVGWithStyleAndData;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGEdgeCaseWidth.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGEdgeCaseWidth = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGEdgeCaseWidth;
37 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGEdgeCaseWidth.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGEdgeCaseWidth = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGEdgeCaseWidth;
37 |
--------------------------------------------------------------------------------
/tests/fixtures/clean.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStyleAndData = (props: SvgProps) => {
29 | return (
30 |
35 | );
36 | };
37 |
38 | export default SVGWithStyleAndData;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStyleAndData = (props: SvgProps) => {
29 | return (
30 |
35 | );
36 | };
37 |
38 | export default SVGWithStyleAndData;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStyleAndData = (props: SvgProps) => {
29 | return (
30 |
35 | );
36 | };
37 |
38 | export default SVGWithStyleAndData;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStyleAndData = (props: SvgProps) => {
29 | return (
30 |
35 | );
36 | };
37 |
38 | export default SVGWithStyleAndData;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGEdgeCaseWidth = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGEdgeCaseWidth;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGPctUnit = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGPctUnit;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGEdgeCaseWidth = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGEdgeCaseWidth;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGEdgeCaseWidth = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGEdgeCaseWidth;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGPctUnit.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGPctUnit = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGPctUnit;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGEdgeCaseWidth = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGEdgeCaseWidth;
38 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGWithStroke.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStroke = (props) => {
3 | return (
4 |
27 | );
28 | };
29 |
30 | export default SVGWithStroke;
31 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithStroke.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStroke = (props) => {
3 | return (
4 |
27 | );
28 | };
29 |
30 | export default SVGWithStroke;
31 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStroke = (props: React.SVGProps) => {
3 | return (
4 |
27 | );
28 | };
29 |
30 | export default SVGWithStroke;
31 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGSimple.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGSimple = (props) => {
28 | return (
29 |
41 | );
42 | };
43 |
44 | export default SVGSimple;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGSimple.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGSimple = (props) => {
28 | return (
29 |
41 | );
42 | };
43 |
44 | export default SVGSimple;
45 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGClean.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGClean = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGClean;
12 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithStroke.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithStroke = (props: React.SVGProps) => {
3 | return (
4 |
27 | );
28 | };
29 |
30 | export default SVGWithStroke;
31 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | pull_request:
5 | branches: [main]
6 | push:
7 | branches: [main]
8 |
9 | jobs:
10 | test:
11 | strategy:
12 | matrix:
13 | os: [ubuntu-latest, windows-latest]
14 | runs-on: ${{ matrix.os }}
15 |
16 | steps:
17 | - uses: actions/checkout@v4
18 |
19 | - name: Use Node.js
20 | uses: actions/setup-node@v4
21 | with:
22 | node-version-file: "package.json"
23 | cache: "npm"
24 |
25 | - name: Handle Next.js Cache
26 | uses: actions/cache@v4
27 | with:
28 | path: .next/cache
29 | key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
30 | restore-keys: |
31 | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
32 |
33 | - name: Install dependencies
34 | run: npm ci
35 |
36 | - name: Test
37 | run: npm run test
38 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGClean.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGClean = (props) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGClean;
12 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGWithFill.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithFill = (props) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGWithFill;
20 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGEdgeCaseWidth = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGEdgeCaseWidth;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithFill.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithFill = (props) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGWithFill;
20 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGClean = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGClean;
12 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSimple = (props: SvgProps) => {
29 | return (
30 |
41 | );
42 | };
43 |
44 | export default SVGSimple;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSimple = (props: SvgProps) => {
29 | return (
30 |
41 | );
42 | };
43 |
44 | export default SVGSimple;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGEdgeCaseWidth.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGEdgeCaseWidth = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGEdgeCaseWidth;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSimple = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGSimple;
46 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithFill = (props: React.SVGProps) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGWithFill;
20 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGClean.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGClean = (props: React.SVGProps) => {
3 | return (
4 |
8 | );
9 | };
10 |
11 | export default SVGClean;
12 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSimple = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGSimple;
46 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithFill.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGWithFill = (props: React.SVGProps) => {
3 | return (
4 |
16 | );
17 | };
18 |
19 | export default SVGWithFill;
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Maxime Thirouin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGMatrixNegative.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGMatrixNegative = (props) => {
3 | return (
4 |
35 | );
36 | };
37 |
38 | export default SVGMatrixNegative;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithStyleAndData = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
48 | );
49 | };
50 |
51 | export default SVGWithStyleAndData;
52 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGMatrixNegative.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGMatrixNegative = (props) => {
3 | return (
4 |
35 | );
36 | };
37 |
38 | export default SVGMatrixNegative;
39 |
--------------------------------------------------------------------------------
/tests/components/with-web/SVGSketchExport.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSketchExport = (props) => {
3 | return (
4 |
22 | );
23 | };
24 |
25 | export default SVGSketchExport;
26 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGWithStyleAndData.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithStyleAndData = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
48 | );
49 | };
50 |
51 | export default SVGWithStyleAndData;
52 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGSketchExport.web.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSketchExport = (props) => {
3 | return (
4 |
22 | );
23 | };
24 |
25 | export default SVGSketchExport;
26 |
--------------------------------------------------------------------------------
/tests/fixtures/sketch-export.svg:
--------------------------------------------------------------------------------
1 |
2 |
13 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGMatrixNegative = (props: React.SVGProps) => {
3 | return (
4 |
35 | );
36 | };
37 |
38 | export default SVGMatrixNegative;
39 |
--------------------------------------------------------------------------------
/tests/components/with-web-for-typescript/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSketchExport = (props: React.SVGProps) => {
3 | return (
4 |
22 | );
23 | };
24 |
25 | export default SVGSketchExport;
26 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGMatrixNegative.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGMatrixNegative = (props: React.SVGProps) => {
3 | return (
4 |
35 | );
36 | };
37 |
38 | export default SVGMatrixNegative;
39 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGSketchExport.web.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | const SVGSketchExport = (props: React.SVGProps) => {
3 | return (
4 |
22 | );
23 | };
24 |
25 | export default SVGSketchExport;
26 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGWithStroke.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithStroke = (props) => {
28 | return (
29 |
52 | );
53 | };
54 |
55 | export default SVGWithStroke;
56 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithStroke.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithStroke = (props) => {
28 | return (
29 |
52 | );
53 | };
54 |
55 | export default SVGWithStroke;
56 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGSimple = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
50 | );
51 | };
52 |
53 | export default SVGSimple;
54 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGSimple.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGSimple = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
49 | );
50 | };
51 |
52 | export default SVGSimple;
53 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStroke = (props: SvgProps) => {
29 | return (
30 |
51 | );
52 | };
53 |
54 | export default SVGWithStroke;
55 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStroke = (props: SvgProps) => {
29 | return (
30 |
51 | );
52 | };
53 |
54 | export default SVGWithStroke;
55 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGClean.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGClean = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGClean;
37 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStroke = (props: SvgProps) => {
29 | return (
30 |
53 | );
54 | };
55 |
56 | export default SVGWithStroke;
57 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGClean.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGClean = (props) => {
28 | return (
29 |
33 | );
34 | };
35 |
36 | export default SVGClean;
37 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGWithFill.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithFill = (props) => {
28 | return (
29 |
41 | );
42 | };
43 |
44 | export default SVGWithFill;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithStroke = (props: SvgProps) => {
29 | return (
30 |
53 | );
54 | };
55 |
56 | export default SVGWithStroke;
57 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGWithFill.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGWithFill = (props) => {
28 | return (
29 |
41 | );
42 | };
43 |
44 | export default SVGWithFill;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithFill = (props: SvgProps) => {
29 | return (
30 |
41 | );
42 | };
43 |
44 | export default SVGWithFill;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGClean = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGClean;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGClean = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGClean;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGClean = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGClean;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithFill = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGWithFill;
46 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGClean = (props: SvgProps) => {
29 | return (
30 |
34 | );
35 | };
36 |
37 | export default SVGClean;
38 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithFill = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGWithFill;
46 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGWithFill = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGWithFill;
46 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSketchExport = (props: SvgProps) => {
29 | return (
30 |
41 | );
42 | };
43 |
44 | export default SVGSketchExport;
45 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGMatrixNegative.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGMatrixNegative = (props) => {
28 | return (
29 |
60 | );
61 | };
62 |
63 | export default SVGMatrixNegative;
64 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-from-svg",
3 | "description": "Transform SVG files into React components, Native and/or Web, JavaScript and TypeScript. Without shitload of dependencies.",
4 | "version": "8.0.2",
5 | "license": "MIT",
6 | "repository": "https://github.com/MoOx/react-from-svg",
7 | "author": {
8 | "name": "Maxime Thirouin",
9 | "url": "https://github.com/MoOx"
10 | },
11 | "type": "module",
12 | "exports": "./dist/bin.js",
13 | "keywords": [
14 | "react-native-svg",
15 | "react-native-web",
16 | "react-native",
17 | "react",
18 | "svg-to-react",
19 | "svg",
20 | "svgr-cli",
21 | "svgr"
22 | ],
23 | "bin": {
24 | "react-from-svg": "./dist/bin.js"
25 | },
26 | "files": [
27 | "dist",
28 | "!dist/**.test.js"
29 | ],
30 | "scripts": {
31 | "prepare": "husky",
32 | "build": "tsc",
33 | "format:generated": "prettier --write tests/components",
34 | "test:build:all": "node dist/all-combinations.test.js",
35 | "test": "npm run build && npm run test:build:all",
36 | "prepublishOnly": "npm run build",
37 | "release": "npmpub"
38 | },
39 | "dependencies": {
40 | "camelcase": "^8.0.0",
41 | "glob": "^11.0.1",
42 | "meow": "^13.2.0",
43 | "mkdirp": "^3.0.1"
44 | },
45 | "devDependencies": {
46 | "@types/react": "^19.1.0",
47 | "husky": "^9.1.7",
48 | "npmpub": "^5.0.0",
49 | "prettier": "^3.5.3",
50 | "react": "^19.1.0",
51 | "react-native-svg": "^15.11.2",
52 | "typescript": "^5.8.0"
53 | },
54 | "prettier": {
55 | "trailingComma": "all"
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGMatrixNegative.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGMatrixNegative = (props) => {
28 | return (
29 |
60 | );
61 | };
62 |
63 | export default SVGMatrixNegative;
64 |
--------------------------------------------------------------------------------
/tests/components/with-native/SVGSketchExport.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGSketchExport = (props) => {
28 | return (
29 |
47 | );
48 | };
49 |
50 | export default SVGSketchExport;
51 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSketchExport = (props: SvgProps) => {
29 | return (
30 |
42 | );
43 | };
44 |
45 | export default SVGSketchExport;
46 |
--------------------------------------------------------------------------------
/tests/components/with-native_with-web/SVGSketchExport.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | const SVGSketchExport = (props) => {
28 | return (
29 |
47 | );
48 | };
49 |
50 | export default SVGSketchExport;
51 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGClean = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGClean;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGClean.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGClean = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
38 | );
39 | };
40 |
41 | export default SVGClean;
42 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGMatrixNegative = (props: SvgProps) => {
29 | return (
30 |
60 | );
61 | };
62 |
63 | export default SVGMatrixNegative;
64 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-stroke/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGMatrixNegative = (props: SvgProps) => {
29 | return (
30 |
60 | );
61 | };
62 |
63 | export default SVGMatrixNegative;
64 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGMatrixNegative = (props: SvgProps) => {
29 | return (
30 |
61 | );
62 | };
63 |
64 | export default SVGMatrixNegative;
65 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSketchExport = (props: SvgProps) => {
29 | return (
30 |
48 | );
49 | };
50 |
51 | export default SVGSketchExport;
52 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGMatrixNegative = (props: SvgProps) => {
29 | return (
30 |
61 | );
62 | };
63 |
64 | export default SVGMatrixNegative;
65 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_with-web-for-typescript/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { SvgProps } from "react-native-svg";
28 | const SVGSketchExport = (props: SvgProps) => {
29 | return (
30 |
48 | );
49 | };
50 |
51 | export default SVGSketchExport;
52 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithStroke = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
63 | );
64 | };
65 |
66 | export default SVGWithStroke;
67 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGWithStroke.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithStroke = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
65 | );
66 | };
67 |
68 | export default SVGWithStroke;
69 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGMatrixNegative = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
68 | );
69 | };
70 |
71 | export default SVGMatrixNegative;
72 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGMatrixNegative.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGMatrixNegative = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
69 | );
70 | };
71 |
72 | export default SVGMatrixNegative;
73 |
--------------------------------------------------------------------------------
/src/bin.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | import meow from "meow";
4 | import { make } from "./transformer.js";
5 |
6 | const cli = meow(
7 | `
8 | Usage
9 | $ react-from-svg [--with-native|--with-web]
10 |
11 | Options
12 | --with-native, -rn Output code for react-native-svg
13 | --with-native-for-typescript, -rnts Output code for react-native-svg with TypeScript
14 | --with-web, -rnw Output code for DOM. If --with-native is also used, will be output as .web.js files
15 | --with-web-for-typescript, -rnwts Output code for DOM with TypeScript. If --with-native is also used, will be output as .web.tsx files
16 | --remove-fill, -rf Remove all 'fill' properties from SVGs, convenient for icons
17 | --remove-stroke, -rs Remove all 'stroke' properties from SVGs, convenient for icons
18 | --allow-override-fill, -aof Replace all 'fill' properties by a dynamic prop (fills) in SVGs, e.g. fill={fills[N]}.
19 |
20 | Example
21 | $ react-from-svg src/svgs src/svgs/components --with-web-for-typescript --allow-override-fill
22 | `,
23 | {
24 | importMeta: import.meta,
25 | flags: {
26 | withNative: { type: "boolean", shortFlag: "rn" },
27 | withNativeForTypescript: { type: "boolean", shortFlag: "rnts" },
28 | withWeb: { type: "boolean", shortFlag: "rnw" },
29 | withWebForTypescript: { type: "boolean", shortFlag: "rnwts" },
30 | removeFill: { type: "boolean", shortFlag: "rf" },
31 | removeStroke: { type: "boolean", shortFlag: "rs" },
32 | allowOverrideFill: { type: "boolean", shortFlag: "aof" },
33 | },
34 | },
35 | );
36 |
37 | if (
38 | cli.flags.withNative === undefined &&
39 | cli.flags.withNativeForTypescript === undefined &&
40 | cli.flags.withWeb === undefined &&
41 | cli.flags.withWebForTypescript === undefined
42 | ) {
43 | console.error(
44 | "You should at least choose an output option (one of --with-*)!",
45 | );
46 | cli.showHelp();
47 | process.exit(1);
48 | }
49 |
50 | make(cli.input as [string, string], cli.flags);
51 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGSketchExport = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
60 | );
61 | };
62 |
63 | export default SVGSketchExport;
64 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGSketchExport.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGSketchExport = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
59 | );
60 | };
61 |
62 | export default SVGSketchExport;
63 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_allow-override-fill/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithFill = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
64 | );
65 | };
66 |
67 | export default SVGWithFill;
68 |
--------------------------------------------------------------------------------
/tests/components/with-native-for-typescript_remove-fill_remove-stroke_allow-override-fill/SVGWithFill.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import Svg, {
3 | Circle,
4 | ClipPath,
5 | Defs,
6 | Ellipse,
7 | ForeignObject,
8 | G,
9 | Image,
10 | Line,
11 | LinearGradient,
12 | Marker,
13 | Mask,
14 | Path,
15 | Pattern,
16 | Polygon,
17 | Polyline,
18 | RadialGradient,
19 | Rect,
20 | Stop,
21 | Symbol,
22 | Text,
23 | TextPath,
24 | TSpan as Tspan,
25 | Use,
26 | } from "react-native-svg";
27 | import type { ColorValue } from "react-native";
28 | import type { SvgProps } from "react-native-svg";
29 | const SVGWithFill = ({
30 | fills,
31 | ...props
32 | }: SvgProps & { fills?: (ColorValue | undefined)[] }) => {
33 | return (
34 |
64 | );
65 | };
66 |
67 | export default SVGWithFill;
68 |
--------------------------------------------------------------------------------
/src/templates.ts:
--------------------------------------------------------------------------------
1 | const sep = ";\n";
2 |
3 | // Helper for prop signature
4 | function getPropsSignature(
5 | allowOverrideFill: boolean,
6 | typescript: boolean,
7 | native: boolean,
8 | ): string {
9 | const fillsType = `{fills?: (${native ? "ColorValue" : "string"} | undefined)[]}`;
10 | const optionalPropsType = typescript
11 | ? ` : ${
12 | native ? "SvgProps" : "React.SVGProps"
13 | }${allowOverrideFill ? " & " + fillsType : ""}`
14 | : "";
15 | return `(${allowOverrideFill ? "{ fills, ...props }" : "props"}${optionalPropsType})`;
16 | }
17 |
18 | const importReact = (): string => {
19 | return "import React from 'react'";
20 | };
21 |
22 | const jsExport = (
23 | name: string,
24 | svgOutput: string,
25 | allowOverrideFill: boolean = false,
26 | ): string => {
27 | const content =
28 | `const ${name} = ${getPropsSignature(allowOverrideFill, false, false)} => {
29 | return (${svgOutput});
30 | }` + sep;
31 | return `${content}
32 | export default ${name}`;
33 | };
34 |
35 | const tsxExport = (
36 | name: string,
37 | svgOutput: string,
38 | native: boolean,
39 | allowOverrideFill: boolean = false,
40 | ): string => {
41 | const content =
42 | `const ${name} = ${getPropsSignature(allowOverrideFill, true, native)} => {
43 | return (${svgOutput});
44 | }` + sep;
45 | return `${content}
46 | export default ${name}`;
47 | };
48 |
49 | const web = (
50 | svgOutput: string,
51 | name: string,
52 | allowOverrideFill: boolean = false,
53 | ): string => {
54 | return (
55 | importReact() + sep + jsExport(name, svgOutput, allowOverrideFill) + sep
56 | );
57 | };
58 |
59 | const RNSvgModules = [
60 | "Circle",
61 | "ClipPath",
62 | "Defs",
63 | "Ellipse",
64 | "ForeignObject",
65 | "G",
66 | "Image",
67 | "Line",
68 | "LinearGradient",
69 | "Marker",
70 | "Mask",
71 | "Path",
72 | "Pattern",
73 | "Polygon",
74 | "Polyline",
75 | "RadialGradient",
76 | "Rect",
77 | "Stop",
78 | "Symbol",
79 | "Text",
80 | "TextPath",
81 | "TSpan as Tspan",
82 | "Use",
83 | ];
84 |
85 | const importReactNativeSvg = (
86 | typescript: boolean,
87 | allowOverrideFill: boolean,
88 | ): string => {
89 | return `import Svg, {
90 | ${RNSvgModules.join(",")}
91 | } from 'react-native-svg';${
92 | typescript && allowOverrideFill
93 | ? `import type { ColorValue } from 'react-native';`
94 | : ""
95 | }${typescript ? `import type { SvgProps } from 'react-native-svg';` : ""}
96 | `;
97 | };
98 |
99 | const native = (
100 | svgOutput: string,
101 | name: string,
102 | allowOverrideFill: boolean = false,
103 | ): string => {
104 | return (
105 | importReact() +
106 | sep +
107 | importReactNativeSvg(false, allowOverrideFill) +
108 | sep +
109 | jsExport(name, svgOutput, allowOverrideFill) +
110 | sep
111 | );
112 | };
113 |
114 | const nativeForTypescript = (
115 | svgOutput: string,
116 | name: string,
117 | allowOverrideFill: boolean = false,
118 | ): string => {
119 | return (
120 | importReact() +
121 | sep +
122 | importReactNativeSvg(true, allowOverrideFill) +
123 | sep +
124 | tsxExport(name, svgOutput, true, allowOverrideFill) +
125 | sep
126 | );
127 | };
128 |
129 | const webForTypescript = (
130 | svgOutput: string,
131 | name: string,
132 | allowOverrideFill: boolean = false,
133 | ): string => {
134 | return (
135 | importReact() +
136 | sep +
137 | tsxExport(name, svgOutput, false, allowOverrideFill) +
138 | sep
139 | );
140 | };
141 |
142 | export { web, native, nativeForTypescript, webForTypescript };
143 |
--------------------------------------------------------------------------------
/src/adjust-svg.ts:
--------------------------------------------------------------------------------
1 | import { toCamel, toPascal } from "./case.js";
2 |
3 | const tagsToRemove = ["title", "desc"];
4 |
5 | const cleanupStart = (svg: string): string => {
6 | let result = svg
7 | .replace(/'/g, '"')
8 | .replace(/\sversion="1.1"/g, "")
9 | .replace(/<\?xml(.*)\?>/g, "")
10 | .replace(/\sxmlns="http:\/\/www\.w3\.org\/2000\/svg"/g, "")
11 | .replace(/\sxmlns:xlink="http:\/\/www.w3.org\/1999\/xlink"/g, "")
12 | .replace(//g, "");
13 |
14 | // Remove tags with or without attributes
15 | tagsToRemove.forEach((tag) => {
16 | result = result.replace(new RegExp(`<${tag}[^>]*>.*?<\/${tag}>`, "gs"), "");
17 | });
18 |
19 | return result;
20 | };
21 |
22 | const prepareSvgProps = (svg: string): string => {
23 | return svg
24 | .replace(/