mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-01 15:37:32 +08:00
Fix ts icon generation formatting
Improved icon generation to use manual formatting instead of JSON.stringify for better readability and consistency with other icon files.
This commit is contained in:
@@ -18,8 +18,8 @@ import { galaxyLogo } from "@/components/icons/galaxyIcons";
|
||||
|
||||
---
|
||||
|
||||
- **galaxyLogo**: `import { galaxyLogo } from '@/components/icons/galaxyIcons';`
|
||||
- **textLarger**: `import { textLarger } from '@/components/icons/galaxyIcons';`
|
||||
- **textSmaller**: `import { textSmaller } from '@/components/icons/galaxyIcons';`
|
||||
- **galaxyLogo**: `import { galaxyLogo } from "@/components/icons/galaxyIcons";`
|
||||
- **textLarger**: `import { textLarger } from "@/components/icons/galaxyIcons";`
|
||||
- **textSmaller**: `import { textSmaller } from "@/components/icons/galaxyIcons";`
|
||||
|
||||
---
|
||||
|
||||
@@ -101,16 +101,16 @@ function makeMarkdown(iconDefinitions) {
|
||||
content += "## Usage\n\n";
|
||||
content += "```vue\n";
|
||||
content += "<script setup>\n";
|
||||
content += "import { galaxyLogo } from '@/components/icons/galaxyIcons';\n";
|
||||
content += 'import { galaxyLogo } from "@/components/icons/galaxyIcons";\n';
|
||||
content += "</script>\n\n";
|
||||
content += "<template>\n";
|
||||
content += ' <FontAwesomeIcon :icon="galaxyLogo" />\n';
|
||||
content += ' <FontAwesomeIcon :icon="galaxyLogo" />\n';
|
||||
content += "</template>\n";
|
||||
content += "```\n\n";
|
||||
content += "---\n\n";
|
||||
|
||||
iconDefinitions.forEach((icon) => {
|
||||
content += `- **${icon.iconName}**: \`import { ${icon.iconName} } from '@/components/icons/galaxyIcons';\`\n`;
|
||||
content += `- **${icon.iconName}**: \`import { ${icon.iconName} } from "@/components/icons/galaxyIcons";\`\n`;
|
||||
});
|
||||
|
||||
content += "\n---\n";
|
||||
|
||||
@@ -23,7 +23,7 @@ function generateIconsTypeScript() {
|
||||
|
||||
// Galaxy custom icons
|
||||
// Generated from: ${iconsJsonPath}
|
||||
// To regenerate, run: npm run icons
|
||||
// To regenerate: node icons/generate_ts_icons.js
|
||||
|
||||
// Matches FontAwesome's structure
|
||||
export interface GalaxyIconDefinition {
|
||||
@@ -41,21 +41,29 @@ export type IconLike = IconDefinition | GalaxyIconDefinition;
|
||||
// Convert icon name to camelCase for JavaScript export
|
||||
const exportName = icon.iconName;
|
||||
|
||||
content += `export const ${exportName}: GalaxyIconDefinition = ${JSON.stringify(
|
||||
{
|
||||
iconName: icon.iconName,
|
||||
prefix: icon.prefix,
|
||||
icon: icon.icon,
|
||||
},
|
||||
null,
|
||||
4,
|
||||
)};
|
||||
// Format the icon data manually to match the expected style
|
||||
const iconData = icon.icon;
|
||||
const formattedIcon = `{
|
||||
iconName: "${icon.iconName}",
|
||||
prefix: "${icon.prefix}",
|
||||
icon: [
|
||||
${iconData[0]},
|
||||
${iconData[1]},
|
||||
[],
|
||||
"",
|
||||
[
|
||||
${iconData[4].map((path) => `"${path}"`).join(",\n ")},
|
||||
],
|
||||
],
|
||||
};`;
|
||||
|
||||
content += `export const ${exportName}: GalaxyIconDefinition = ${formattedIcon}
|
||||
|
||||
`;
|
||||
});
|
||||
|
||||
// Write the TypeScript file
|
||||
fs.writeFileSync(outputPath, content);
|
||||
fs.writeFileSync(outputPath, content.trimEnd() + "\n");
|
||||
console.log(`Generated Galaxy icons TypeScript exports at: ${outputPath}`);
|
||||
console.log(`Exported ${icons.length} icons: ${icons.map((i) => i.iconName).join(", ")}`);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
|
||||
// Galaxy custom icons
|
||||
// Generated from: /Users/dannon/work/galaxy/client/src/assets/icons.json
|
||||
// To regenerate, run: npm run icons
|
||||
// To regenerate: node icons/generate_ts_icons.js
|
||||
|
||||
// Matches FontAwesome's structure
|
||||
export interface GalaxyIconDefinition {
|
||||
|
||||
Reference in New Issue
Block a user