Added a generic assistant component
This commit is contained in:
parent
57dd83975f
commit
f20a1f2ca3
17
I18N Commander/UI MAUI/Components/Assistant.razor
Normal file
17
I18N Commander/UI MAUI/Components/Assistant.razor
Normal file
@ -0,0 +1,17 @@
|
||||
<div class="offcanvas offcanvas-bottom" tabindex="-1" id="@this.Name" aria-labelledby="@this.Name-Header" style="@this.AssistantHeight">
|
||||
<div class="offcanvas-header">
|
||||
<h4 class="offcanvas-title d-flex align-items-center" id="@this.Name-Header">
|
||||
@if (this.IsIconAvailable)
|
||||
{
|
||||
<Icon Filename="@this.IconName" Size="35" Classes="me-2" AltText="@this.HeaderIconAltText"/>
|
||||
}
|
||||
@this.HeaderText
|
||||
</h4>
|
||||
<button class="btn btn-secondary" type="button" data-bs-toggle="offcanvas" data-bs-target="#@this.Name">
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
@this.ChildContent
|
||||
</div>
|
||||
</div>
|
32
I18N Commander/UI MAUI/Components/Assistant.razor.cs
Normal file
32
I18N Commander/UI MAUI/Components/Assistant.razor.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace UI_MAUI.Components;
|
||||
|
||||
public partial class Assistant : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public string HeaderText { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string Name { get; set; } = "Assistant";
|
||||
|
||||
[Parameter]
|
||||
public string IconName { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public Height BaseHeight { get; set; } = new(60, 40, 50);
|
||||
|
||||
public readonly record struct Height(int Phone, int Desktop, int Tablet);
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
private string AssistantHeight =>
|
||||
DeviceInfo.Idiom == DeviceIdiom.Phone ? $"--bs-offcanvas-height: {this.BaseHeight.Phone}vh;" :
|
||||
DeviceInfo.Idiom == DeviceIdiom.Tablet ? $"--bs-offcanvas-height: {this.BaseHeight.Tablet}vh;" :
|
||||
$"--bs-offcanvas-height: {this.BaseHeight.Desktop}vh;";
|
||||
|
||||
private string HeaderIconAltText => $"Icon: {this.HeaderText}";
|
||||
|
||||
private bool IsIconAvailable => !string.IsNullOrWhiteSpace(this.IconName);
|
||||
}
|
Loading…
Reference in New Issue
Block a user