Skip to content

Commit

Permalink
refactor: add getIconPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jul 4, 2024
1 parent 7918f56 commit 54ae3aa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions scripts/generators/generateFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,27 @@ 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();
} else {
iconName = getIconFileName(iconName, type);
}

return ` /// <i> <img width='48' src="${GITHUB_URL}${name_link}.png"></br>${readableName} icon ${
type != undefined ? `(${type})` : ""
}</i>
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 ` /// <i> <img width='48' src="${GITHUB_URL}${name_link}.png"></br>${readableName} icon ${
type != undefined ? `(${type})` : ""
}</i>`;
}

0 comments on commit 54ae3aa

Please sign in to comment.