[frontend/mfm] Implement border fn node
This commit is contained in:
parent
90511c7b58
commit
326192148f
1 changed files with 15 additions and 1 deletions
|
@ -275,7 +275,7 @@ public static class MfmRenderer
|
|||
"scale" => MfmFnScale(args, document),
|
||||
"fg" => MfmFnFg(args, document),
|
||||
"bg" => MfmFnBg(args, document),
|
||||
"border" => throw new NotImplementedException($"{node.Name}"),
|
||||
"border" => MfmFnBorder(args, document),
|
||||
"ruby" => throw new NotImplementedException($"{node.Name}"),
|
||||
"unixtime" => throw new NotImplementedException($"{node.Name}"),
|
||||
_ => throw new NotImplementedException($"{node.Name}")
|
||||
|
@ -397,4 +397,18 @@ public static class MfmRenderer
|
|||
|
||||
return el;
|
||||
}
|
||||
|
||||
private static INode MfmFnBorder(Dictionary<string, string?> args, IDocument document)
|
||||
{
|
||||
var el = document.CreateElement("span");
|
||||
|
||||
var width = args.GetValueOrDefault("width") ?? "1";
|
||||
var radius = args.GetValueOrDefault("radius") ?? "0";
|
||||
var style = args.GetValueOrDefault("style") ?? "solid";
|
||||
var color = args.ContainsKey("color") ? "#" + args["color"] : "var(--notice-color)";
|
||||
|
||||
el.SetAttribute("style", $"display: inline-block; border: {width}px {style} {color}; border-radius: {radius}px;");
|
||||
|
||||
return el;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue