correct css class output in icon renderer

This commit is contained in:
2025-12-15 13:45:22 +01:00
parent a57c109736
commit 74023d2de6
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -2,6 +2,11 @@
public class IconOptions : IconSetOptions
{
public IconOptions()
{
CssClass = "app-icon";
}
public List<IconSetOptions> Sets { get; set; } = [];
}
+2 -2
View File
@@ -55,7 +55,7 @@ public class IconTagHelper : TagHelper
decimal stroke = Stroke < 0 ? (set.DefaultStrokeWidth ?? _options.DefaultStrokeWidth ?? 2) : Stroke;
string strokeStr = stroke.ToString().Replace(',', '.');
string[] classes = new string[] { _options.CssClass, set.CssClass, Class }.Where(x => x.HasValue()).ToArray();
string[] classes = new[] { set.CssClass.HasValue() ? set.CssClass : _options.CssClass, Class }.Where(x => x.HasValue()).Distinct().ToArray();
output.TagName = "svg";
output.Attributes.SetAttribute("class", string.Join(" ", classes));
@@ -86,7 +86,7 @@ public class IconTagHelper : TagHelper
return inner;
}
return $"<svg class='{_options.CssClass}{(classes.HasValue() ? " " + classes : string.Empty)}' width='{size}' height='{size}'" +
return $"<svg class='{(classes.HasValue() ? " " + classes : string.Empty)}' width='{size}' height='{size}'" +
$"xmlns='http://www.w3.org/2000/svg' stroke-width='{stroke}' data-symbol='{symbol}'>{inner}</svg>";
}
}