Skip to content

Commit 2978ef4

Browse files
author
xiazhigang
committed
Merge branch 'master' of github.com:yocdev/tarocodegen
2 parents 9bc7b8a + 80a66b9 commit 2978ef4

File tree

11 files changed

+139
-40
lines changed

11 files changed

+139
-40
lines changed

example/icons/IconAlertTriangle.rn.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function IconAlertTriangle(props) {
77
xmlns="http://www.w3.org/2000/svg"
88
width={24}
99
height={24}
10+
viewBox="0 0 24 24"
1011
fill="none"
1112
stroke={props.color}
1213
strokeWidth={2}

example/icons/IconAlertTriangle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function IconAlertTriangle(props) {
66
xmlns="http://www.w3.org/2000/svg"
77
width={24}
88
height={24}
9+
viewBox="0 0 24 24"
910
fill="none"
1011
stroke={props.color}
1112
strokeWidth={2}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from "react";
2+
import Svg, { Path } from "react-native-svg";
3+
4+
function IconChevronRight(props) {
5+
return (
6+
<Svg
7+
xmlns="http://www.w3.org/2000/svg"
8+
width={24}
9+
height={24}
10+
viewBox="0 0 24 24"
11+
fill="none"
12+
stroke="currentColor"
13+
strokeWidth={2}
14+
strokeLinecap="round"
15+
strokeLinejoin="round"
16+
className="prefix__feather prefix__feather-chevron-right"
17+
{...props}
18+
>
19+
<Path d="M9 18l6-6-6-6" />
20+
</Svg>
21+
);
22+
}
23+
24+
export default IconChevronRight;

example/icons/IconChevronRight.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from "react";
2+
3+
function IconChevronRight(props) {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
width={24}
8+
height={24}
9+
viewBox="0 0 24 24"
10+
fill="none"
11+
stroke="currentColor"
12+
strokeWidth={2}
13+
strokeLinecap="round"
14+
strokeLinejoin="round"
15+
className="prefix__feather prefix__feather-chevron-right"
16+
{...props}
17+
>
18+
<path d="M9 18l6-6-6-6" />
19+
</svg>
20+
);
21+
}
22+
23+
export default IconChevronRight;
Lines changed: 1 addition & 0 deletions
Loading

global.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
declare module 'prettier'
2-
declare module '@svgr/core'
1+
declare module "prettier";
2+
declare module "@svgr/core";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yocdev/tarocodegen",
3-
"version": "1.1.4",
3+
"version": "1.1.6",
44
"author": "[email protected]",
55
"license": "MIT",
66
"bin": {

src/icons/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ const svgrGenerator = async (fileDir: string, componentName: string) => {
139139
svgCode,
140140
{
141141
native: platform === "rn",
142+
dimensions: false,
142143
replaceAttrValues: {
143144
"#000": "{props.color}",
144145
"#000000": "{props.color}",
146+
currentColor: "{props.color}",
145147
},
146148
plugins: [
147149
"@svgr/plugin-svgo",

src/util/transformSvg.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as path from "path";
2+
import * as fs from "fs";
3+
// @ts-ignore
4+
import svgr from "@svgr/core";
5+
6+
function loadSvg() {
7+
const svgCode = fs.readFileSync(
8+
path.resolve(__dirname, "../../example/icons/source/alert-triangle.svg"),
9+
"utf-8"
10+
);
11+
console.log(svgCode);
12+
svgr(
13+
svgCode,
14+
{
15+
native: true,
16+
dimensions: false,
17+
replaceAttrValues: {
18+
"#000": "{props.color}",
19+
"#000000": "{props.color}",
20+
currentColor: "{props.color}",
21+
},
22+
plugins: [
23+
"@svgr/plugin-svgo",
24+
"@svgr/plugin-jsx",
25+
"@svgr/plugin-prettier",
26+
],
27+
},
28+
{ componentName: "MyComponent" }
29+
).then((jsCode: string) => {
30+
console.log("--js", jsCode);
31+
});
32+
}
33+
34+
loadSvg();
35+
36+
// function template(
37+
// { template }: any,
38+
// opts: any,
39+
// { imports, componentName, props, jsx, exports }: any
40+
// ) {
41+
// console.log(jsx, opts);
42+
// return template.ast`
43+
// ${imports}
44+
// const ${componentName} = (${props}) => ${jsx}
45+
// ${exports}
46+
// `;
47+
// }

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"esModuleInterop": true,
66
"outDir": "dist"
77
},
8-
"include": ["src", "./global.d.ts"]
8+
"include": ["src", "global.d.ts"]
99
}

0 commit comments

Comments
 (0)