2020-03-10 13:29:03 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Rendering;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace AntBlazor
|
|
|
|
|
{
|
2020-03-10 22:09:44 +08:00
|
|
|
|
public class AntText : AntTypographyBase
|
2020-03-10 13:29:03 +08:00
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Code { get; set; }
|
2020-03-10 13:29:03 +08:00
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
base.OnInitialized();
|
|
|
|
|
SetClassMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SetClassMap()
|
|
|
|
|
{
|
|
|
|
|
string prefixName = "ant-typography";
|
|
|
|
|
ClassMapper.Clear()
|
|
|
|
|
.Add("ant-typography")
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.If($"{prefixName}-{Type}", () => !string.IsNullOrEmpty(Type))
|
|
|
|
|
.If($"{prefixName}-disabled", () => Disabled);
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 22:09:44 +08:00
|
|
|
|
protected override void OnParametersSet()
|
|
|
|
|
{
|
|
|
|
|
base.OnParametersSet();
|
|
|
|
|
SetClassMap();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
protected override void BuildRenderTree(RenderTreeBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
base.BuildRenderTree(builder);
|
|
|
|
|
// According to Ant-Design 4.0, Fallback to 1 if level is invalid.
|
|
|
|
|
|
|
|
|
|
builder.OpenElement(0, "span");
|
|
|
|
|
builder.AddAttribute(1, "class", this.ClassMapper.Class);
|
2020-04-23 17:13:56 +08:00
|
|
|
|
if (Mark) builder.OpenElement(2, "mark");
|
|
|
|
|
if (Delete) builder.OpenElement(3, "del");
|
|
|
|
|
if (Underline) builder.OpenElement(4, "u");
|
|
|
|
|
if (Code) builder.OpenElement(5, "code");
|
|
|
|
|
if (Strong) builder.OpenElement(6, "strong");
|
2020-03-10 13:29:03 +08:00
|
|
|
|
builder.AddContent(6, ChildContent);
|
2020-04-23 17:13:56 +08:00
|
|
|
|
if (Strong) builder.CloseElement();
|
|
|
|
|
if (Code) builder.CloseElement();
|
|
|
|
|
if (Underline) builder.CloseElement();
|
|
|
|
|
if (Delete) builder.CloseElement();
|
|
|
|
|
if (Mark) builder.CloseElement();
|
|
|
|
|
if (Copyable)
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
|
|
|
|
builder.OpenElement(7, "a");
|
|
|
|
|
builder.AddAttribute(8, "onclick", (Action)(async () => await Copy()));
|
|
|
|
|
builder.OpenComponent<AntIcon>(9);
|
|
|
|
|
builder.AddAttribute(10, "type", "copy");
|
|
|
|
|
builder.AddAttribute(11, "theme", AntIconThemeType.Outline);
|
|
|
|
|
builder.CloseComponent();
|
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
2020-03-10 13:29:03 +08:00
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|