2020-08-11 17:30:14 +08:00
|
|
|
|
using System;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2020-08-11 17:30:14 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Rendering;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-03-10 13:29:03 +08:00
|
|
|
|
{
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public class Text : TypographyBase
|
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
|
|
|
|
|
2020-09-04 11:24:50 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public bool Keyboard { 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)
|
|
|
|
|
{
|
2020-04-24 18:32:50 +08:00
|
|
|
|
if (builder != null)
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
2020-04-24 18:32:50 +08:00
|
|
|
|
base.BuildRenderTree(builder);
|
|
|
|
|
// According to Ant-Design 4.0, Fallback to 1 if level is invalid.
|
2020-08-11 17:30:14 +08:00
|
|
|
|
int i = 0;
|
2020-04-24 18:32:50 +08:00
|
|
|
|
|
2020-08-11 17:30:14 +08:00
|
|
|
|
builder.OpenElement(i++, "span");
|
|
|
|
|
builder.AddAttribute(i++, "class", this.ClassMapper.Class);
|
|
|
|
|
builder.AddAttribute(i++, "style", Style);
|
|
|
|
|
if (Mark) builder.OpenElement(i++, "mark");
|
|
|
|
|
if (Delete) builder.OpenElement(i++, "del");
|
|
|
|
|
if (Underline) builder.OpenElement(i++, "u");
|
|
|
|
|
if (Code) builder.OpenElement(i++, "code");
|
2020-09-04 11:24:50 +08:00
|
|
|
|
if (Keyboard) builder.OpenElement(i++, "kbd");
|
2020-08-11 17:30:14 +08:00
|
|
|
|
if (Strong) builder.OpenElement(i++, "strong");
|
|
|
|
|
builder.AddContent(i++, ChildContent);
|
2020-04-24 18:32:50 +08:00
|
|
|
|
if (Strong) builder.CloseElement();
|
|
|
|
|
if (Code) builder.CloseElement();
|
2020-09-04 11:24:50 +08:00
|
|
|
|
if (Keyboard) builder.CloseElement();
|
2020-04-24 18:32:50 +08:00
|
|
|
|
if (Underline) builder.CloseElement();
|
|
|
|
|
if (Delete) builder.CloseElement();
|
|
|
|
|
if (Mark) builder.CloseElement();
|
|
|
|
|
if (Copyable)
|
|
|
|
|
{
|
2020-08-11 17:30:14 +08:00
|
|
|
|
builder.OpenElement(i++, "a");
|
|
|
|
|
builder.AddAttribute(i++, "onclick", (Action)(async () => await Copy()));
|
|
|
|
|
builder.OpenComponent<Icon>(i++);
|
|
|
|
|
builder.AddAttribute(i++, "Type", "copy");
|
|
|
|
|
builder.AddAttribute(i++, "Theme", IconThemeType.Outline);
|
2020-04-24 18:32:50 +08:00
|
|
|
|
builder.CloseComponent();
|
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-12 16:35:23 +08:00
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|