mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 10:39:07 +00:00
Allow TextInfoLines to color its content
This commit is contained in:
4 files changed
+42
No files matched your search
@@ -9,6 +9,7 @@
|
|||||||
Lines="3"
|
Lines="3"
|
||||||
MaxLines="@this.MaxLines"
|
MaxLines="@this.MaxLines"
|
||||||
AutoGrow="@true"
|
AutoGrow="@true"
|
||||||
|
Style="@this.GetColor()"
|
||||||
UserAttributes="@USER_INPUT_ATTRIBUTES" />
|
UserAttributes="@USER_INPUT_ATTRIBUTES" />
|
||||||
|
|
||||||
@if (this.ShowingCopyButton)
|
@if (this.ShowingCopyButton)
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public partial class TextInfoLines : ComponentBase
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public bool ShowingCopyButton { get; set; } = true;
|
public bool ShowingCopyButton { get; set; } = true;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public TextColor Color { get; set; } = TextColor.DEFAULT;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private RustService RustService { get; init; } = null!;
|
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 string ClipboardTooltip => $"Copy {this.ClipboardTooltipSubject} to the clipboard";
|
||||||
|
|
||||||
private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content);
|
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;";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public enum TextColor
|
||||||
|
{
|
||||||
|
DEFAULT,
|
||||||
|
|
||||||
|
WARN,
|
||||||
|
ERROR,
|
||||||
|
SUCCESS,
|
||||||
|
INFO,
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public static class TextColorExtensions
|
||||||
|
{
|
||||||
|
public static string GetHTMLColor(this TextColor color, SettingsManager settingsManager) => color switch
|
||||||
|
{
|
||||||
|
TextColor.DEFAULT => string.Empty,
|
||||||
|
|
||||||
|
TextColor.ERROR => settingsManager.IsDarkMode ? "#ff6c6c" : "#ff0000",
|
||||||
|
TextColor.WARN => settingsManager.IsDarkMode ? "#c7a009" : "#c7c000",
|
||||||
|
TextColor.SUCCESS => settingsManager.IsDarkMode ? "#08b342" : "#009933",
|
||||||
|
TextColor.INFO => settingsManager.IsDarkMode ? "#5279b8" : "#2d67c4",
|
||||||
|
|
||||||
|
_ => string.Empty,
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in new issue
Block a user