2019-12-17 14:39:23 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-05-16 23:27:40 +08:00
|
|
|
|
using OneOf;
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2019-12-17 14:39:23 +08:00
|
|
|
|
{
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public partial class Card : AntDomComponentBase
|
2019-12-17 14:39:23 +08:00
|
|
|
|
{
|
2019-12-17 17:53:25 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
|
|
2019-12-17 14:39:23 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment Body { get; set; }
|
|
|
|
|
|
2021-01-23 01:18:05 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment ActionTemplate { get; set; }
|
|
|
|
|
|
2019-12-17 14:39:23 +08:00
|
|
|
|
[Parameter]
|
2020-09-20 10:43:40 +08:00
|
|
|
|
public bool Bordered { get; set; } = true;
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Hoverable { get; set; } = false;
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Loading { get; set; } = false;
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string BodyStyle { get; set; }
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment Cover { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public IList<RenderFragment> Actions { get; set; } = new List<RenderFragment>();
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Type { get; set; }
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Size { get; set; }
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-09-16 13:58:16 +08:00
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment TitleTemplate { get; set; }
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment Extra { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-09-20 10:43:40 +08:00
|
|
|
|
public RenderFragment CardTabs { get; set; }
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
2020-09-20 10:43:40 +08:00
|
|
|
|
private bool _hasGrids;
|
2021-01-23 01:18:05 +08:00
|
|
|
|
internal IList<CardAction> _cardActions;
|
2019-12-17 14:39:23 +08:00
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
protected void SetClassMap()
|
2019-12-17 14:39:23 +08:00
|
|
|
|
{
|
2020-09-20 10:43:40 +08:00
|
|
|
|
this.ClassMapper
|
2019-12-17 14:39:23 +08:00
|
|
|
|
.Add("ant-card")
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.If("ant-card-loading", () => Loading)
|
|
|
|
|
.If("ant-card-bordered", () => Bordered)
|
|
|
|
|
.If("ant-card-hoverable", () => Hoverable)
|
|
|
|
|
.If("ant-card-small", () => Size == "small")
|
2020-09-20 10:43:40 +08:00
|
|
|
|
.If("ant-card-contain-grid", () => _hasGrids)
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.If("ant-card-type-inner", () => Type == "inner")
|
2020-09-20 10:43:40 +08:00
|
|
|
|
.If("ant-card-contain-tabs", () => CardTabs != null)
|
2019-12-17 14:39:23 +08:00
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
base.OnInitialized();
|
2020-04-23 17:13:56 +08:00
|
|
|
|
SetClassMap();
|
2019-12-17 14:39:23 +08:00
|
|
|
|
}
|
2020-09-20 10:43:40 +08:00
|
|
|
|
|
|
|
|
|
internal void MarkHasGrid()
|
|
|
|
|
{
|
|
|
|
|
_hasGrids = true;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetBody(RenderFragment body)
|
|
|
|
|
{
|
|
|
|
|
this.Body = body;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
2021-01-23 01:18:05 +08:00
|
|
|
|
|
|
|
|
|
internal void AddCardAction(CardAction action)
|
|
|
|
|
{
|
|
|
|
|
_cardActions ??= new List<CardAction>();
|
|
|
|
|
_cardActions.Add(action);
|
|
|
|
|
}
|
2019-12-17 14:39:23 +08:00
|
|
|
|
}
|
2020-04-23 17:13:56 +08:00
|
|
|
|
}
|