ant-design-blazor/components/core/Base/AntDomComponentBase.cs
zxyao 4f8eafa501
fix(module: notification): RTL incorrect style (#3049)
* fix: notification TRL not working

* feat: add top and bottom placement support

* fix: modal patch.less is lost when sync the css

* chore: code format

* fix: notification dom is flicker

---------

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2023-02-01 00:16:03 +08:00

89 lines
2.2 KiB
C#

using Microsoft.AspNetCore.Components;
namespace AntDesign
{
public abstract class AntDomComponentBase : AntComponentBase
{
[Inject]
private IComponentIdGenerator ComponentIdGenerator { get; set; }
[Parameter]
public string Id { get; set; }
[CascadingParameter]
public ConfigProvider ConfigProvider { get; set; }
protected bool RTL => ConfigProvider?.Direction == "RTL";
//[Parameter(CaptureUnmatchedValues = true)]
//public Dictionary<string, object> Attributes { get; set; } = new Dictionary<string, object>();
private ElementReference _ref;
/// <summary>
/// Returned ElementRef reference for DOM element.
/// </summary>
public virtual ElementReference Ref
{
get => _ref;
set
{
_ref = value;
RefBack?.Set(value);
}
}
protected ClassMapper ClassMapper { get; } = new ClassMapper();
protected AntDomComponentBase()
{
}
protected override void OnInitialized()
{
Id ??= ComponentIdGenerator.Generate(this);
base.OnInitialized();
}
/// <summary>
/// Specifies one or more class names for an DOM element.
/// </summary>
[Parameter]
public string Class
{
get => _class;
set
{
_class = value;
ClassMapper.OriginalClass = value;
}
}
/// <summary>
/// Specifies an inline style for a DOM element.
/// </summary>
[Parameter]
public string Style
{
get => _style;
set
{
_style = value;
if (!string.IsNullOrWhiteSpace(_style) && !_style.EndsWith(";"))
{
_style += ";";
}
//this.StateHasChanged();
}
}
protected virtual string GenerateStyle()
{
return Style;
}
private string _class;
private string _style;
}
}