Added a generic assistant component

This commit is contained in:
Thorsten Sommer 2022-08-12 23:56:30 +02:00
parent 57dd83975f
commit f20a1f2ca3
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 49 additions and 0 deletions

View 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>

View 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);
}