[frontend/mfm] Implement fg and bg fn nodes

This commit is contained in:
pancakes 2024-11-10 19:15:39 +10:00 committed by Laura Hausmann
parent 5d6e1d841f
commit 90511c7b58
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -273,8 +273,8 @@ public static class MfmRenderer
"crop" => MfmFnCrop(args, document), "crop" => MfmFnCrop(args, document),
"position" => MfmFnPosition(args, document), "position" => MfmFnPosition(args, document),
"scale" => MfmFnScale(args, document), "scale" => MfmFnScale(args, document),
"fg" => throw new NotImplementedException($"{node.Name}"), "fg" => MfmFnFg(args, document),
"bg" => throw new NotImplementedException($"{node.Name}"), "bg" => MfmFnBg(args, document),
"border" => throw new NotImplementedException($"{node.Name}"), "border" => throw new NotImplementedException($"{node.Name}"),
"ruby" => throw new NotImplementedException($"{node.Name}"), "ruby" => throw new NotImplementedException($"{node.Name}"),
"unixtime" => throw new NotImplementedException($"{node.Name}"), "unixtime" => throw new NotImplementedException($"{node.Name}"),
@ -377,4 +377,24 @@ public static class MfmRenderer
return el; return el;
} }
private static INode MfmFnFg(Dictionary<string, string?> args, IDocument document)
{
var el = document.CreateElement("span");
if (args.TryGetValue("color", out var color))
el.SetAttribute("style", $"color: #{color};");
return el;
}
private static INode MfmFnBg(Dictionary<string, string?> args, IDocument document)
{
var el = document.CreateElement("span");
if (args.TryGetValue("color", out var color))
el.SetAttribute("style", $"background-color: #{color};");
return el;
}
} }