Skip to content

Commit

Permalink
feat: Add inline icon previews for dart
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jul 3, 2024
1 parent 67aff3a commit 7918f56
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/fetch_icons/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
684c4d8d5f5a51f3dabb8c0474ec81bf
12 changes: 11 additions & 1 deletion scripts/generators/generateFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { webfont } from "webfont";
import { createFolder, getIconFileName } from "../utils/fileUtils.js";
import { writeFileSync } from "fs";

const GITHUB_URL = "https://raw.githubusercontent.com/ZebraDevs/zeta-icons/main/ouputs/png/";
/**
* Generates font files from optimized SVGs.
*
Expand Down Expand Up @@ -106,13 +107,22 @@ 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(" ");

if (type == undefined) {
iconName = iconName.toSnakeCase();
} else {
iconName = getIconFileName(iconName, type);
}

return ` static const IconData ${iconName} = IconData(0x${unicode}, fontFamily: family${
return ` /// <i> <img width='48' src="${GITHUB_URL}${name_link}.png"></br>${readableName} icon ${
type != undefined ? `(${type})` : ""
}</i>
static const IconData ${iconName} = IconData(0x${unicode}, fontFamily: family${
type?.capitalize() ?? ""
}, fontPackage: package);`;
}
1 change: 1 addition & 0 deletions scripts/generators/generatePNGs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const generatePNGs = (inputDir: string, outputDir: string, categories: st
const name = split.pop()?.slice(0, -3);
sharp(inputDir + "/" + cat + "/" + svg)
.resize(512)
.modulate({ lightness: 44 })
.png()
.toFile(outputDir + "/" + name + "png");
}
Expand Down
2 changes: 1 addition & 1 deletion test/data/documentResponse.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/generatedFontResponse.json

Large diffs are not rendered by default.

0 comments on commit 7918f56

Please sign in to comment.