this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

initial commit

Dylan Hackworth e13e3657

+336
+7
.gitignore
··· 1 + bin/ 2 + obj/ 3 + nupkgs/ 4 + /packages/ 5 + riderModule.iml 6 + /_ReSharper.Caches/ 7 + /.idea
+17
Iconify.sln
··· 1 +  2 + Microsoft Visual Studio Solution File, Format Version 12.00 3 + # 4 + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iconify", "Iconify\Iconify.csproj", "{6C4588EC-0352-4244-A9F7-35A91EBBCA5A}" 5 + EndProject 6 + Global 7 + GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 + Debug|Any CPU = Debug|Any CPU 9 + Release|Any CPU = Release|Any CPU 10 + EndGlobalSection 11 + GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 + {6C4588EC-0352-4244-A9F7-35A91EBBCA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 + {6C4588EC-0352-4244-A9F7-35A91EBBCA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 + {6C4588EC-0352-4244-A9F7-35A91EBBCA5A}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 + {6C4588EC-0352-4244-A9F7-35A91EBBCA5A}.Release|Any CPU.Build.0 = Release|Any CPU 16 + EndGlobalSection 17 + EndGlobal
+2
Iconify.sln.DotSettings.user
··· 1 + <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> 2 + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATagHelperAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F83848228fb434a82b1ff994f8d86e2b38838_003F00_003F9a633517_003FTagHelperAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
+50
Iconify/Extensions/IconifyBlazorServiceCollectionExtensions.cs
··· 1 + using Iconify.IconSets; 2 + using Microsoft.Extensions.DependencyInjection; 3 + using Microsoft.Extensions.Hosting; 4 + 5 + namespace Iconify.Extensions; 6 + 7 + public static class IconifyServiceCollectionExtensions 8 + { 9 + /// <summary> 10 + /// Registers the <see cref="Registry" /> singleton and (optionally) 11 + /// pre-loads icon-set JSON files or <see cref="IconSet" /> instances. 12 + /// </summary> 13 + /// <param name="services">The DI container.</param> 14 + /// <param name="configure"> 15 + /// Optional callback that lets callers add icon sets: 16 + /// <code> 17 + /// services.AddIconify(b => 18 + /// { 19 + /// b.AddJson("wwwroot/icons/mdi.json") 20 + /// .AddJson("wwwroot/icons/lucide.json"); 21 + /// }); 22 + /// </code> 23 + /// </param> 24 + public static IServiceCollection AddIconify( 25 + this IServiceCollection services, 26 + Action<IconifyBuilder>? configure = null) 27 + { 28 + // Collect caller-supplied sets/paths 29 + IconifyBuilder builder = new(); 30 + configure?.Invoke(builder); 31 + 32 + // Register Registry as a singleton 33 + services.AddSingleton<Registry>(sp => 34 + { 35 + IHostEnvironment env = sp.GetRequiredService<IHostEnvironment>(); 36 + Registry registry = new(); 37 + 38 + foreach (string full in builder.JsonPaths.Select(path => Path.IsPathRooted(path) 39 + ? path 40 + : Path.Combine(env.ContentRootPath, path))) 41 + registry.Register(full); 42 + 43 + foreach (IconSet set in builder.IconSets) registry.Register(set); 44 + 45 + return registry; 46 + }); 47 + 48 + return services; 49 + } 50 + }
+36
Iconify/Extensions/IconifyBuilder.cs
··· 1 + using Iconify.IconSets; 2 + 3 + namespace Iconify.Extensions; 4 + 5 + /// <summary> 6 + /// Fluent helper that callers use inside AddIconify() 7 + /// to register icon-set JSON files or in-memory IconSet objects. 8 + /// </summary> 9 + public sealed class IconifyBuilder 10 + { 11 + internal List<string> JsonPaths { get; } = new(); 12 + internal List<IconSet> IconSets { get; } = new(); 13 + 14 + /// <summary>Add a single JSON file (absolute or relative to the content root).</summary> 15 + public IconifyBuilder AddJson(string path) 16 + { 17 + JsonPaths.Add(path); 18 + return this; 19 + } 20 + 21 + /// <summary>Add every *.json in a folder.</summary> 22 + public IconifyBuilder AddJsonFolder(string folder) 23 + { 24 + foreach (string file in Directory.GetFiles(folder, "*.json")) 25 + JsonPaths.Add(file); 26 + 27 + return this; 28 + } 29 + 30 + /// <summary>Add a pre-constructed <see cref="IconSet" /> object.</summary> 31 + public IconifyBuilder AddSet(IconSet set) 32 + { 33 + IconSets.Add(set); 34 + return this; 35 + } 36 + }
+40
Iconify/Icon.razor
··· 1 + @using Iconify.IconSets 2 + @inject Registry IconRegistry 3 + 4 + <svg xmlns="http://www.w3.org/2000/svg" 5 + viewBox="0 0 @_width @_height" 6 + width="@_width" 7 + height="@_height" 8 + @attributes="AdditionalAttributes"> 9 + @(Body) 10 + </svg> 11 + 12 + @code { 13 + 14 + /// <summary>The icon name or "set:icon-name" string. Required.</summary> 15 + [Parameter][EditorRequired] 16 + public required string Name { get; set; } 17 + 18 + /// <summary>Pass-through attributes (class, style, aria-*, …).</summary> 19 + [Parameter(CaptureUnmatchedValues = true)] 20 + public Dictionary<string, object>? AdditionalAttributes { get; set; } 21 + 22 + private int _width = 24; 23 + private int _height = 24; 24 + private MarkupString Body { get; set; } 25 + 26 + protected override void OnParametersSet() 27 + { 28 + if (string.IsNullOrWhiteSpace(Name)) 29 + throw new ArgumentException("The 'Icon' parameter is required.", nameof(Icon)); 30 + 31 + IconId id = IconId.From(Name); 32 + IconData iconData = IconRegistry.Resolve(id) 33 + ?? throw new ArgumentException($"Icon '{id}' not found.", nameof(Icon)); 34 + 35 + _width = iconData.Width ?? 24; 36 + _height = iconData.Height ?? 24; 37 + Body = (MarkupString)iconData.Body; 38 + } 39 + 40 + }
+9
Iconify/IconSets/Author.cs
··· 1 + using System.Text.Json.Serialization; 2 + 3 + namespace Iconify.IconSets; 4 + 5 + public sealed record Author 6 + { 7 + [JsonPropertyName("name")] public required string Name { get; init; } 8 + [JsonPropertyName("url")] public required string Url { get; init; } 9 + }
+10
Iconify/IconSets/IconData.cs
··· 1 + using System.Text.Json.Serialization; 2 + 3 + namespace Iconify.IconSets; 4 + 5 + public sealed record IconData 6 + { 7 + [JsonPropertyName("body")] public required string Body { get; init; } 8 + [JsonPropertyName("width")] public int? Width { get; init; } = null; 9 + [JsonPropertyName("height")] public int? Height { get; init; } = null; 10 + }
+24
Iconify/IconSets/IconId.cs
··· 1 + namespace Iconify.IconSets; 2 + 3 + public sealed record IconId 4 + { 5 + public required string Set { get; init; } 6 + public required string Name { get; init; } 7 + 8 + public override string ToString() 9 + { 10 + return $"{Set}:{Name}"; 11 + } 12 + 13 + public static IconId From(string value) 14 + { 15 + string[] split = value.Split(":", 2); 16 + if (split.Length < 2) throw new ArgumentException("Invalid icon ID format", nameof(value)); 17 + 18 + return new IconId 19 + { 20 + Set = split[0], 21 + Name = split[1] 22 + }; 23 + } 24 + }
+18
Iconify/IconSets/IconSet.cs
··· 1 + using System.Text.Json; 2 + using System.Text.Json.Serialization; 3 + 4 + namespace Iconify.IconSets; 5 + 6 + public sealed record IconSet 7 + { 8 + [JsonPropertyName("prefix")] public required string Prefix { get; init; } 9 + [JsonPropertyName("info")] public required Info Info { get; init; } 10 + [JsonPropertyName("lastModified")] public required long LastModified { get; init; } 11 + [JsonPropertyName("icons")] public required Dictionary<string, IconData> Icons { get; init; } 12 + 13 + public static IconSet? Load(string path) 14 + { 15 + using FileStream stream = File.OpenRead(path); 16 + return JsonSerializer.Deserialize<IconSet>(stream); 17 + } 18 + }
+16
Iconify/IconSets/Info.cs
··· 1 + using System.Text.Json.Serialization; 2 + 3 + namespace Iconify.IconSets; 4 + 5 + public sealed record Info 6 + { 7 + [JsonPropertyName("name")] public required string Name { get; init; } 8 + [JsonPropertyName("total")] public required int Total { get; init; } 9 + [JsonPropertyName("version")] public required string Version { get; init; } 10 + [JsonPropertyName("author")] public required Author Author { get; init; } 11 + [JsonPropertyName("license")] public required License License { get; init; } 12 + [JsonPropertyName("samples")] public List<string>? Samples { get; init; } 13 + [JsonPropertyName("category")] public string? Category { get; init; } 14 + [JsonPropertyName("tags")] public List<string>? Tags { get; init; } 15 + [JsonPropertyName("palette")] public bool Palette { get; init; } 16 + }
+10
Iconify/IconSets/License.cs
··· 1 + using System.Text.Json.Serialization; 2 + 3 + namespace Iconify.IconSets; 4 + 5 + public sealed record License 6 + { 7 + [JsonPropertyName("title")] public required string Title { get; init; } 8 + [JsonPropertyName("spdx")] public required string Spdx { get; init; } 9 + [JsonPropertyName("url")] public required string Url { get; init; } 10 + }
+30
Iconify/Iconify.csproj
··· 1 + <Project Sdk="Microsoft.NET.Sdk.Razor"> 2 + 3 + <PropertyGroup> 4 + <TargetFramework>net9.0</TargetFramework> 5 + <Nullable>enable</Nullable> 6 + <ImplicitUsings>enable</ImplicitUsings> 7 + <PackageId>Iconify</PackageId> 8 + <Version>1.0.0</Version> 9 + <Authors>dylhack</Authors> 10 + <PackageLicenseExpression>MIT</PackageLicenseExpression> 11 + <GeneratePackageOnBuild>true</GeneratePackageOnBuild> 12 + <Title>Iconify Blazor</Title> 13 + <Description>Iconify for Blazor</Description> 14 + <PackageProjectUrl>https://github.com/dylhack/iconify</PackageProjectUrl> 15 + <RepositoryUrl>https://github.com/dylhack/iconify</RepositoryUrl> 16 + <RepositoryType>git</RepositoryType> 17 + <PackageOutputPath>./nupkgs</PackageOutputPath> 18 + </PropertyGroup> 19 + 20 + 21 + <ItemGroup> 22 + <SupportedPlatform Include="browser"/> 23 + </ItemGroup> 24 + 25 + <ItemGroup> 26 + <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.5"/> 27 + <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.6"/> 28 + </ItemGroup> 29 + 30 + </Project>
+43
Iconify/Registry.cs
··· 1 + using Iconify.IconSets; 2 + 3 + namespace Iconify; 4 + 5 + public class Registry 6 + { 7 + private IDictionary<string, IconSet> Sets { get; } = new Dictionary<string, IconSet>(); 8 + 9 + /// <summary> 10 + /// Register an icon set. 11 + /// </summary> 12 + /// <param name="iconSet"></param> 13 + public void Register(IconSet iconSet) 14 + { 15 + Sets.Add(iconSet.Prefix, iconSet); 16 + } 17 + 18 + /// <summary> 19 + /// Register an icon set from a JSON file. 20 + /// </summary> 21 + /// <param name="path"></param> 22 + /// <exception cref="ArgumentException"></exception> 23 + public void Register(string path) 24 + { 25 + IconSet iconSet = IconSet.Load(path) 26 + ?? throw new ArgumentException("Invalid icon set path"); 27 + 28 + Register(iconSet); 29 + } 30 + 31 + public IconSet? Resolve(string set) 32 + { 33 + return Sets.TryGetValue(set, out IconSet? iconSet) ? iconSet : null; 34 + } 35 + 36 + public IconData? Resolve(IconId iconId) 37 + { 38 + IconSet? iconSet = Resolve(iconId.Set); 39 + if (iconSet != null && iconSet.Icons.TryGetValue(iconId.Name, out IconData? iconData)) return iconData; 40 + 41 + return null; 42 + } 43 + }
+1
Iconify/_Imports.razor
··· 1 + @using Microsoft.AspNetCore.Components.Web
+2
IconifyBlazor.sln.DotSettings.user
··· 1 + <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> 2 + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATagHelperAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F83848228fb434a82b1ff994f8d86e2b38838_003F00_003F9a633517_003FTagHelperAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
+21
LICENSE
··· 1 + MIT License 2 + 3 + Copyright (c) 2025 Dylan Hackworth 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy 6 + of this software and associated documentation files (the "Software"), to deal 7 + in the Software without restriction, including without limitation the rights 8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 + copies of the Software, and to permit persons to whom the Software is 10 + furnished to do so, subject to the following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 + SOFTWARE.