Skip to content

Commit

Permalink
Merge pull request #6 from MartinTopfstedt/develop
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
Codinion authored Apr 5, 2022
2 parents 3d29615 + 07f9c9b commit 7c2399c
Show file tree
Hide file tree
Showing 34 changed files with 37,468 additions and 9,540 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 1.2.0
- updated to Font-Awesome 6.1.1
# 1.1.0
- updated to Font-Awesome 6.1.0
# 1.0.0
- updated to Font-Awesome 6.0.0
2 changes: 1 addition & 1 deletion Font-Awesome
Submodule Font-Awesome updated 10490 files
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

WPF (.Net and .Net Core), UWP and WinUI controls for the web's most popular icon set and toolkit.

Font-Awesome Version: 6.0.0
Font-Awesome Version: 6.1.1

## Breaking Changes

Expand Down
Binary file modified bin/FontAwesome.Generator/FontAwesome.Generator.Shared.dll
Binary file not shown.
Binary file modified bin/FontAwesome.Generator/FontAwesome.Generator.Shared.pdb
Binary file not shown.
Binary file modified bin/FontAwesome.Generator/FontAwesome.Generator.dll
Binary file not shown.
Binary file modified bin/FontAwesome.Generator/FontAwesome.Generator.exe
Binary file not shown.
Binary file modified bin/FontAwesome.Generator/FontAwesome.Generator.pdb
Binary file not shown.
5 changes: 3 additions & 2 deletions bin/FontAwesome.Generator/Templates/EFontAwesomeIcon.scriban
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FontAwesome6
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public enum EFontAwesomeIcon
{
Expand All @@ -22,7 +23,7 @@ namespace FontAwesome6
{{~ for kvp in freeIcons ~}}
{{~ for style in kvp.Value.free ~}}
/// <summary>{{ kvp.Value.label | string.replace "&" "&amp;"}}</summary>
/// <remarks><see href="https://fontawesome.com/v6.0/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
/// <remarks><see href="https://fontawesome.com/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
{{ style | string.capitalize }}_{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }},
{{~ end ~}}
{{~ end ~}}
Expand All @@ -32,7 +33,7 @@ namespace FontAwesome6
{{~ for style in kvp.Value.styles ~}}
{{~ if !(kvp.Value.free | array.contains style) ~}}
/// <summary>{{ kvp.Value.label | string.replace "&" "&amp;"}}</summary>
/// <remarks><see href="https://fontawesome.com/v6.0/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
/// <remarks><see href="https://fontawesome.com/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
{{ style | string.capitalize }}_{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }},
{{~ end ~}}
{{~ end ~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FontAwesome6
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public enum EFontAwesomeStyle
{
Expand Down
12 changes: 9 additions & 3 deletions bin/FontAwesome.Generator/Templates/FontAwesomeUnicodes.scriban
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ using System.Collections.Generic;

namespace FontAwesome6
{
/// <summary>
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public static class FontAwesomeUnicodes
{
public static Dictionary<string, Tuple<string, double>> Data = new Dictionary<string, Tuple<string, double>>() {
public static Dictionary<string, Tuple<string, string>> Data = new Dictionary<string, Tuple<string, string>>() {
{{~ for kvp in freeIcons ~}}
{{~ if (kvp.Value.free | array.size) > 0 ~}}
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", {{kvp.Value.duotoneOpacity}}) },
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", "{{kvp.Value.id}}") },
{{~ end ~}}
{{~ end ~}}
#if FontAwesomePro
{{~ for kvp in proIcons ~}}
{{~ if (kvp.Value.free | array.size) == 0 ~}}
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", {{kvp.Value.duotoneOpacity}}) },
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", "{{kvp.Value.id}}") },
{{~ end ~}}
{{~ end ~}}
#endif
Expand Down
2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.all.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/Font-Awesome/FontAwesomeSvg.solid.json

Large diffs are not rendered by default.

40 changes: 35 additions & 5 deletions src/FontAwesom.Generator.Shared/FontAwesomeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public async Task<bool> DoesVersionExistAsync(string version)
// return response.Data.Release;
//}

public async Task<Icon[]> GetIconsAsync(string version, bool isFree)
public async Task<Icon[]> GetFreeIconsAsync(string version)
{
var graphQLClient = new GraphQLHttpClient("https://api.fontawesome.com", new NewtonsoftJsonSerializer());
var request = new GraphQLRequest
{
Query = @"query ReleaseQuery($version: String!, $license: String!) {
Query = @"query ReleaseQuery($version: String!) {
release (version: $version)
{
version,
icons(license: $license) {
icons(license: ""free"") {
id,
label,
styles,
Expand All @@ -71,8 +71,38 @@ public async Task<Icon[]> GetIconsAsync(string version, bool isFree)
}",
Variables = new
{
version,
license = isFree ? "free" : "pro"
version
}
};

var response = await graphQLClient.SendQueryAsync<ResponseType>(request);
return response.Data.Release.Icons;
}

public async Task<Icon[]> GetAllIconsAsync(string version)
{
var graphQLClient = new GraphQLHttpClient("https://api.fontawesome.com", new NewtonsoftJsonSerializer());
var request = new GraphQLRequest
{
Query = @"query ReleaseQuery($version: String!) {
release (version: $version)
{
version,
icons {
id,
label,
styles,
unicode,
membership {
free,
pro
}
}
}
}",
Variables = new
{
version
}
};

Expand Down
33 changes: 24 additions & 9 deletions src/FontAwesom.Generator.Shared/FontAwesomeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FontAwesome.Generator.Shared.GraphQl;
using FontAwesome.Generator.Shared.Models;
using FontAwesome.Generator.Shared.Models.GraphQL;
using FontAwesome.Generator.Shared.Models.Svgs;

using Newtonsoft.Json;
Expand All @@ -17,14 +18,19 @@ public class FontAwesomeGenerator
{
private static Regex _reOpacity = new Regex(@"\.fa-secondary\{opacity:(.*?)\}");

public async Task GenerateAllAsync(string version, bool isFree, string sourceDirectory, string svgDirectory, string outputDirectory, string outputFileNamePrefix)
public async Task GenerateSourceFiles(string version, string sourceDirectory)
{
var icons = await GetIconsAsync(version, isFree, svgDirectory);
GenerateFiles(sourceDirectory, icons);
var icons = await GetIconsAsync(version, false);
GenerateFiles(sourceDirectory, icons, version);
}

public async Task GenerateSvgFiles(string version, bool isFree, string svgDirectory, string outputDirectory, string outputFileNamePrefix)
{
var icons = await GetIconsAsync(version, isFree, svgDirectory);
GenerateSvg(outputDirectory, isFree, icons, outputFileNamePrefix);
}

public async Task<Dictionary<string, FontAwesomeIcon>> GetIconsAsync(string version, bool isFree, string svgDirectory)
private async Task<Dictionary<string, FontAwesomeIcon>> GetIconsAsync(string version, bool isFree, string svgDirectory = null)
{
var api = new FontAwesomeApi();

Expand All @@ -33,13 +39,22 @@ public async Task<Dictionary<string, FontAwesomeIcon>> GetIconsAsync(string vers
throw new Exception($"Version {version} does not exist.");
}

var icons = await api.GetIconsAsync(version, isFree);
IEnumerable<Icon> icons;
if (isFree)
{
icons = await api.GetFreeIconsAsync(version);
}
else
{
icons = await api.GetAllIconsAsync(version);
}

var result = new Dictionary<string, FontAwesomeIcon>();
foreach (var icon in icons)
{
var faIcon = new FontAwesomeIcon
{
id = icon.Id,
unicode = icon.Unicode,
label = icon.Label,
styles = icon.Styles,
Expand Down Expand Up @@ -81,7 +96,7 @@ public async Task<Dictionary<string, FontAwesomeIcon>> GetIconsAsync(string vers
}


private static void GenerateFiles(string srcDirectory, Dictionary<string, FontAwesomeIcon> icons)
private static void GenerateFiles(string srcDirectory, Dictionary<string, FontAwesomeIcon> icons, string version)
{
if (!Directory.Exists(srcDirectory))
{
Expand Down Expand Up @@ -123,14 +138,14 @@ private static void GenerateFiles(string srcDirectory, Dictionary<string, FontAw
var freeStyles = icons.Values.SelectMany(i => i.free).Distinct();
var allStyles = icons.Values.SelectMany(i => i.styles).Distinct();

GenerateFile("EFontAwesomeStyle.scriban", Path.Combine(dirFontAwesome6, "EFontAwesomeStyle.cs"), new { FreeStyles = freeStyles, ProStyles = allStyles.Except(freeStyles) });
GenerateFile("EFontAwesomeStyle.scriban", Path.Combine(dirFontAwesome6, "EFontAwesomeStyle.cs"), new { FreeStyles = freeStyles, ProStyles = allStyles.Except(freeStyles), version });

var freeIcons = icons.Where(i => i.Value.free.Count > 0);
var proIcons = icons.Where(i => i.Value.free.Count < i.Value.styles.Count);

GenerateFile("EFontAwesomeIcon.scriban", Path.Combine(dirFontAwesome6, $"EFontAwesomeIcon.cs"), new { freeIcons, proIcons });
GenerateFile("EFontAwesomeIcon.scriban", Path.Combine(dirFontAwesome6, $"EFontAwesomeIcon.cs"), new { freeIcons, proIcons, version });

GenerateFile("FontAwesomeUnicodes.scriban", Path.Combine(dirFontAwesome6Fonts, $"FontAwesomeUnicodes.cs"), new { freeIcons, proIcons });
GenerateFile("FontAwesomeUnicodes.scriban", Path.Combine(dirFontAwesome6Fonts, $"FontAwesomeUnicodes.cs"), new { freeIcons, proIcons, version });
}

private static void GenerateSvg(string outputDirectory, bool isFree, Dictionary<string, FontAwesomeIcon> icons, string outputFileNamePrefix)
Expand Down
13 changes: 1 addition & 12 deletions src/FontAwesom.Generator.Shared/Models/FontAwesomeIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class FontAwesomeIcon
{
public string id { get; set; }
public string label { get; set; }
public string unicode { get; set; }
public string unicodeString => FixUnicode(unicode);
Expand All @@ -10,18 +11,6 @@ public class FontAwesomeIcon
public Dictionary<string, FontAwesomeSvgIcon> svg { get; set; }
public List<string> free { get; set; }

public string duotoneOpacity
{
get
{
if (svg.TryGetValue("duotone", out var info))
{
return info.opacity;
}
return "1.0";
}
}

private string FixUnicode(string str)
{
if (string.IsNullOrEmpty(str))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FontAwesome6
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public enum EFontAwesomeIcon
{
Expand All @@ -22,7 +23,7 @@ namespace FontAwesome6
{{~ for kvp in freeIcons ~}}
{{~ for style in kvp.Value.free ~}}
/// <summary>{{ kvp.Value.label | string.replace "&" "&amp;"}}</summary>
/// <remarks><see href="https://fontawesome.com/v6.0/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
/// <remarks><see href="https://fontawesome.com/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
{{ style | string.capitalize }}_{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }},
{{~ end ~}}
{{~ end ~}}
Expand All @@ -32,7 +33,7 @@ namespace FontAwesome6
{{~ for style in kvp.Value.styles ~}}
{{~ if !(kvp.Value.free | array.contains style) ~}}
/// <summary>{{ kvp.Value.label | string.replace "&" "&amp;"}}</summary>
/// <remarks><see href="https://fontawesome.com/v6.0/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
/// <remarks><see href="https://fontawesome.com/icons/{{ kvp.Key }}?s={{ style }}" /></remarks>
{{ style | string.capitalize }}_{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }},
{{~ end ~}}
{{~ end ~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace FontAwesome6
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public enum EFontAwesomeStyle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ using System.Collections.Generic;

namespace FontAwesome6
{
/// <summary>
/// FontAwesome by Dave Gandy (@davegandy)
/// The iconic SVG, font, and CSS toolkit
/// License https://fontawesome.com/license (C#: MIT License)
/// Version: {{ version }}
/// </summary>
public static class FontAwesomeUnicodes
{
public static Dictionary<string, Tuple<string, double>> Data = new Dictionary<string, Tuple<string, double>>() {
public static Dictionary<string, Tuple<string, string>> Data = new Dictionary<string, Tuple<string, string>>() {
{{~ for kvp in freeIcons ~}}
{{~ if (kvp.Value.free | array.size) > 0 ~}}
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", {{kvp.Value.duotoneOpacity}}) },
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", "{{kvp.Value.id}}") },
{{~ end ~}}
{{~ end ~}}
#if FontAwesomePro
{{~ for kvp in proIcons ~}}
{{~ if (kvp.Value.free | array.size) == 0 ~}}
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", {{kvp.Value.duotoneOpacity}}) },
{ "{{ kvp.Key | regex.replace "[\\-&\\.']" " " | string.capitalizewords | string.replace " " "" }}", Tuple.Create("{{kvp.Value.unicodeString}}", "{{kvp.Value.id}}") },
{{~ end ~}}
{{~ end ~}}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/FontAwesome.Generator.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public static int Main(string[] args)

private async Task OnExecute()
{
var generator = new FontAwesomeGenerator();
await generator.GenerateAllAsync(Version, !IsProVersion, SourceDirectory, FontAwesomeSvgDirectory, SvgOutputDirectory, SvgOutputFileNamePrefix ?? "FontAwesomeSvg");
//var generator = new FontAwesomeGenerator();
//await generator.GenerateAllAsync(Version, !IsProVersion, SourceDirectory, FontAwesomeSvgDirectory, SvgOutputDirectory, SvgOutputFileNamePrefix ?? "FontAwesomeSvg");
}
}
}
Loading

0 comments on commit 7c2399c

Please sign in to comment.