Improve the Dialog component
This commit is contained in:
parent
ad1552e343
commit
eda134c471
12 changed files with 311 additions and 264 deletions
31
Start/Client/Components/Shared/Alert.razor
Normal file
31
Start/Client/Components/Shared/Alert.razor
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<div class="toast @AlertTypeToClass(this.Type)" role="alert">
|
||||
@ChildContent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public AlertType Type { get; set; }
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } = null!;
|
||||
|
||||
private string AlertTypeToClass(AlertType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AlertType.Error: return "toast-error";
|
||||
case AlertType.Warning: return "toast-warning";
|
||||
case AlertType.Success: return "toast-success";
|
||||
case AlertType.Info: return "toast-primary";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
public enum AlertType
|
||||
{
|
||||
Error,
|
||||
Warning,
|
||||
Success,
|
||||
Info,
|
||||
None
|
||||
}
|
||||
}
|
||||
46
Start/Client/Components/Shared/Dialog.razor
Normal file
46
Start/Client/Components/Shared/Dialog.razor
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<div class="modal @(this.Active ? "active" : "")" role="dialog">
|
||||
<a class="modal-overlay" @onclick="this.OnDialogClose" aria-label="Close"></a>
|
||||
<div class="modal-container">
|
||||
<div class="modal-header">
|
||||
<a class="btn btn-clear float-right" @onclick="this.OnDialogClose" aria-label="Close"></a>
|
||||
<div class="modal-title h5">@this.Header</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="content">
|
||||
@this.Body
|
||||
</div>
|
||||
</div>
|
||||
@if (this.Footer != null)
|
||||
{
|
||||
<div class="modal-footer">
|
||||
@this.Footer
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment Header { get; set; } = null!;
|
||||
[Parameter]
|
||||
public RenderFragment Body { get; set; } = null!;
|
||||
[Parameter]
|
||||
public RenderFragment? Footer { get; set; } = null;
|
||||
|
||||
[Parameter]
|
||||
public bool Active { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback OnClose { get; set; }
|
||||
|
||||
public void OnDialogClose()
|
||||
{
|
||||
if (this.OnClose.HasDelegate)
|
||||
{
|
||||
this.OnClose.InvokeAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue