From 54ae3aa3c48741ebe4f2dd0d3fc0f880cba420e0 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 4 Jul 2024 12:04:43 +0100 Subject: [PATCH] refactor: add getIconPreview --- scripts/generators/generateFonts.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/generators/generateFonts.ts b/scripts/generators/generateFonts.ts index fb700fe2..ffca1f03 100644 --- a/scripts/generators/generateFonts.ts +++ b/scripts/generators/generateFonts.ts @@ -107,11 +107,7 @@ const buildFontFile = async (type: FontType, fontResult: GenerateFontResult, inp * @returns {string} Dart definition line used in body of `Icons.dart`. */ function getDartIconDefinition(iconName: string, unicode: string, type: FontType | undefined): string { - const name_link = `${iconName}_${type === undefined ? "round" : type}`; - const readableName = iconName - .split("_") - .map((e) => e.capitalize()) - .join(" "); + const iconPreview = getIconPreview(iconName, type); if (type == undefined) { iconName = iconName.toSnakeCase(); @@ -119,10 +115,19 @@ function getDartIconDefinition(iconName: string, unicode: string, type: FontType iconName = getIconFileName(iconName, type); } - return ` ///
${readableName} icon ${ - type != undefined ? `(${type})` : "" - }
+ return `${iconPreview} static const IconData ${iconName} = IconData(0x${unicode}, fontFamily: family${ type?.capitalize() ?? "" }, fontPackage: package);`; } + +function getIconPreview(iconName: string, type: FontType | undefined) { + const name_link = `${iconName}_${type === undefined ? "round" : type}`; + const readableName = iconName + .split("_") + .map((e) => e.capitalize()) + .join(" "); + return ` ///
${readableName} icon ${ + type != undefined ? `(${type})` : "" + }
`; +}