Skip to content

Commit 15f9025

Browse files
committed
feat: Remove property summary_component_name
1 parent 4655637 commit 15f9025

File tree

13 files changed

+17
-35
lines changed

13 files changed

+17
-35
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ npx iconfont-init
3434
"save_dir": "./src/components/iconfont",
3535
"trim_icon_prefix": "icon",
3636
"unit": "px",
37-
"default_icon_size": 18,
38-
"summary_component_name": "Icon"
37+
"default_icon_size": 18
3938
}
4039
```
4140
### 配置参数说明:
@@ -65,10 +64,6 @@ npx iconfont-init
6564
### default_icon_size
6665
我们将为每个生成的图标组件加入默认的字体大小,当然,你也可以通过传入props的方式改变这个size值。
6766

68-
69-
### summary_component_name
70-
就是汇总组件的名称,默认名称为`Icon`,您也可以改成`IconFont`或者您喜欢的名字。记住,它是一个变量名,您必须遵守Javascript中关于变量的语法规则。以及作为组件名,请尽量以大写字母开头。
71-
7267
# Step 3
7368
开始生成React标准组件
7469
```bash
@@ -84,7 +79,7 @@ npx iconfont-h5
8479
1、使用汇总`Icon`组件:
8580
```typescript jsx
8681
import React from 'react';
87-
import Icon from '../src/iconfont/Icon';
82+
import Icon from '../src/iconfont';
8883

8984
export const App = () => {
9085
return (

scripts/config/demo-js.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"save_dir": "./snapshots/demo-js",
55
"trim_icon_prefix": "icon",
66
"unit": "px",
7-
"default_icon_size": 14,
8-
"summary_component_name": "Custom_Icon"
7+
"default_icon_size": 14
98
}

scripts/config/demo-ts.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"save_dir": "./snapshots/demo-ts",
55
"trim_icon_prefix": "icon",
66
"unit": "rem",
7-
"default_icon_size": 16,
8-
"summary_component_name": "IconFont"
7+
"default_icon_size": 16
98
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ interface Props extends DOMAttributes<SVGElement> {
1010
className?: string;
1111
}
1212

13-
export declare const Custom_Icon: FunctionComponent<Props>;
13+
export declare const IconFont: FunctionComponent<Props>;
1414

15-
export default Custom_Icon;
15+
export default IconFont;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import IconAlipay from './IconAlipay';
55
import IconUser from './IconUser';
66
import IconSetup from './IconSetup';
77

8-
export const Custom_Icon = ({ name, ...rest }) => {
8+
export const IconFont = ({ name, ...rest }) => {
99
switch (name) {
1010
case 'alipay':
1111
return <IconAlipay {...rest} />;
@@ -19,4 +19,4 @@ export const Custom_Icon = ({ name, ...rest }) => {
1919
return null;
2020
};
2121

22-
export default Custom_Icon;
22+
export default IconFont;

src/libs/generateComponent.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
replaceSingleIconContent,
1717
replaceSize,
1818
replaceSizeUnit,
19-
replaceSummaryIcon,
2019
} from './replace';
2120
import { whitespace } from './whitespace';
2221
import { copyTemplate } from './copyTemplate';
@@ -88,13 +87,10 @@ export const generateComponent = (data: XmlData, config: Config) => {
8887
let typeDefinitionFile = getTemplate(`Icon.d.ts`);
8988

9089
typeDefinitionFile = replaceNames(typeDefinitionFile, names);
91-
typeDefinitionFile = replaceSummaryIcon(typeDefinitionFile, config.summary_component_name);
92-
fs.writeFileSync(path.join(saveDir, config.summary_component_name + '.d.ts'), typeDefinitionFile);
90+
fs.writeFileSync(path.join(saveDir, 'index.d.ts'), typeDefinitionFile);
9391
}
9492

95-
iconFile = replaceSummaryIcon(iconFile, config.summary_component_name);
96-
97-
fs.writeFileSync(path.join(saveDir, config.summary_component_name + jsxExtension), iconFile);
93+
fs.writeFileSync(path.join(saveDir, 'index' + jsxExtension), iconFile);
9894

9995
console.log(`\n${colors.green('√')} All icons have putted into dir: ${colors.green(config.save_dir)}\n`);
10096
};

src/libs/getConfig.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface Config {
1010
trim_icon_prefix: string;
1111
unit: string;
1212
default_icon_size: number;
13-
summary_component_name: string;
1413
}
1514

1615
let cacheConfig: Config;
@@ -40,7 +39,6 @@ export const getConfig = () => {
4039

4140
config.save_dir = config.save_dir || defaultConfig.save_dir;
4241
config.default_icon_size = config.default_icon_size || defaultConfig.default_icon_size;
43-
config.summary_component_name = config.summary_component_name || defaultConfig.summary_component_name;
4442
config.unit = config.unit || defaultConfig.unit;
4543

4644
cacheConfig = config;

src/libs/iconfont.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"save_dir": "./src/components/iconfont",
55
"trim_icon_prefix": "icon",
66
"unit": "px",
7-
"default_icon_size": 18,
8-
"summary_component_name": "Icon"
7+
"default_icon_size": 18
98
}

src/libs/replace.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ export const replaceImports = (content: string, imports: string[]) => {
3131
return content.replace(/#imports#/g, imports.map((item) => `import ${item} from './${item}';`).join('\n'));
3232
};
3333

34-
export const replaceSummaryIcon = (content: string, iconName: string) => {
35-
return content.replace(/#SummaryIcon#/g, iconName);
36-
};
37-
3834
export const replaceSizeUnit = (content: string, unit: string) => {
3935
return content.replace(/\{size\}/g, `{size + '${unit}'}`);
4036
};

0 commit comments

Comments
 (0)