ant-design-blazor/components/core/Base/AntDomComponentBase.cs

77 lines
1.8 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Components;
2019-12-08 00:51:07 +08:00
namespace AntBlazor
{
public abstract class AntDomComponentBase : AntComponentBase
{
[Parameter]
public string Id { get; set; } = IdGeneratorHelper.Generate("ant-blazor-");
2019-12-08 00:51:07 +08:00
//[Parameter(CaptureUnmatchedValues = true)]
//public Dictionary<string, object> Attributes { get; set; } = new Dictionary<string, object>();
2019-12-08 00:51:07 +08:00
private ElementReference _ref;
/// <summary>
/// Returned ElementRef reference for DOM element.
/// </summary>
public virtual ElementReference Ref
{
get => _ref;
set
{
_ref = value;
RefBack?.Set(value);
}
}
[CascadingParameter]
2019-12-11 00:23:10 +08:00
public AntTheme AntTheme { get; set; }
2019-12-08 00:51:07 +08:00
protected ClassMapper ClassMapper { get; } = new ClassMapper();
protected AntDomComponentBase()
{
ClassMapper
.Get(() => this.Class)
2019-12-11 00:23:10 +08:00
.Get(() => this.AntTheme?.GetClass());
2019-12-08 00:51:07 +08:00
}
/// <summary>
/// Specifies one or more class names for an DOM element.
2019-12-08 00:51:07 +08:00
/// </summary>
[Parameter]
public string Class
2019-12-08 00:51:07 +08:00
{
get => _class;
2019-12-20 00:20:53 +08:00
set
{
_class = value;
ClassMapper.OriginalClass = value;
}
2019-12-08 00:51:07 +08:00
}
/// <summary>
/// Specifies an inline style for an DOM element.
/// </summary>
[Parameter]
public string Style
{
get => _style;
set
{
_style = value;
this.StateHasChanged();
}
}
protected virtual string GenerateStyle()
{
return Style;
}
private string _class;
private string _style;
}
}