Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UX-1021): Add inline icon previews for dart #5

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ${
thelukewalton marked this conversation as resolved.
Show resolved Hide resolved
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.