Open bcardarella opened 1 month ago
I don't believe this is necessary, as the client automatically decodes to the correct type based on the modifier's arguments.
However, CSS does support this with slightly different syntax. From MDN:
/* Simple usage */
attr(data-count);
attr(title);
/* With type */
attr(src url);
attr(data-count number);
attr(data-width px);
/* With fallback */
attr(data-count number, 0);
attr(src url, "");
attr(data-width px, inherit);
attr(data-something, "default");
In this case the Color
modifier was not accepted text representations of a float. I tried:
foregroundStyle(Color(red: attr("red"), green: attr("green"), blue: attr("blue")))
with:
<Rectangle red="0.5" green="0.1" blue="0.7" />
with no luck until I changed to the more explicit float:
foregroundStyle(Color(red: 0.5, green: 0.1, blue: 0.7))
That's an issue with Color
not accepting attribute value numbers. It needs to have AttributeDecodable
added to its red
, green
, and blue
arguments, then make the Color
itself attribute decodable so it can pass the element through.
@carson-katri ah ok, out of curiosity is there a way to determine which other views within the client would require AttributeDecodable
or do we have to add as we go?
There's a list in the modifier generator. In this case, Color
is already attribute decodable, it just needs to extend that to its arguments
In class rules the attr values are string, we should allow for typecasting:
results in: