Allow TextInfoLines to color its content

This commit is contained in:
tsommer committed 2025-02-10 22:13:54 +01:00
1 parent 7642bfa76c
commit a695e3c05f
4 files changed
+42

No files matched your search

@@ -9,6 +9,7 @@
Lines="3"
MaxLines="@this.MaxLines"
AutoGrow="@true"
Style="@this.GetColor()"
UserAttributes="@USER_INPUT_ATTRIBUTES" />
@if (this.ShowingCopyButton)
@@ -20,6 +20,9 @@ public partial class TextInfoLines : ComponentBase
[Parameter]
public bool ShowingCopyButton { get; set; } = true;
[Parameter]
public TextColor Color { get; set; } = TextColor.DEFAULT;
[Inject]
private RustService RustService { get; init; } = null!;
@@ -47,4 +50,13 @@ public partial class TextInfoLines : ComponentBase
private string ClipboardTooltip => $"Copy {this.ClipboardTooltipSubject} to the clipboard";
private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content);
private string GetColor()
{
var htmlColorCode = this.Color.GetHTMLColor(this.SettingsManager);
if(string.IsNullOrWhiteSpace(htmlColorCode))
return string.Empty;
return $"color: {htmlColorCode} !important;";
}
}