Skip to content

Commit

Permalink
Small fixes for MaterialIconsFontGenerator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix-CodingClimber committed Jun 29, 2024
1 parent 4fb4237 commit 36c99da
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/DotNetElements.Extensions.Icons/MaterialIconsFontGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ private async Task WriteToFileAsync(IReadOnlyList<MaterialIcon> iconInfo)

iconBuilder.AppendLine($" {varName},");

iconDictionaryBuilder.AppendLine($" {{ {varName}, \"\\u{icon.Unicode}\" }},");
iconDictionaryBuilder.AppendLine($" {{ Icons.Material.{varName}, \"&#x{icon.Unicode};\" }},");
}

resultBuilder.Append(iconBuilder);
resultBuilder.Append(iconDictionaryHeader);
resultBuilder.Append(iconDictionaryBuilder);
resultBuilder.Append(fileFooter);

Expand All @@ -105,25 +104,27 @@ public enum Material
private const string iconDictionaryHeader =
"""
}
public static class MaterialIconsExtensions
}
public static partial class MaterialIconsExtensions
{
private readonly static Dictionary<Icons.Material, string> unicodeMap = new()
{
private readonly static Dictionary<Material, string> unicodeMap = new()
{
""";

private const string fileFooter =
"""
};
public static string ToUnicode(this Material materialIcon)
{
return unicodeMap[materialIcon];
}
};
public static string ToUnicode(this Icons.Material materialIcon)
{
return unicodeMap[materialIcon];
}
}
""";

private record MaterialIconFontInfo(string Name, string UnicodeUrl);

private record MaterialIcon(string Id, string Unicode);
}

0 comments on commit 36c99da

Please # to comment.