mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 21:31:45 +02:00
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
Phantom.Server.Database
Phantom.Server.Database.Postgres
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Forms
Graphics
Utils
BlazorUtils.cs
BootstrapEditContext.cs
DebounceTimer.cs
EditContextExtensions.cs
FormValidationAttribute.cs
Throttler.cs
Phantom.Server.Web.Components.csproj
_Imports.razor
Utils
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
PhantomPanel.sln
global.json
28 lines
937 B
C#
28 lines
937 B
C#
using System.Globalization;
|
|
|
|
namespace Phantom.Server.Web.Components.Utils;
|
|
|
|
static class BlazorUtils {
|
|
public static string? CombineClassNames(IReadOnlyDictionary<string, object>? additionalAttributes, string? classNames) {
|
|
if (additionalAttributes is null || !additionalAttributes.TryGetValue("class", out var @class)) {
|
|
return classNames;
|
|
}
|
|
|
|
var classAttributeValue = Convert.ToString(@class, CultureInfo.InvariantCulture);
|
|
|
|
if (string.IsNullOrEmpty(classAttributeValue)) {
|
|
return classNames;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(classNames)) {
|
|
return classAttributeValue;
|
|
}
|
|
|
|
return $"{classAttributeValue} {classNames}";
|
|
}
|
|
|
|
public static bool CombineBooleansWithOr(IReadOnlyDictionary<string, object>? additionalAttributes, string attributeName, bool value) {
|
|
return value || (additionalAttributes is not null && additionalAttributes.TryGetValue(attributeName, out var @bool) && @bool is bool and true);
|
|
}
|
|
}
|