diff --git a/Ticky.Base/Models/LabelModel.cs b/Ticky.Base/Models/LabelModel.cs index ad83bc3..79e425a 100644 --- a/Ticky.Base/Models/LabelModel.cs +++ b/Ticky.Base/Models/LabelModel.cs @@ -8,9 +8,9 @@ public class LabelModel [Required(AllowEmptyStrings = false)] [Display(Name = "Text color")] - public Color? TextColor { get; set; } + public Color TextColor { get; set; } = Color.White; [Required(AllowEmptyStrings = false)] [Display(Name = "Background color")] - public Color? BackgroundColor { get; set; } + public Color BackgroundColor { get; set; } = Color.Red; } diff --git a/Ticky.Internal/Helpers/ColorHelper.cs b/Ticky.Internal/Helpers/ColorHelper.cs new file mode 100644 index 0000000..7a7e349 --- /dev/null +++ b/Ticky.Internal/Helpers/ColorHelper.cs @@ -0,0 +1,8 @@ +using System.Drawing; + +namespace Ticky.Internal.Helpers; + +public static class ColorHelper +{ + public static string ToColorInputValue(this Color color) => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; +} diff --git a/Ticky.Web/Components/Dialogs/AddLabelModal.razor b/Ticky.Web/Components/Dialogs/AddLabelModal.razor index 907fe81..a7f0d3a 100644 --- a/Ticky.Web/Components/Dialogs/AddLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/AddLabelModal.razor @@ -16,13 +16,13 @@
- +
- +
@@ -53,8 +53,8 @@ { BoardId = board.Id, Name = "Example", - BackgroundColor = Color.AliceBlue, - TextColor = Color.Black + BackgroundColor = _labelModel.BackgroundColor, + TextColor = _labelModel.TextColor }; _editContext = new EditContext(_labelModel); @@ -111,8 +111,8 @@ { BoardId = board.Id, Name = _labelModel.Text, - TextColor = _labelModel.TextColor!.Value, - BackgroundColor = _labelModel.BackgroundColor!.Value + TextColor = _labelModel.TextColor, + BackgroundColor = _labelModel.BackgroundColor }); await db.SaveChangesAsync(); @@ -122,4 +122,4 @@ await OnSubmit.InvokeAsync(); Modal?.Close(); } -} \ No newline at end of file +} diff --git a/Ticky.Web/Components/Dialogs/EditLabelModal.razor b/Ticky.Web/Components/Dialogs/EditLabelModal.razor index db4c0f2..16ca968 100644 --- a/Ticky.Web/Components/Dialogs/EditLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/EditLabelModal.razor @@ -16,13 +16,13 @@
- +
- +
@@ -63,7 +63,7 @@ BackgroundColor = label.BackgroundColor, TextColor = label.TextColor }; - _editContext = new EditContext(_board); + _editContext = new EditContext(_labelModel); base.Open(); } @@ -121,8 +121,8 @@ targetLabel.BoardId = board.Id; targetLabel.Name = _labelModel.Text; - targetLabel.TextColor = _labelModel.TextColor!.Value; - targetLabel.BackgroundColor = _labelModel.BackgroundColor!.Value; + targetLabel.TextColor = _labelModel.TextColor; + targetLabel.BackgroundColor = _labelModel.BackgroundColor; await db.SaveChangesAsync(); @@ -131,4 +131,4 @@ await OnSubmit.InvokeAsync(); Modal?.Close(); } -} \ No newline at end of file +}