From 7352e82b3e03ddd8bb9c2810a4caed3e3317c949 Mon Sep 17 00:00:00 2001
From: Taiizor <41683699+Taiizor@users.noreply.github.com>
Date: Tue, 21 Nov 2023 19:34:12 +0300
Subject: [PATCH] Infrastructure Preparation 40
---
.../Taiizor.Starterkit.Demo/DemoIcons.json | 7 +
.../Taiizor.Starterkit.Demo/DemoSettings.json | 219 +++++++++---------
.../Taiizor.Starterkit.Demo/Program.cs | 15 +-
.../Taiizor.Starterkit.Demo.csproj | 2 +-
.../Extension/BootstrapBase.cs | 3 +-
src/Taiizor.Starterkit/Extension/Theme.cs | 38 +++
src/Taiizor.Starterkit/Extension/ThemeBase.cs | 2 +
.../Extension/ThemeIcons.cs | 23 ++
.../Extension/ThemeSettings.cs | 4 +-
src/Taiizor.Starterkit/Interface/ITheme.cs | 2 +
.../Resources/FactoryIcons.json | 7 +
.../Resources/FactorySettings.json | 1 +
.../Taiizor.Starterkit.csproj | 2 +-
.../install-from-nuget.csproj | 2 +-
14 files changed, 209 insertions(+), 118 deletions(-)
create mode 100644 demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoIcons.json
create mode 100644 src/Taiizor.Starterkit/Extension/ThemeIcons.cs
create mode 100644 src/Taiizor.Starterkit/Resources/FactoryIcons.json
diff --git a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoIcons.json b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoIcons.json
new file mode 100644
index 0000000..82e1860
--- /dev/null
+++ b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoIcons.json
@@ -0,0 +1,7 @@
+{
+ "Demo": {
+ "icon-1": 1,
+ "icon-2": 3,
+ "icon-3": 2
+ }
+}
\ No newline at end of file
diff --git a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoSettings.json b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoSettings.json
index d60f728..a97ff39 100644
--- a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoSettings.json
+++ b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoSettings.json
@@ -1,113 +1,114 @@
{
- "Demo": {
- "Domain": "https://www.vegalya.com/",
- "PartialsDir": "~/Shared/Partials",
- "LayoutDir": "~/Shared/Layout",
- "ExceptionHandler": "/Error",
- "MapFallbackPage": "/_Host",
- "LocaleSwitchEnabled": true,
- "ModeSwitchEnabled": true,
- "LocaleDefault": "en-GB",
- "SvgDir": "media/icons/",
- "ModeDefault": "system",
- "AssetsDir": "assets/",
- "PagesDir": "~/Pages",
- "Direction": "rtl",
- "Preloader": true,
- "Major": 1,
- "Minor": 0,
- "Build": 1,
- "SocialMedia": {
- "YouTube": {
- "Url": "https://www.youtube.com/@iTaiizor",
- "Alt": "YouTube Address",
- "Icon": "youtube",
- "Line": ""
- },
- "GitHub": {
- "Url": "https://github.com/Taiizor",
- "Alt": "GitHub Address",
- "Icon": "github",
- "Line": ""
- }
- },
- "Compression": {
- "StaticFile": {
- "CacheControl": "public, max-age={0}",
- "MaxAge": "1.00:00:00",
- "Mode": "Compress",
- "Change": true,
- "Extensions": [
- ".jpeg",
- ".css",
- ".svg",
- ".png",
- ".jpg",
- ".js"
- ],
- "Headers": {
- "Vary": "Accept-Encoding"
+ "Demo": {
+ "Domain": "https://www.vegalya.com/",
+ "PartialsDir": "~/Shared/Partials",
+ "LayoutDir": "~/Shared/Layout",
+ "ExceptionHandler": "/Error",
+ "MapFallbackPage": "/_Host",
+ "LocaleSwitchEnabled": true,
+ "ModeSwitchEnabled": true,
+ "LocaleDefault": "en-GB",
+ "SvgDir": "media/icons/",
+ "ModeDefault": "system",
+ "AssetsDir": "assets/",
+ "PagesDir": "~/Pages",
+ "IconType": "solid",
+ "Direction": "rtl",
+ "Preloader": true,
+ "Major": 1,
+ "Minor": 0,
+ "Build": 1,
+ "SocialMedia": {
+ "YouTube": {
+ "Url": "https://www.youtube.com/@iTaiizor",
+ "Alt": "YouTube Address",
+ "Icon": "youtube",
+ "Line": ""
+ },
+ "GitHub": {
+ "Url": "https://github.com/Taiizor",
+ "Alt": "GitHub Address",
+ "Icon": "github",
+ "Line": ""
+ }
+ },
+ "Compression": {
+ "StaticFile": {
+ "CacheControl": "public, max-age={0}",
+ "MaxAge": "1.00:00:00",
+ "Mode": "Compress",
+ "Change": true,
+ "Extensions": [
+ ".jpeg",
+ ".css",
+ ".svg",
+ ".png",
+ ".jpg",
+ ".js"
+ ],
+ "Headers": {
+ "Vary": "Accept-Encoding"
+ }
+ },
+ "Response": {
+ "EnableHttps": true,
+ "MimeTypes": [
+ "*/*"
+ ]
+ },
+ "Level": {
+ "Deflate": "Optimal",
+ "Brotli": "Optimal",
+ "Gzip": "Optimal"
+ }
+ },
+ "ThirdParty": {
+ "GoogleAnalytics": "NULL",
+ "GoogleAdsense": "NULL",
+ "YandexMetrika": "NULL"
+ },
+ "Languages": {
+ "DefaultFlag": "european-union",
+ "CookieName": "Factorial",
+ "UnknownName": "Unknown",
+ "UnknownLang": "xy-XY",
+ "CookieExpires": 30,
+ "ActiveLang": [
+ "en-GB"
+ ],
+ "List": {
+ "English": {
+ "en-GB": "united-kingdom"
+ }
+ }
+ },
+ "Assets": {
+ "Favicon": "favicon.png",
+ "Manifest": "manifest.json",
+ "Version": true,
+ "Font": [
+ "https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,800,900"
+ ],
+ "Css": [
+ "css/bootstrap/bootstrap.min.css",
+ "css/site.css"
+ ],
+ "Js": [
+ "js/jquery.min.js"
+ ]
+ },
+ "Vendors": {
+ "special-library": {
+ "Font": [
+ "plugins/custom/special-library/special-library.ttf"
+ ],
+ "Css": [
+ "plugins/custom/special-library/special-library.css"
+ ],
+ "Js": [
+ "plugins/custom/special-library/special-library.js"
+ ]
+ }
}
- },
- "Response": {
- "EnableHttps": true,
- "MimeTypes": [
- "*/*"
- ]
- },
- "Level": {
- "Deflate": "Optimal",
- "Brotli": "Optimal",
- "Gzip": "Optimal"
- }
- },
- "ThirdParty": {
- "GoogleAnalytics": "NULL",
- "GoogleAdsense": "NULL",
- "YandexMetrika": "NULL"
- },
- "Languages": {
- "DefaultFlag": "european-union",
- "CookieName": "Factorial",
- "UnknownName": "Unknown",
- "UnknownLang": "xy-XY",
- "CookieExpires": 30,
- "ActiveLang": [
- "en-GB"
- ],
- "List": {
- "English": {
- "en-GB": "united-kingdom"
- }
- }
- },
- "Assets": {
- "Favicon": "favicon.png",
- "Manifest": "manifest.json",
- "Version": true,
- "Font": [
- "https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,800,900"
- ],
- "Css": [
- "css/bootstrap/bootstrap.min.css",
- "css/site.css"
- ],
- "Js": [
- "js/jquery.min.js"
- ]
- },
- "Vendors": {
- "special-library": {
- "Font": [
- "plugins/custom/special-library/special-library.ttf"
- ],
- "Css": [
- "plugins/custom/special-library/special-library.css"
- ],
- "Js": [
- "plugins/custom/special-library/special-library.js"
- ]
- }
}
- }
}
\ No newline at end of file
diff --git a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Program.cs b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Program.cs
index ca9fb08..e7cddfe 100644
--- a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Program.cs
+++ b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Program.cs
@@ -9,13 +9,22 @@ public static void Main(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
- // Set settings to the configuration
- //IConfiguration configuration = new ConfigurationBuilder()
+ // Set theme to the configuration
+ //IConfiguration themeConfiguration = new ConfigurationBuilder()
// .AddJsonFile("DemoSettings.json")
// .Build();
- //ThemeSettings.Init(configuration, "Demo");
+ //ThemeSettings.Init(themeConfiguration, "Demo");
+
+ // Set icons to the configuration
+ //IConfiguration iconConfiguration = new ConfigurationBuilder()
+ // .AddJsonFile("DemoIcons.json")
+ // .Build();
+
+ //ThemeIcons.Init(iconConfiguration, "Demo");
+
ThemeSettings.Init("DemoSettings.json", "Demo");
+ ThemeIcons.Init("DemoIcons.json", "Demo");
// Add services to the container.
builder.Services.AddRazorPages();
diff --git a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
index 9ec2145..bb8376a 100644
--- a/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
+++ b/demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo.csproj
@@ -14,7 +14,7 @@
-
+
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Extension/BootstrapBase.cs b/src/Taiizor.Starterkit/Extension/BootstrapBase.cs
index 55c327d..a2d942b 100644
--- a/src/Taiizor.Starterkit/Extension/BootstrapBase.cs
+++ b/src/Taiizor.Starterkit/Extension/BootstrapBase.cs
@@ -1,3 +1,4 @@
+using Taiizor.Starterkit.Enum;
using Taiizor.Starterkit.Helper;
using Taiizor.Starterkit.Interface;
@@ -63,7 +64,7 @@ public void Init(ITheme theme)
// Init theme direction option (RTL or LTR) from settings
public void InitThemeDirection()
{
- _theme.SetDirection(Converter.Convert(ThemeSettings.Config.Direction, Enum.DirectionEnum.LTR));
+ _theme.SetDirection(Converter.Convert(ThemeSettings.Config.Direction, DirectionEnum.LTR));
}
}
}
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Extension/Theme.cs b/src/Taiizor.Starterkit/Extension/Theme.cs
index babfe24..92af3e2 100644
--- a/src/Taiizor.Starterkit/Extension/Theme.cs
+++ b/src/Taiizor.Starterkit/Extension/Theme.cs
@@ -110,6 +110,44 @@ public string GetSvgIcon(string path, string classNames)
return $"{svg}";
}
+ // Get icon content
+ public string GetIcon(string iconName, string iconClass = "", string iconType = "")
+ {
+ string tag = "i";
+ string output = "";
+ string iconsFinalClass = iconClass == "" ? "" : " " + iconClass;
+
+ if (string.IsNullOrEmpty(iconType) && !string.IsNullOrEmpty(ThemeSettings.Config.IconsType))
+ {
+ iconType = ThemeSettings.Config.IconsType;
+ }
+
+ if (string.IsNullOrEmpty(iconType))
+ {
+ iconType = "duotone";
+ }
+
+ if (iconType == "duotone")
+ {
+ int paths = ThemeIcons.Config.TryGetValue(iconName, out int number) ? number : 0;
+
+ output += $"<{tag} class='ki-{iconType} ki-{iconName}{iconsFinalClass}'>";
+
+ for (int i = 0; i < paths; i++)
+ {
+ output += $"";
+ }
+
+ output += $"{tag}>";
+ }
+ else
+ {
+ output = $"<{tag} class='ki-{iconType} ki-{iconName}{iconsFinalClass}'>{tag}>";
+ }
+
+ return output;
+ }
+
// Set preloader option from settings
public void SetPreloader(bool flag)
{
diff --git a/src/Taiizor.Starterkit/Extension/ThemeBase.cs b/src/Taiizor.Starterkit/Extension/ThemeBase.cs
index b8a3b61..7eedfd6 100644
--- a/src/Taiizor.Starterkit/Extension/ThemeBase.cs
+++ b/src/Taiizor.Starterkit/Extension/ThemeBase.cs
@@ -25,6 +25,8 @@ public class ThemeBase
public string LayoutDir { get; set; }
+ public string IconsType { get; set; }
+
public string PartialsDir { get; set; }
public string ModeDefault { get; set; }
diff --git a/src/Taiizor.Starterkit/Extension/ThemeIcons.cs b/src/Taiizor.Starterkit/Extension/ThemeIcons.cs
new file mode 100644
index 0000000..f4d59ec
--- /dev/null
+++ b/src/Taiizor.Starterkit/Extension/ThemeIcons.cs
@@ -0,0 +1,23 @@
+using Microsoft.Extensions.Configuration;
+
+namespace Taiizor.Starterkit.Extension
+{
+ public class ThemeIcons
+ {
+ public static SortedDictionary Config { get; set; } = [];
+
+ public static void Init(string Path, string Key)
+ {
+ IConfiguration Configuration = new ConfigurationBuilder()
+ .AddJsonFile(Path)
+ .Build();
+
+ Init(Configuration, Key);
+ }
+
+ public static void Init(IConfiguration Configuration, string Key)
+ {
+ Config = Configuration.GetSection(Key).Get>() ?? Config;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Extension/ThemeSettings.cs b/src/Taiizor.Starterkit/Extension/ThemeSettings.cs
index f9c6b77..3700477 100644
--- a/src/Taiizor.Starterkit/Extension/ThemeSettings.cs
+++ b/src/Taiizor.Starterkit/Extension/ThemeSettings.cs
@@ -4,7 +4,7 @@ namespace Taiizor.Starterkit.Extension
{
public class ThemeSettings
{
- public static ThemeBase Config;
+ public static ThemeBase Config = new();
public static void Init(string Path, string Key)
{
@@ -17,7 +17,7 @@ public static void Init(string Path, string Key)
public static void Init(IConfiguration Configuration, string Key)
{
- Config = Configuration.GetSection(Key).Get();
+ Config = Configuration.GetSection(Key).Get() ?? Config;
}
}
}
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Interface/ITheme.cs b/src/Taiizor.Starterkit/Interface/ITheme.cs
index fa48b38..7257171 100644
--- a/src/Taiizor.Starterkit/Interface/ITheme.cs
+++ b/src/Taiizor.Starterkit/Interface/ITheme.cs
@@ -18,6 +18,8 @@ public interface ITheme
string GetSvgIcon(string path, string classNames);
+ string GetIcon(string iconName, string iconClass = "", string iconType = "");
+
void SetDomain(string flag);
string GetDomain();
diff --git a/src/Taiizor.Starterkit/Resources/FactoryIcons.json b/src/Taiizor.Starterkit/Resources/FactoryIcons.json
new file mode 100644
index 0000000..02f632b
--- /dev/null
+++ b/src/Taiizor.Starterkit/Resources/FactoryIcons.json
@@ -0,0 +1,7 @@
+{
+ "icon-paths": {
+ "icon-1": 1,
+ "icon-2": 3,
+ "icon-3": 2
+ }
+}
\ No newline at end of file
diff --git a/src/Taiizor.Starterkit/Resources/FactorySettings.json b/src/Taiizor.Starterkit/Resources/FactorySettings.json
index 8e8981a..8979c6d 100644
--- a/src/Taiizor.Starterkit/Resources/FactorySettings.json
+++ b/src/Taiizor.Starterkit/Resources/FactorySettings.json
@@ -12,6 +12,7 @@
"ModeDefault": "system",
"AssetsDir": "assets/",
"PagesDir": "~/Pages",
+ "IconType": "solid",
"Direction": "ltr",
"Preloader": true,
"Major": 0,
diff --git a/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj b/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
index 426fe3e..bc45799 100644
--- a/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
+++ b/src/Taiizor.Starterkit/Taiizor.Starterkit.csproj
@@ -13,7 +13,7 @@
Resources\Taiizor.Starterkit.ico
- 1.1.3.1
+ 1.1.3.2
$(Version)
true
Taiizor.Starterkit
diff --git a/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj b/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
index 279e989..13e771c 100644
--- a/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
+++ b/tutorial/C#/#002 install-from-nuget/install-from-nuget/install-from-nuget.csproj
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file