From 326192148fc9eaeca796cd2c2072c7da5eee2fd0 Mon Sep 17 00:00:00 2001 From: pancakes Date: Sun, 10 Nov 2024 21:14:28 +1000 Subject: [PATCH] [frontend/mfm] Implement border fn node --- .../Core/Miscellaneous/RenderMfm.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs index 3e276174..c250376e 100644 --- a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs +++ b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs @@ -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 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; + } } \ No newline at end of file