Skip to content

Commit cab461e

Browse files
committed
feat: symbol_url is optional to against local_svgs
1 parent b2a7d45 commit cab461e

18 files changed

+290
-12
lines changed

scripts/config/demo-js-nonurl.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"use_typescript": false,
3+
"save_dir": "./snapshots/demo-js-nonurl",
4+
"trim_icon_prefix": "icon",
5+
"default_icon_size": 18,
6+
"local_svgs": "./localSvgs"
7+
}

scripts/config/demo-ts-nonurl.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"use_typescript": true,
3+
"save_dir": "./snapshots/demo-ts-nonurl",
4+
"trim_icon_prefix": "icon",
5+
"default_icon_size": 20,
6+
"local_svgs": "./localSvgs"
7+
}

scripts/update-snapshot.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ npx ts-node src/commands/createIcon.ts
77

88
cp -f ./scripts/config/demo-ts.json ./iconfont.json
99
npx ts-node src/commands/createIcon.ts
10+
11+
cp -f ./scripts/config/demo-js-nonurl.json ./iconfont.json
12+
npx ts-node src/commands/createIcon.ts
13+
14+
cp -f ./scripts/config/demo-ts-nonurl.json ./iconfont.json
15+
npx ts-node src/commands/createIcon.ts
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
3+
import { FunctionComponent } from 'react';
4+
// Don't forget to install package: @types/react-native
5+
import { ViewProps } from 'react-native';
6+
import { GProps } from 'react-native-svg';
7+
8+
interface Props extends GProps, ViewProps {
9+
size?: number;
10+
color?: string | string[];
11+
}
12+
13+
declare const IconClassSvg: FunctionComponent<Props>;
14+
15+
export default IconClassSvg;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* eslint-disable */
2+
3+
import React from 'react';
4+
import { SvgCss } from 'react-native-svg';
5+
6+
const xml = `
7+
<svg xmlns="http://www.w3.org/2000/svg">
8+
<style type="text/css">
9+
<![CDATA[
10+
11+
circle.myGreen {
12+
stroke: #006600;
13+
fill: #00cc00;
14+
}
15+
circle.myRed {
16+
stroke: #660000;
17+
fill: #cc0000;
18+
}
19+
20+
]]>
21+
</style>
22+
23+
<circle class="myGreen" cx="40" cy="40" r="24"/>
24+
<circle class="myRed" cx="40" cy="100" r="24"/>
25+
</svg>
26+
`
27+
28+
let IconClassSvg = ({ size, color, ...rest }) => {
29+
return (
30+
<SvgCss xml={xml} width={size} height={size} {...rest} />
31+
);
32+
};
33+
34+
IconClassSvg.defaultProps = {
35+
size: 18,
36+
};
37+
38+
IconClassSvg = React.memo ? React.memo(IconClassSvg) : IconClassSvg;
39+
40+
export default IconClassSvg;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
3+
import { FunctionComponent } from 'react';
4+
// Don't forget to install package: @types/react-native
5+
import { ViewProps } from 'react-native';
6+
import { GProps } from 'react-native-svg';
7+
8+
interface Props extends GProps, ViewProps {
9+
size?: number;
10+
color?: string | string[];
11+
}
12+
13+
declare const IconInlineStyle: FunctionComponent<Props>;
14+
15+
export default IconInlineStyle;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable */
2+
3+
import React from 'react';
4+
import { SvgCss } from 'react-native-svg';
5+
6+
const xml = `
7+
<svg xmlns="http://www.w3.org/2000/svg">
8+
<style type="text/css">
9+
<![CDATA[
10+
11+
circle {
12+
stroke: #006600;
13+
fill: #00cc00;
14+
}
15+
16+
]]>
17+
</style>
18+
<circle cx="40" cy="40" r="24"/>
19+
</svg>
20+
`
21+
22+
let IconInlineStyle = ({ size, color, ...rest }) => {
23+
return (
24+
<SvgCss xml={xml} width={size} height={size} {...rest} />
25+
);
26+
};
27+
28+
IconInlineStyle.defaultProps = {
29+
size: 18,
30+
};
31+
32+
IconInlineStyle = React.memo ? React.memo(IconInlineStyle) : IconInlineStyle;
33+
34+
export default IconInlineStyle;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
3+
import { FunctionComponent } from 'react';
4+
// Don't forget to install package: @types/react-native
5+
import { ViewProps } from 'react-native';
6+
import { GProps } from 'react-native-svg';
7+
8+
interface Props extends GProps, ViewProps {
9+
size?: number;
10+
color?: string | string[];
11+
}
12+
13+
declare const IconNormal: FunctionComponent<Props>;
14+
15+
export default IconNormal;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-disable */
2+
3+
import React from 'react';
4+
import { SvgXml } from 'react-native-svg';
5+
6+
const xml = `
7+
<svg xmlns="http://www.w3.org/2000/svg">
8+
<circle cx="40" cy="40" r="24" stroke="#000000" fill="#00ff00"/>
9+
</svg>
10+
`
11+
12+
let IconNormal = ({ size, color, ...rest }) => {
13+
return (
14+
<SvgXml xml={xml} width={size} height={size} {...rest} />
15+
);
16+
};
17+
18+
IconNormal.defaultProps = {
19+
size: 18,
20+
};
21+
22+
IconNormal = React.memo ? React.memo(IconNormal) : IconNormal;
23+
24+
export default IconNormal;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
3+
import { FunctionComponent } from 'react';
4+
// Don't forget to install package: @types/react-native
5+
import { ViewProps } from 'react-native';
6+
import { GProps } from 'react-native-svg';
7+
8+
interface Props extends GProps, ViewProps {
9+
size?: number;
10+
color?: string | string[];
11+
}
12+
13+
declare const IconStyle: FunctionComponent<Props>;
14+
15+
export default IconStyle;

0 commit comments

Comments
 (0)