From 6e79e884e15346d9a0aed07f1964f482a480e465 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Wed, 11 Sep 2024 08:24:21 +0330 Subject: [PATCH 1/3] improve BitSnackBar demo #8568 --- .../SnackBar/BitSnackBar.razor.cs | 2 +- .../SnackBar/BitSnackBarDemo.razor | 192 ++++++------------ .../SnackBar/BitSnackBarDemo.razor.cs | 120 +++++++++-- 3 files changed, 159 insertions(+), 155 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs b/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs index 36f166a182..e200b91e3f 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs @@ -56,7 +56,7 @@ public partial class BitSnackBar : BitComponentBase - public async Task Show(string title, string? body = "", BitSnackBarType type = BitSnackBarType.None, string? cssClass = null, string? cssStyle = null) + public async Task Show(string title, string? body = "", BitSnackBarType type = BitSnackBarType.Info, string? cssClass = null, string? cssStyle = null) { var item = new BitSnackBarItem { diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor index 07b41daa55..9758842375 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor @@ -9,10 +9,17 @@ ComponentParameters="componentParameters" ComponentSubEnums="componentSubEnums" ComponentSubClasses="componentSubClasses"> - + + + + Open SnackBar + + + +
-
- Show +
+ Show
- + -
-
- - Dismiss Icon Name -
- -
- - -
- @title - -
-
-
- Title Template -
- -
- - -
- @body -
- Yes - No -
- Answer: @bodyTemplateAnswer -
-
-
- Body Template -
-
+ + Dismiss Icon Name +

+ + +
+ @title + +
+
+
+ Title Template +

+ + +
+ @body +
+ Yes + No +
+ Answer: @bodyTemplateAnswer +
+
+
+ Body Template
- + -
-
- Item's Style & Class: -
- - Custom style -
-
-
- - Custom style -
-
-
-
- Styles & Classes: -
- - Custom styles -
-
-
- - Custom classes -
-
+
+
Item's Style & Class:

+ + Custom style +

+ + Custom style +



+
Styles & Classes:

+ + Custom styles +

+ + Custom classes
- - -@code { - private BitSnackBar basicSnackBarRef = new(); - private BitDir direction; - private BitSnackBarType basicSnackBarType = BitSnackBarType.Info; - private BitSnackBarPosition basicSnackBarPosition = BitSnackBarPosition.BottomRight; - private string basicSnackBarTitle = string.Empty; - private string basicSnackBarBody = string.Empty; - private bool basicSnackBarAutoDismiss = true; - private int basicSnackBarDismissSeconds = 3; - - private async Task OpenBasicSnackBar() - { - await basicSnackBarRef.Show(basicSnackBarTitle, basicSnackBarBody, basicSnackBarType); - } - - - private BitSnackBar dismissIconNameRef = new(); - private BitSnackBar titleTemplateRef = new(); - private BitSnackBar bodyTemplateRef = new(); - - private string? bodyTemplateAnswer; - - private async Task OpenDismissIconName() - { - await dismissIconNameRef.Success("This is title", "This is body"); - } - - private async Task OpenTitleTemplate() - { - await titleTemplateRef.Warning("This is title", "This is body"); - } - - private async Task OpenBodyTemplate() - { - await bodyTemplateRef.Error("This is title", "This is body"); - } - - - private BitSnackBar snackBarStyleRef = new(); - private BitSnackBar snackBarClassRef = new(); - private BitSnackBar snackBarStylesRef = new(); - private BitSnackBar snackBarClassesRef = new(); - - private async Task OpenSnackBarStyle() - { - await snackBarClassRef.Show("This is title", "This is body", cssStyle: "background-color: dodgerblue; border-radius: 0.5rem;"); - } - - private async Task OpenSnackBarClass() - { - await snackBarStyleRef.Show("This is title", "This is body", cssClass: "custom-class"); - } - - private async Task OpenSnackBarStyles() - { - await snackBarStylesRef.Show("This is title", "This is body"); - } - - private async Task OpenSnackBarClasses() - { - await snackBarClassesRef.Show("This is title", "This is body"); - } -} \ No newline at end of file + \ No newline at end of file diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cs index 511a1753aa..13466705d6 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cs +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cs @@ -230,7 +230,87 @@ public partial class BitSnackBarDemo + private BitSnackBar basicRef = default!; + private async Task OpenBasicSnackBar() + { + await basicRef.Show("This is title", "This is body"); + } + + + private string? bodyTemplateAnswer; + private BitSnackBar bodyTemplateRef = default!; + private BitSnackBar titleTemplateRef = default!; + private BitSnackBar dismissIconNameRef = default!; + + private async Task OpenDismissIconName() + { + await dismissIconNameRef.Success("This is title", "This is body"); + } + + private async Task OpenTitleTemplate() + { + await titleTemplateRef.Warning("This is title", "This is body"); + } + + private async Task OpenBodyTemplate() + { + await bodyTemplateRef.Error("This is title", "This is body"); + } + + + private BitDir direction; + private BitSnackBar customizationRef = default!; + private BitSnackBarType basicSnackBarType = BitSnackBarType.Info; + private BitSnackBarPosition basicSnackBarPosition = BitSnackBarPosition.BottomRight; + private string basicSnackBarTitle = "This is title"; + private string basicSnackBarBody = "This is body"; + private bool basicSnackBarAutoDismiss = true; + private int basicSnackBarDismissSeconds = 3; + + private async Task OpenCustomizationSnackBar() + { + await customizationRef.Show(basicSnackBarTitle, basicSnackBarBody, basicSnackBarType); + } + + + private BitSnackBar snackBarStyleRef = default!; + private BitSnackBar snackBarClassRef = default!; + private BitSnackBar snackBarStylesRef = default!; + private BitSnackBar snackBarClassesRef = default!; + + private async Task OpenSnackBarStyle() + { + await snackBarClassRef.Show("This is title", "This is body", cssStyle: "background-color: dodgerblue; border-radius: 0.5rem;", type: BitSnackBarType.None); + } + + private async Task OpenSnackBarClass() + { + await snackBarStyleRef.Show("This is title", "This is body", cssClass: "custom-class", type: BitSnackBarType.None); + } + + private async Task OpenSnackBarStyles() + { + await snackBarStylesRef.Show("This is title", "This is body", type: BitSnackBarType.None); + } + + private async Task OpenSnackBarClasses() + { + await snackBarClassesRef.Show("This is title", "This is body", type: BitSnackBarType.None); + } + + + private readonly string example1RazorCode = @" + +Open SnackBar"; + private readonly string example1CsharpCode = @" +private BitSnackBar basicRef = default!; +private async Task OpenBasicSnackBar() +{ + await basicRef.Show(""This is title"", ""This is body""); +}"; + + private readonly string example2RazorCode = @" -Show"; - private readonly string example1CsharpCode = @" -private BitSnackBar basicSnackBarRef = new(); +Show"; + private readonly string example2CsharpCode = @" private BitDir direction; +private BitSnackBar basicSnackBarRef = default!; private BitSnackBarType basicSnackBarType = BitSnackBarType.Info; private BitSnackBarPosition basicSnackBarPosition = BitSnackBarPosition.BottomRight; -private string basicSnackBarTitle = string.Empty; -private string basicSnackBarBody = string.Empty; +private string basicSnackBarTitle = ""This is title""; +private string basicSnackBarBody = ""This is body""; private bool basicSnackBarAutoDismiss = true; private int basicSnackBarDismissSeconds = 3; @@ -282,7 +362,7 @@ private async Task OpenBasicSnackBar() await basicSnackBarRef.Show(basicSnackBarTitle, basicSnackBarBody, basicSnackBarType); }"; - private readonly string example2RazorCode = @" + private readonly string example3RazorCode = @" Dismiss Icon Name @@ -309,10 +389,10 @@ private async Task OpenBasicSnackBar() Body Template"; - private readonly string example2CsharpCode = @" -private BitSnackBar dismissIconNameRef = new(); -private BitSnackBar titleTemplateRef = new(); -private BitSnackBar bodyTemplateRef = new(); + private readonly string example3CsharpCode = @" +private BitSnackBar dismissIconNameRef = default!; +private BitSnackBar titleTemplateRef = default!; +private BitSnackBar bodyTemplateRef = default!; private string? bodyTemplateAnswer; @@ -331,7 +411,7 @@ private async Task OpenBodyTemplate() await bodyTemplateRef.Error(""This is title"", ""This is body""); }"; - private readonly string example3RazorCode = @" + private readonly string example4RazorCode = @"