From 2c8d7d2c3e23da827223bc9078ecc144dbc123bc Mon Sep 17 00:00:00 2001 From: Mohammad Aminsafaei Date: Thu, 9 Jan 2025 14:00:47 +0330 Subject: [PATCH 1/2] Add Classes/Styles parameters in the BitMessageBox (#9637) --- .../Components/MessageBox/BitMessageBox.razor | 28 ++-- .../MessageBox/BitMessageBox.razor.cs | 10 ++ .../MessageBox/BitMessageBoxClassStyles.cs | 49 ++++++ .../Extras/MessageBox/BitMessageBoxDemo.razor | 23 ++- .../MessageBox/BitMessageBoxDemo.razor.cs | 139 ++++++++++++------ .../BitMessageBoxDemo.razor.samples.cs | 79 ++++++++++ .../MessageBox/BitMessageBoxDemo.razor.scss | 21 +++ 7 files changed, 297 insertions(+), 52 deletions(-) create mode 100644 src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs create mode 100644 src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor index 8b739f2adc..08a038ff75 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor @@ -1,24 +1,34 @@ @namespace Bit.BlazorUI -
-
-
- @Title +
+
+
+ + @Title + - + + Variant="BitVariant.Text" + Styles="@Styles?.CloseButton" + Classes="@Classes?.CloseButton" />
-
+
@Body
-
- +
+ @(OkText ?? "Ok")
diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs index ff27a97a4e..018cff5288 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs @@ -9,6 +9,11 @@ public partial class BitMessageBox /// [Parameter] public string? Body { get; set; } + /// + /// Custom CSS classes for different parts of the message box. + /// + [Parameter] public BitMessageBoxClassStyles? Classes { get; set; } + /// /// The text of the Ok button. /// @@ -19,6 +24,11 @@ public partial class BitMessageBox /// [Parameter] public EventCallback OnClose { get; set; } + /// + /// Custom CSS styles for different parts of the message box. + /// + [Parameter] public BitMessageBoxClassStyles? Styles { get; set; } + /// /// The title of the message box. /// diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs new file mode 100644 index 0000000000..8d355632bf --- /dev/null +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs @@ -0,0 +1,49 @@ +namespace Bit.BlazorUI; + +public class BitMessageBoxClassStyles +{ + /// + /// Custom CSS classes/styles for the root element of the BitMessageBox. + /// + public string? Root { get; set; } + + /// + /// Custom CSS classes/styles for the content of the BitMessageBox. + /// + public string? Content { get; set; } + + /// + /// Custom CSS classes/styles for the header of the BitMessageBox. + /// + public string? Header { get; set; } + + /// + /// Custom CSS classes/styles for the title of the BitMessageBox. + /// + public string? Title { get; set; } + + /// + /// Custom CSS classes/styles for the BitSpacer of the BitMessageBox. + /// + public string? Spacer { get; set; } + + /// + /// Custom CSS classes/styles for the CloseButton of the BitMessageBox. + /// + public BitButtonClassStyles? CloseButton { get; set; } + + /// + /// Custom CSS classes/styles for the body of the BitMessageBox. + /// + public string? Body { get; set; } + + /// + /// Custom CSS classes/styles for the footer of the BitMessageBox. + /// + public string? Footer { get; set; } + + /// + /// Custom CSS classes/styles for the OkButton of the BitMessageBox. + /// + public BitButtonClassStyles? OkButton { get; set; } +} diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor index 407032fc8e..ce77901e39 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor @@ -7,7 +7,8 @@ + ComponentParameters="componentParameters" + ComponentSubClasses="componentSubClasses"> @@ -36,4 +37,24 @@ Show MessageBox + + + +
Customize the appearance of BitActionButton using styles and CSS classes.
+
+
+ + + +
+ + + +
+
+
\ No newline at end of file diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs index 1e03830cb5..b7e6692a1d 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs @@ -11,6 +11,15 @@ public partial class BitMessageBoxDemo DefaultValue = "null", Description = "The body of the message box.", }, + new() + { + Name = "Classes", + Type = "BitMessageBoxClassStyles?", + DefaultValue = "null", + Description = "Custom CSS classes for different parts of the message box.", + LinkType = LinkType.Link, + Href = "#class-styles", + }, new() { Name = "OkText", @@ -26,6 +35,15 @@ public partial class BitMessageBoxDemo Description = "The event callback for closing the message box.", }, new() + { + Name = "Styles", + Type = "BitMessageBoxClassStyles?", + DefaultValue = "null", + Description = "Custom CSS styles for different parts of the message box.", + LinkType = LinkType.Link, + Href = "#class-styles", + }, + new() { Name = "Title", Type = "string?", @@ -34,6 +52,85 @@ public partial class BitMessageBoxDemo }, ]; + private readonly List componentSubClasses = + [ + new() + { + Id = "class-styles", + Title = "BitMessageBoxClassStyles", + Parameters = + [ + new() + { + Name = "Root", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the root element of the BitMessageBox." + }, + new() + { + Name = "Content", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the content of the BitMessageBox." + }, + new() + { + Name = "Header", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the header of the BitMessageBox." + }, + new() + { + Name = "Title", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the title of the BitMessageBox." + }, + new() + { + Name = "Spacer", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the BitSpacer of the BitMessageBox." + }, + new() + { + Name = "CloseButton", + Type = "BitButtonClassStyles?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the CloseButton of the BitMessageBox.", + LinkType = LinkType.Link, + Href = "/components/button/#class-styles" + }, + new() + { + Name = "Body", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the body of the BitMessageBox." + }, + new() + { + Name = "Footer", + Type = "string?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the footer of the BitMessageBox." + }, + new() + { + Name = "OkButton", + Type = "BitButtonClassStyles?", + DefaultValue = "null", + Description = "Custom CSS classes/styles for the OkButton of the BitMessageBox.", + LinkType = LinkType.Link, + Href = "/components/button/#class-styles" + } + ] + } + ]; + private bool isModalOpen; @@ -55,46 +152,4 @@ private async Task ShowMessageBoxService() { await messageBoxService.Show("TITLE", "BODY"); } - - - - private readonly string example1RazorCode = @" - - -"; - - private readonly string example2RazorCode = @" - isModalOpen = true"">Show - - isModalOpen = false"" Title=""This is the Title"" Body=""This is the Body!"" /> -"; - private readonly string example2CsharpCode = @" -private bool isModalOpen;"; - - private readonly string example3RazorCode = @" -Show MessageBox - -"; - private readonly string example3CsharpCode = @" -[AutoInject] private BitModalService modalService { get; set; } = default!; -private async Task ShowMessageBox() -{ - BitModalReference modalRef = default!; - Dictionary parameters = new() - { - { nameof(BitMessageBox.Title), ""This is a title"" }, - { nameof(BitMessageBox.Body), ""This is a body."" }, - { nameof(BitMessageBox.OnClose), EventCallback.Factory.Create(this, () => modalRef.Close()) } - }; - modalRef = await modalService.Show(parameters); -}"; - - private readonly string example4RazorCode = @" -Show MessageBox"; - private readonly string example4CsharpCode = @" -[AutoInject] private BitMessageBoxService messageBoxService { get; set; } = default!; -private async Task ShowMessageBoxService() -{ - await messageBoxService.Show(""TITLE"", ""BODY""); -}"; } diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs new file mode 100644 index 0000000000..99d139bcd3 --- /dev/null +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs @@ -0,0 +1,79 @@ +namespace Bit.BlazorUI.Demo.Client.Core.Pages.Components.Extras.MessageBox; + +public partial class BitMessageBoxDemo +{ + private readonly string example1RazorCode = @" + + +"; + + private readonly string example2RazorCode = @" + isModalOpen = true"">Show + + isModalOpen = false"" Title=""This is the Title"" Body=""This is the Body!"" /> +"; + private readonly string example2CsharpCode = @" +private bool isModalOpen;"; + + private readonly string example3RazorCode = @" +Show MessageBox + +"; + private readonly string example3CsharpCode = @" +[AutoInject] private BitModalService modalService { get; set; } = default!; +private async Task ShowMessageBox() +{ + BitModalReference modalRef = default!; + Dictionary parameters = new() + { + { nameof(BitMessageBox.Title), ""This is a title"" }, + { nameof(BitMessageBox.Body), ""This is a body."" }, + { nameof(BitMessageBox.OnClose), EventCallback.Factory.Create(this, () => modalRef.Close()) } + }; + modalRef = await modalService.Show(parameters); +}"; + + private readonly string example4RazorCode = @" +Show MessageBox"; + private readonly string example4CsharpCode = @" +[AutoInject] private BitMessageBoxService messageBoxService { get; set; } = default!; +private async Task ShowMessageBoxService() +{ + await messageBoxService.Show(""TITLE"", ""BODY""); +}"; + + private readonly string example5RazorCode = @" + + + + + + + + +"; +} diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss index e69de29bb2..aafd8697ea 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss @@ -0,0 +1,21 @@ +::deep { + .custom-msg { + background: linear-gradient(180deg, #3e0f0f, transparent) #000; + } + + .custom-msg-btn { + color: #fff; + font-weight: bold; + border-radius: 1rem; + border-color: #8f0101; + transition: background-color 1s; + background: linear-gradient(90deg, #d10000, transparent) #8f0101; + } + + .custom-msg-btn:hover { + color: #fff; + font-weight: bold; + border-color: #8f0101; + background-color: #8f0101; + } +} From 057e9a25114289120afe24984bdc3356a9bb55d3 Mon Sep 17 00:00:00 2001 From: Mohammad Aminsafaei Date: Thu, 9 Jan 2025 15:17:13 +0330 Subject: [PATCH 2/2] Resolve comment --- .../Components/MessageBox/BitMessageBox.razor | 2 +- .../Components/MessageBox/BitMessageBoxClassStyles.cs | 4 ++-- .../Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor index 08a038ff75..b36adb8b27 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor @@ -1,7 +1,7 @@ @namespace Bit.BlazorUI
-
+
- /// Custom CSS classes/styles for the content of the BitMessageBox. + /// Custom CSS classes/styles for the container of the BitMessageBox. /// - public string? Content { get; set; } + public string? Container { get; set; } /// /// Custom CSS classes/styles for the header of the BitMessageBox. diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs index b7e6692a1d..fe7b10e9c4 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs @@ -69,10 +69,10 @@ public partial class BitMessageBoxDemo }, new() { - Name = "Content", + Name = "Container", Type = "string?", DefaultValue = "null", - Description = "Custom CSS classes/styles for the content of the BitMessageBox." + Description = "Custom CSS classes/styles for the container of the BitMessageBox." }, new() {