Skip to content

Commit 71ee908

Browse files
committed
some improvements
- set `mergeAmbiguousCharacters` to true since some of the icons contain numbers in the name: circle-step-1 > CircleStep_1Icon vs CircleStep1Icon - rename some variables - shorten some code
1 parent eb7e480 commit 71ee908

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/generate-icon-components.mjs

+10-9
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,25 @@ const promises = icons.map((svg) => {
2828
await Promise.all(promises);
2929

3030
async function generateComponent(iconName) {
31-
const componentName = pascalCase(iconName);
31+
const componentName = pascalCase(iconName, { mergeAmbiguousCharacters: true });
3232

33-
const iconContent = await readFile(join(ICON_FOLDER, iconName + ".svg"));
34-
const iconContentWithAttributes = iconContent
33+
const iconContent = (await readFile(join(ICON_FOLDER, iconName + ".svg")))
3534
.toString()
36-
.replace(">", " ...attributes>"); // We assume the first closing element is the svg element
35+
.replace(">", " ...attributes>"); // We assume the first closing bracket belongs to the svg element
3736

38-
const component = `// THIS FILE IS GENERATED. ANY CHANGES TO THIS FILE WILL BE LOST.
37+
const componentContent = `// THIS FILE IS GENERATED. ANY CHANGES TO THIS FILE WILL BE LOST.
3938
import type { TOC } from '@ember/component/template-only';
4039
4140
export interface ${componentName}IconSignature {
42-
Element: SVGElement;
41+
Element: SVGSVGElement;
4342
}
4443
45-
export const ${componentName}Icon: TOC<${componentName}IconSignature> = <template>${iconContentWithAttributes}</template>;
46-
export default ${componentName}Icon;`;
44+
export const ${componentName}Icon: TOC<${componentName}IconSignature> = <template>${iconContent}</template>;`;
4745

48-
await writeFile(join(COMPONENT_ICON_FOLDER, iconName + ".gts"), component);
46+
await writeFile(
47+
join(COMPONENT_ICON_FOLDER, iconName + ".gts"),
48+
componentContent,
49+
);
4950
}
5051

5152
async function prepareOutputDir() {

0 commit comments

Comments
 (0)