ant-design-blazor/components/page-header/PageHeader.razor.cs
Key Roche 903008ef64
refactor: Mark redundant paramters as obsolete for future removal (#3035)
Co-authored-by: James Yeung <shunjiey@hotmail.com>
2023-01-31 16:26:12 +08:00

98 lines
2.5 KiB
C#

using System;
using AntDesign.JsInterop;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using OneOf;
namespace AntDesign
{
public partial class PageHeader
{
[Parameter]
public bool Ghost { get; set; }
[Parameter]
public OneOf<bool?, string> BackIcon { get; set; }
[Parameter]
public RenderFragment BackIconTemplate { get; set; }
[Parameter]
public string Title { get; set; }
[Parameter]
public RenderFragment TitleTemplate { get; set; }
[Parameter]
public string Subtitle { get; set; }
[Parameter]
public RenderFragment SubtitleTemplate { get; set; }
[Parameter]
public EventCallback OnBack { get; set; }
[Parameter]
public RenderFragment PageHeaderContent { get; set; }
[Parameter]
public RenderFragment PageHeaderFooter { get; set; }
[Parameter]
public RenderFragment PageHeaderBreadcrumb { get; set; }
[Parameter]
public RenderFragment PageHeaderAvatar { get; set; }
[Obsolete("Use TitleTemplate instead")]
[Parameter]
public RenderFragment PageHeaderTitle { get; set; }
[Obsolete("Use SubtitleTemplate instead")]
[Parameter]
public RenderFragment PageHeaderSubtitle { get; set; }
[Parameter]
public RenderFragment PageHeaderTags { get; set; }
[Parameter]
public RenderFragment PageHeaderExtra { get; set; }
private bool _isCompact = false;
private void SetClassMap()
{
ClassMapper
.Add("ant-page-header")
.If("ant-page-header-compact", () => _isCompact)
.If("has-footer", () => PageHeaderFooter != null)
.If("ant-page-header-ghost", () => this.Ghost)
.If("has-breadcrumb", () => PageHeaderBreadcrumb != null)
.If("ant-page-header-rtl", () => RTL);
}
protected override void OnInitialized()
{
base.OnInitialized();
SetClassMap();
}
private void OnResize(DomRect domRect)
{
_isCompact = domRect.Width < 768;
}
private async void OnBackClick(MouseEventArgs eventArgs)
{
if (OnBack.HasDelegate)
{
await OnBack.InvokeAsync(eventArgs);
}
else
{
await JsInvokeAsync("history.back");
}
}
}
}