From 638c0a07408cc704fc34f75cb232f6c17fe4c40c Mon Sep 17 00:00:00 2001 From: Jorge Osta Date: Thu, 23 Mar 2023 23:15:14 +0100 Subject: [PATCH 1/5] Add move-in animation usable on CustomLayout --- samples/BlazorServer/Pages/Animation.razor | 22 +++++- samples/BlazorServer/Pages/CustomLayout.razor | 13 +++- .../Shared/CustomAnimatedBootstrapModal.razor | 29 ++++++++ .../Shared/CustomBootstrapModal.razor | 4 +- .../BlazorWebAssembly/Pages/Animation.razor | 16 +++++ .../Pages/CustomLayout.razor | 10 +++ .../Shared/CustomAnimatedBootstrapModal.razor | 29 ++++++++ .../Shared/CustomBootstrapModal.razor | 6 +- .../BlazoredModalInstance.razor | 18 ++--- .../BlazoredModalInstance.razor.cs | 43 +++++++++--- .../BlazoredModalInstance.razor.css | 69 +++++++++++++------ .../Configuration/ModalAnimationType.cs | 5 ++ 12 files changed, 216 insertions(+), 48 deletions(-) create mode 100644 samples/BlazorServer/Shared/CustomAnimatedBootstrapModal.razor create mode 100644 samples/BlazorWebAssembly/Shared/CustomAnimatedBootstrapModal.razor diff --git a/samples/BlazorServer/Pages/Animation.razor b/samples/BlazorServer/Pages/Animation.razor index ae99bdd8..11d551c9 100644 --- a/samples/BlazorServer/Pages/Animation.razor +++ b/samples/BlazorServer/Pages/Animation.razor @@ -33,6 +33,8 @@ + +

@@ -49,6 +51,20 @@ Modal.Show("Default Animation"); } + void FadeInAnimation() + { + var options = new ModalOptions { AnimationType = ModalAnimationType.FadeIn }; + + Modal.Show("FadeIn Animation", options); + } + + void MoveInOutAnimation() + { + var options = new ModalOptions { AnimationType = ModalAnimationType.MoveInOut }; + + Modal.Show("MoveInOut Animation", options); + } + void NoAnimation() { var options = new ModalOptions { AnimationType = ModalAnimationType.None }; @@ -59,9 +75,9 @@ void MultipleModals() { var options = new ModalOptions - { - AnimationType = ModalAnimationType.None - }; + { + AnimationType = ModalAnimationType.None + }; Modal.Show("Multiple Modals", options); } diff --git a/samples/BlazorServer/Pages/CustomLayout.razor b/samples/BlazorServer/Pages/CustomLayout.razor index 948970ea..8d746bb1 100644 --- a/samples/BlazorServer/Pages/CustomLayout.razor +++ b/samples/BlazorServer/Pages/CustomLayout.razor @@ -33,6 +33,8 @@ + + @code { [CascadingParameter] public IModalService Modal { get; set; } = default!; @@ -40,8 +42,17 @@ void ShowModalCustomLayout() { var options = new ModalOptions { UseCustomLayout = true }; - var parameters = new ModalParameters {{nameof(CustomBootstrapModal.Message), "Hello custom modal!!"}}; + var parameters = new ModalParameters(); + parameters.Add(nameof(CustomBootstrapModal.Message), "Hello Bootstrap modal!!"); Modal.Show("Custom Layout", parameters, options); } + void ShowAnimatedModalCustomLayout() + { + var options = new ModalOptions { UseCustomLayout = true, AnimationType = ModalAnimationType.MoveInOut }; + var parameters = new ModalParameters(); + parameters.Add(nameof(CustomBootstrapModal.Message), "Hello Bootstrap modal!!"); + Modal.Show("Custom Layout", parameters, options); + } + } diff --git a/samples/BlazorServer/Shared/CustomAnimatedBootstrapModal.razor b/samples/BlazorServer/Shared/CustomAnimatedBootstrapModal.razor new file mode 100644 index 00000000..995ed77b --- /dev/null +++ b/samples/BlazorServer/Shared/CustomAnimatedBootstrapModal.razor @@ -0,0 +1,29 @@ +

+ +@code { + + [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; } = default!; + + [Parameter] public string? Message { get; set; } + + async Task Close() => await BlazoredModal.CloseAsync(ModalResult.Ok(true)); + async Task Cancel() => await BlazoredModal.CancelAsync(); + +} \ No newline at end of file diff --git a/samples/BlazorServer/Shared/CustomBootstrapModal.razor b/samples/BlazorServer/Shared/CustomBootstrapModal.razor index 54572a28..6f03427c 100644 --- a/samples/BlazorServer/Shared/CustomBootstrapModal.razor +++ b/samples/BlazorServer/Shared/CustomBootstrapModal.razor @@ -4,9 +4,7 @@