2020-08-11 17:30:14 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components.Rendering;
|
|
|
|
|
|
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 Paragraph : TypographyBase
|
2020-03-10 13:29:03 +08:00
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Code { get; set; } = false;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
|
2020-09-04 11:24:50 +08:00
|
|
|
|
[Parameter]
|
|
|
|
|
public bool Keyboard { get; set; } = false;
|
|
|
|
|
|
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 13:00:54 +08:00
|
|
|
|
{
|
2020-04-24 18:32:50 +08:00
|
|
|
|
base.BuildRenderTree(builder);
|
2021-01-21 17:20:10 +08:00
|
|
|
|
builder.OpenElement(1, "div");
|
|
|
|
|
builder.AddAttribute(2, "class", this.ClassMapper.Class);
|
|
|
|
|
builder.AddAttribute(3, "style", Style);
|
|
|
|
|
builder.OpenElement(4, "span");
|
|
|
|
|
if (Mark) builder.OpenElement(5, "mark");
|
|
|
|
|
if (Delete) builder.OpenElement(6, "del");
|
|
|
|
|
if (Underline) builder.OpenElement(7, "u");
|
|
|
|
|
if (Code) builder.OpenElement(8, "code");
|
|
|
|
|
if (Keyboard) builder.OpenElement(9, "kbd");
|
|
|
|
|
if (Strong) builder.OpenElement(10, "strong");
|
|
|
|
|
builder.AddContent(11, 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();
|
|
|
|
|
builder.CloseElement();
|
|
|
|
|
if (Copyable)
|
|
|
|
|
{
|
2021-01-21 17:20:10 +08:00
|
|
|
|
builder.OpenElement(12, "a");
|
|
|
|
|
builder.AddAttribute(13, "onclick", (Action)(async () => await Copy()));
|
|
|
|
|
builder.OpenComponent<Icon>(14);
|
|
|
|
|
builder.AddAttribute(15, "type", "copy");
|
|
|
|
|
builder.AddAttribute(16, "theme", IconThemeType.Outline);
|
2020-04-24 18:32:50 +08:00
|
|
|
|
builder.CloseComponent();
|
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
2021-01-21 17:20:10 +08:00
|
|
|
|
builder.AddElementReferenceCapture(17, r => Ref = r);
|
2020-03-12 13:00:54 +08:00
|
|
|
|
builder.CloseElement();
|
|
|
|
|
}
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|