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..cfe6b13301 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs @@ -56,6 +56,9 @@ public partial class BitSnackBar : BitComponentBase + /// + /// Shows the snackbar. + /// public async Task Show(string title, string? body = "", BitSnackBarType type = BitSnackBarType.None, string? cssClass = null, string? cssStyle = null) { var item = new BitSnackBarItem @@ -83,12 +86,24 @@ public async Task Show(string title, string? body = "", BitSnackBarType type = B await InvokeAsync(StateHasChanged); } + /// + /// Shows the snackbar with Info type. + /// public Task Info(string title, string? body = "") => Show(title, body, BitSnackBarType.Info); + /// + /// Shows the snackbar with Success type. + /// public Task Success(string title, string? body = "") => Show(title, body, BitSnackBarType.Success); + /// + /// Shows the snackbar with Warning type. + /// public Task Warning(string title, string? body = "") => Show(title, body, BitSnackBarType.Warning); + /// + /// Shows the snackbar with Error type. + /// public Task Error(string title, string? body = "") => Show(title, body, BitSnackBarType.Error); 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..8d0a71afc5 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 @@ -8,11 +8,19 @@ ComponentDescription="SnackBars provide brief notifications. The component is also known as a toast." ComponentParameters="componentParameters" ComponentSubEnums="componentSubEnums" - ComponentSubClasses="componentSubClasses"> - + ComponentSubClasses="componentSubClasses" + ComponentPublicMembers="componentPublicMembers"> + + + + 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..32a70bf80f 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 @@ -228,9 +228,128 @@ public partial class BitSnackBarDemo } ]; + private readonly List componentPublicMembers = + [ + new() + { + Name = "Show", + Type = "async Task Show(string title, string? body = \"\", BitSnackBarType type = BitSnackBarType.None, string? cssClass = null, string? cssStyle = null)", + DefaultValue = "", + Description = "Shows the snackbar.", + }, + new() + { + Name = "Info", + Type = "Task Info(string title, string? body = \"\")", + DefaultValue = "", + Description = "Shows the snackbar with Info type.", + }, + new() + { + Name = "Success", + Type = "Task Success(string title, string? body = \"\")", + DefaultValue = "", + Description = "Shows the snackbar with Success type.", + }, + new() + { + Name = "Warning", + Type = "Task Warning(string title, string? body = \"\")", + DefaultValue = "", + Description = "Shows the snackbar with Warning type.", + }, + new() + { + Name = "Error", + Type = "Task Error(string title, string? body = \"\")", + DefaultValue = "", + Description = "Shows the snackbar with Error type.", + } + ]; + + + + private BitSnackBar basicRef = default!; + private async Task OpenBasicSnackBar() + { + await basicRef.Info("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 int basicSnackBarDismissSeconds = 3; + private bool basicSnackBarAutoDismiss = true; + private BitSnackBar customizationRef = default!; + private string basicSnackBarBody = "This is body"; + private string basicSnackBarTitle = "This is title"; + private BitSnackBarType basicSnackBarType = BitSnackBarType.Info; + private BitSnackBarPosition basicSnackBarPosition = BitSnackBarPosition.BottomRight; + + 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;"); + } + + 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"); + } + private readonly string example1RazorCode = @" + +Open SnackBar"; + private readonly string example1CsharpCode = @" +private BitSnackBar basicRef = default!; +private async Task OpenBasicSnackBar() +{ + await basicRef.Info(""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 int basicSnackBarDismissSeconds = 3; +private bool basicSnackBarAutoDismiss = true; +private BitSnackBar customizationRef = default!; +private string basicSnackBarBody = ""This is body""; +private string basicSnackBarTitle = ""This is title""; 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 readonly string example2RazorCode = @" + private readonly string example3RazorCode = @" Dismiss Icon Name @@ -309,12 +428,11 @@ 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 string? bodyTemplateAnswer; +private BitSnackBar bodyTemplateRef = default!; +private BitSnackBar titleTemplateRef = default!; +private BitSnackBar dismissIconNameRef = default!; private async Task OpenDismissIconName() { @@ -331,7 +449,7 @@ private async Task OpenBodyTemplate() await bodyTemplateRef.Error(""This is title"", ""This is body""); }"; - private readonly string example3RazorCode = @" + private readonly string example4RazorCode = @"