|
1 | 1 | @page "/forms/advanced"
|
| 2 | +@using Blazor.AdminLte.Alerts.Toaster.Configuration |
| 3 | +@using Blazor.AdminLte.Alerts.Toaster.Services |
| 4 | +@inject NavigationManager NavigationManager |
| 5 | +@inject IToastService toastService |
| 6 | + |
2 | 7 | <ContentHeader>
|
3 | 8 | <Header>
|
4 | 9 | <Blazor.AdminLte.PageTitle Title="Advanced Forms" />
|
|
41 | 46 | </FormGroup>
|
42 | 47 | </Body>
|
43 | 48 | </Card>
|
| 49 | + <Card> |
| 50 | + <Title><CardTitle>Date Range Picker (MVP)</CardTitle></Title> |
| 51 | + <Body> |
| 52 | + <button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("I'm an INFO message"))">Info Toast</button> |
| 53 | + <button class="btn btn-success" @onclick="@(() => toastService.ShowSuccess("I'm a SUCCESS message with a custom heading", "Congratulations!"))">Success Toast</button> |
| 54 | + <button class="btn btn-warning" @onclick="@(() => toastService.ShowWarning("I'm a WARNING message"))">Warning Toast</button> |
| 55 | + <button class="btn btn-danger" @onclick="@(() => toastService.ShowError("I'm an ERROR message"))">Error Toast</button> |
| 56 | + <button class="btn btn-info" @onclick="@OnShowHtml">Info Toast with HTML</button> |
| 57 | +@* <button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("Click to refresh the page", "Click me!", () => { NavigationManager.NavigateTo("/", true); }))"> |
| 58 | + Info Toast with custom action on click |
| 59 | + </button> |
| 60 | +*@ <hr /> |
| 61 | + |
| 62 | + <h1>Blazored Toasts - Custom Component</h1> |
| 63 | + |
| 64 | + <button class="btn btn-primary" @onclick="@(() => toastService.ShowToast<MyToastComponent>(new ToastInstanceSettings(5, true)))">Custom Toast</button> |
| 65 | + <button class="btn btn-secondary" @onclick="@(() => toastService.ShowToast<MyToastComponent>(_toastParameters, new ToastInstanceSettings(5, true)))">Custom Toast with parameters</button> |
| 66 | + <hr /> |
| 67 | + |
| 68 | + <h1>Blazored Toasts - Remove Toasts</h1> |
| 69 | + |
| 70 | + <button class="btn btn-primary" @onclick="ClearAll">Clear All Toasts</button> |
| 71 | + <button class="btn btn-warning" @onclick="ClearWarnings">Clear Warning Toasts</button> |
| 72 | + <button class="btn btn-info" @onclick="ClearInfos">Clear Info Toasts</button> |
| 73 | + <button class="btn btn-secondary" @onclick="ClearCustom">Clear Custom Toasts</button> |
| 74 | + |
| 75 | + @code |
| 76 | + { |
| 77 | + private ToastParameters _toastParameters; |
| 78 | + |
| 79 | + protected override void OnInitialized() |
| 80 | + { |
| 81 | + _toastParameters = new ToastParameters(); |
| 82 | + _toastParameters.Add(nameof(MyToastComponent.Title), "I'm a custom toast component with parameters"); |
| 83 | + _toastParameters.Add(nameof(MyToastComponent.ToastParam), "I'm a parameter"); |
| 84 | + } |
| 85 | + |
| 86 | + private void OnShowHtml() |
| 87 | + { |
| 88 | + RenderFragment message =@<text>I'm an <em>INFO</em> message with some <strong>bold</strong> text</text> |
| 89 | + ; |
| 90 | + toastService.ShowToast(ToastLevel.Info, message); |
| 91 | + } |
| 92 | + |
| 93 | + private void ClearAll() |
| 94 | + => toastService.ClearAll(); |
| 95 | + |
| 96 | + private void ClearWarnings() |
| 97 | + => toastService.ClearToasts(ToastLevel.Warning); |
| 98 | + |
| 99 | + private void ClearInfos() |
| 100 | + => toastService.ClearInfoToasts(); |
| 101 | + |
| 102 | + private void ClearCustom() |
| 103 | + => toastService.ClearCustomToasts(); |
| 104 | + } |
| 105 | + </Body> |
| 106 | + </Card> |
44 | 107 | </ContentMain>
|
45 | 108 |
|
46 | 109 |
|
0 commit comments