Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GetPartWrapperCssClasses and GetFieldWrapperCssClasses helpers #14591

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>()
{
Expand All @@ -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<string>()
{
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OrchardCore;

public static class CssOrchardHelper
public static class CssOrchardHelperExtensions
{
public static string GetLimitedWidthWrapperCssClasses(this IOrchardHelper helper, params string[] additionalClasses)
{
Expand Down Expand Up @@ -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<IOptions<TheAdminThemeOptions>>().Value;
private static TheAdminThemeOptions GetThemeOptions(IOrchardHelper helper)
=> helper.HttpContext.RequestServices.GetService<IOptions<TheAdminThemeOptions>>().Value;

private static IEnumerable<string> Combine(string optionClasses, string[] additionalClasses)
{
Expand Down
Loading