From d971eaeddff4020447bb42c295e994d7ea25ddf7 Mon Sep 17 00:00:00 2001 From: Nathan Phillips Date: Tue, 17 Dec 2024 16:37:22 +0000 Subject: [PATCH] Add RenderFragment content to ToastMessage (#965) * Add RenderFragment content to ToastMessage * Toasts demo updated. --------- Co-authored-by: Nathan Phillips Co-authored-by: Vikram Reddy --- .../Pages/Toasts/ToastsDocumentation.razor | 4 ++++ .../Toasts_Demo_07_Toast_With_Content.razor | 16 ++++++++++++++++ .../Components/Toasts/SimpleToast.razor | 1 + blazorbootstrap/Components/Toasts/Toast.razor | 1 + blazorbootstrap/Models/ToastMessage.cs | 2 ++ 5 files changed, 24 insertions(+) create mode 100644 BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/Toasts_Demo_07_Toast_With_Content.razor diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/ToastsDocumentation.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/ToastsDocumentation.razor index 894921b87..e7efd933f 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/ToastsDocumentation.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/ToastsDocumentation.razor @@ -28,6 +28,10 @@ +
+ +
+
Add AutoHide="true" parameter to hide the Blazor Toasts after the delay. The default delay is 5000 milliseconds, be sure to update the delay timeout so that users have enough time to read the toast.
diff --git a/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/Toasts_Demo_07_Toast_With_Content.razor b/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/Toasts_Demo_07_Toast_With_Content.razor new file mode 100644 index 000000000..5e0c3e1e4 --- /dev/null +++ b/BlazorBootstrap.Demo.RCL/Components/Pages/Toasts/Toasts_Demo_07_Toast_With_Content.razor @@ -0,0 +1,16 @@ + + + + +@code { + List messages = []; + + private void ShowToast() => + messages.Add( + new ToastMessage + { + Type = ToastType.Info, + Title = "Blazor Bootstrap", + Content = @
Hello, world! This is a toast message.
, + }); +} diff --git a/blazorbootstrap/Components/Toasts/SimpleToast.razor b/blazorbootstrap/Components/Toasts/SimpleToast.razor index ec0843e9d..a43862409 100644 --- a/blazorbootstrap/Components/Toasts/SimpleToast.razor +++ b/blazorbootstrap/Components/Toasts/SimpleToast.razor @@ -6,6 +6,7 @@
@ToastMessage?.Message + @ToastMessage?.Content
@if (!AutoHide || ShowCloseButton) { diff --git a/blazorbootstrap/Components/Toasts/Toast.razor b/blazorbootstrap/Components/Toasts/Toast.razor index 83f4afec7..b35811629 100644 --- a/blazorbootstrap/Components/Toasts/Toast.razor +++ b/blazorbootstrap/Components/Toasts/Toast.razor @@ -13,6 +13,7 @@
@ToastMessage.Message + @ToastMessage.Content
diff --git a/blazorbootstrap/Models/ToastMessage.cs b/blazorbootstrap/Models/ToastMessage.cs index 25482cdf9..316d516c9 100644 --- a/blazorbootstrap/Models/ToastMessage.cs +++ b/blazorbootstrap/Models/ToastMessage.cs @@ -102,6 +102,8 @@ public ToastMessage(ToastType type, string customIconName, string title, string public string? Message { get; set; } + public RenderFragment? Content { get; set; } + public string? Title { get; set; } public ToastType Type { get; set; }