-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lot's of improvements for MudBlazor components.
- Loading branch information
1 parent
1ba8335
commit 7300da2
Showing
12 changed files
with
213 additions
and
15 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/DotNetElements.Web.MudBlazor/AuditedModelDetailsRow.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@inherits MudComponentBase | ||
|
||
@typeparam TKey where TKey : notnull, IEquatable<TKey> | ||
@typeparam TModel where TModel : IModel<TKey> | ||
@typeparam TDetails where TDetails : AuditedModelDetails | ||
|
||
@if (Context.DetailsShown && Context.Details is not null) | ||
{ | ||
@if (SimpleTable) | ||
{ | ||
<tr> | ||
<td colspan="100"> | ||
<MudGrid Spacing="2"> | ||
<MudItem xs="12"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>ID</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Value.Id</MudText> | ||
</MudStack> | ||
</MudItem> | ||
<MudItem xs="4"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>Creation Time</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Details.CreationTime</MudText> | ||
</MudStack> | ||
</MudItem> | ||
<MudItem xs="4"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>Last Modification Time</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Details.LastModificationTime</MudText> | ||
</MudStack> | ||
</MudItem> | ||
</MudGrid> | ||
</td> | ||
</tr> | ||
} | ||
else | ||
{ | ||
<MudTr> | ||
<MudTd colspan="100" Style="border-bottom: 3px solid var(--mud-palette-table-lines);" DataLabel="Row Details"> | ||
<MudGrid Spacing="2"> | ||
<MudItem xs="12"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>ID</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Value.Id</MudText> | ||
</MudStack> | ||
</MudItem> | ||
<MudItem xs="4"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>Creation Time</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Details.CreationTime</MudText> | ||
</MudStack> | ||
</MudItem> | ||
<MudItem xs="4"> | ||
<MudStack Spacing="1"> | ||
<MudText Typo="Typo.caption"><b>Last Modification Time</b></MudText> | ||
<MudText Typo="Typo.caption">@Context.Details.LastModificationTime</MudText> | ||
</MudStack> | ||
</MudItem> | ||
</MudGrid> | ||
</MudTd> | ||
</MudTr> | ||
} | ||
} | ||
|
||
@code | ||
{ | ||
[Parameter, EditorRequired] | ||
public ModelWithDetails<TModel, TDetails> Context { get; set; } = default!; | ||
|
||
[Parameter] | ||
public bool SimpleTable { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/DotNetElements.Web.MudBlazor/CrudTableActionsCell.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@inherits MudComponentBase | ||
|
||
@typeparam TKey where TKey : notnull, IEquatable<TKey> | ||
@typeparam TModel where TModel : IModel<TKey> | ||
@typeparam TDetails where TDetails : ModelDetails | ||
|
||
@if (SimpleTable) | ||
{ | ||
<td class="py-0 pl-2" style="width: 140px;"> | ||
<MudIconButton OnClick="() => OnEditEntry.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Edit" Color="Color.Warning" /> | ||
<MudIconButton OnClick="() => OnDeleteEntry.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Delete" Color="Color.Error" /> | ||
<MudIconButton OnClick="() => OnShowEntryDetails.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Info" Color="Color.Default" /> | ||
</td> | ||
} | ||
else | ||
{ | ||
<MudTd Class="py-0 pl-2" Style="width: 140px;" DataLabel="Actions"> | ||
<MudIconButton OnClick="() => OnEditEntry.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Edit" Color="Color.Warning" /> | ||
<MudIconButton OnClick="() => OnDeleteEntry.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Delete" Color="Color.Error" /> | ||
<MudIconButton OnClick="() => OnShowEntryDetails.InvokeAsync(Context)" Class="pa-1" Icon="@Icons.Material.Outlined.Info" Color="Color.Default" /> | ||
</MudTd> | ||
} | ||
|
||
@code | ||
{ | ||
[Parameter, EditorRequired] | ||
public ModelWithDetails<TModel, TDetails> Context { get; set; } = default!; | ||
|
||
[Parameter, EditorRequired] | ||
public EventCallback<ModelWithDetails<TModel, TDetails>> OnEditEntry { get; set; } | ||
|
||
[Parameter, EditorRequired] | ||
public EventCallback<ModelWithDetails<TModel, TDetails>> OnDeleteEntry { get; set; } | ||
|
||
[Parameter, EditorRequired] | ||
public EventCallback<ModelWithDetails<TModel, TDetails>> OnShowEntryDetails { get; set; } | ||
|
||
[Parameter] | ||
public bool SimpleTable { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<tr> | ||
<td colspan="100"> | ||
<MudProgressLinear Indeterminate="true" Color="Color.Primary" /> | ||
</td> | ||
</tr> |
21 changes: 21 additions & 0 deletions
21
src/DotNetElements.Web.MudBlazor/CrudTableNewEntryButton.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@inherits MudButton | ||
|
||
@{ | ||
ChildContent = @<span>Create New</span>; | ||
} | ||
|
||
@{ | ||
base.BuildRenderTree(__builder); | ||
} | ||
|
||
@code | ||
{ | ||
public CrudTableNewEntryButton() | ||
{ | ||
StartIcon = Icons.Material.Outlined.Add; | ||
Color = Color.Success; | ||
Variant = Variant.Outlined; | ||
Size = Size.Small; | ||
Class = "ml-4"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/DotNetElements.Web.MudBlazor/CrudTableSearchField.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@inherits MudInput<string> | ||
|
||
@{ | ||
base.BuildRenderTree(__builder); | ||
} | ||
|
||
@code | ||
{ | ||
public CrudTableSearchField() | ||
{ | ||
Placeholder = "Search"; | ||
Clearable = true; | ||
Adornment = Adornment.Start; | ||
AdornmentIcon = Icons.Material.Filled.Search; | ||
IconSize = Size.Medium; | ||
Style = "width: 40%"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@using Microsoft.AspNetCore.Components.Sections | ||
|
||
<SectionContent SectionName="@SectionName"> | ||
<MudText Typo=Typo.h6>@Title</MudText> | ||
</SectionContent> | ||
|
||
@code | ||
{ | ||
[Parameter, EditorRequired] | ||
public string Title { get; set; } = default!; | ||
|
||
[Parameter] | ||
public string SectionName { get; set; } = "page-header"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@if (DarkModeActive) | ||
{ | ||
<MudIconButton Icon="@Icons.Material.Filled.LightMode" Color="Color.Inherit" OnClick="@this.OnToggleDarkMode" Title="To light mode" /> | ||
} | ||
else | ||
{ | ||
<MudIconButton Icon="@Icons.Material.Filled.DarkMode" Color="Color.Inherit" OnClick="@this.OnToggleDarkMode" Title="To dark mode" /> | ||
} | ||
|
||
@code | ||
{ | ||
[Parameter, EditorRequired] | ||
public bool DarkModeActive { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<bool> DarkModeActiveChanged { get; set; } | ||
|
||
private async Task OnToggleDarkMode() | ||
{ | ||
DarkModeActive = !DarkModeActive; | ||
|
||
if (DarkModeActiveChanged.HasDelegate) | ||
await DarkModeActiveChanged.InvokeAsync(DarkModeActive); | ||
} | ||
} |