diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs index 72a5690b049..76cb3975020 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/Razor/CssOrchardHelperExtensions.cs @@ -4,12 +4,12 @@ namespace OrchardCore; -public static class CssOrchardHelper +public static class CssOrchardHelperExtensions { private const string FieldWrapperPrefix = "field-wrapper"; private const string PartWrapperPrefix = "content-part-wrapper"; - - public static string GetPartWrapperCssClasses(this IOrchardHelper helper, ContentTypePartDefinition partDefinition) + + public static string GetPartWrapperCssClasses(this IOrchardHelper helper, ContentTypePartDefinition partDefinition, params string[] additionalClasses) { var items = new List() { @@ -19,17 +19,22 @@ public static string GetPartWrapperCssClasses(this IOrchardHelper helper, Conten if (partDefinition != null) { items.Add($"{PartWrapperPrefix}-{partDefinition.PartDefinition.Name.HtmlClassify()}"); - + if (partDefinition.IsNamedPart()) { items.Add($"{PartWrapperPrefix}-{partDefinition.Name.HtmlClassify()}"); } } + if (additionalClasses?.Length > 0) + { + items.AddRange(additionalClasses); + } + return helper.GetWrapperCssClasses(items.ToArray()); } - - public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, ContentPartFieldDefinition fieldDefinition) + + public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, ContentPartFieldDefinition fieldDefinition, params string[] additionalClasses) { var items = new List() { @@ -39,13 +44,18 @@ public static string GetFieldWrapperCssClasses(this IOrchardHelper helper, Conte if (fieldDefinition != null) { items.Add($"{FieldWrapperPrefix}-{fieldDefinition.PartDefinition.Name}-{fieldDefinition.Name}".HtmlClassify()); - + if (fieldDefinition.IsNamedPart()) { items.Add($"{FieldWrapperPrefix}-{fieldDefinition.ContentTypePartDefinition.Name}-{fieldDefinition.Name}".HtmlClassify()); } } + if (additionalClasses?.Length > 0) + { + items.AddRange(additionalClasses); + } + return helper.GetWrapperCssClasses(items.ToArray()); } } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs similarity index 94% rename from src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs rename to src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs index 152fd88aba8..145bfc44f8e 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelper.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Html/CssOrchardHelperExtensions.cs @@ -6,7 +6,7 @@ namespace OrchardCore; -public static class CssOrchardHelper +public static class CssOrchardHelperExtensions { public static string GetLimitedWidthWrapperCssClasses(this IOrchardHelper helper, params string[] additionalClasses) { @@ -74,7 +74,8 @@ public static string GetOffsetCssClasses(this IOrchardHelper helper, params stri return string.Join(' ', Combine(options.OffsetClasses, additionalClasses)); } - private static TheAdminThemeOptions GetThemeOptions(IOrchardHelper helper) => helper.HttpContext.RequestServices.GetService>().Value; + private static TheAdminThemeOptions GetThemeOptions(IOrchardHelper helper) + => helper.HttpContext.RequestServices.GetService>().Value; private static IEnumerable Combine(string optionClasses, string[] additionalClasses) {