Closed timgremore closed 5 days ago
@carson-katri can you provide the SwiftUI hex syntax that we should support? Just looking in a few places and I see different numerical types:
https://mariusschulz.com/blog/numbers-and-numeric-types-in-swift#numeric-literals
let decimal = 42 // 42 = 4 * 10 + 2 * 1
let binary = 0b101010 // 42 = 1 * 32 + 1 * 8 + 1 * 2
let octal = 0o52 // 42 = 5 * 8 + 2 * 1
let hexadecimal = 0x2A // 42 = 2 * 16 + 10 * 1
and for hex itself I see what looks like more than one implementation. The typical 0xNNNN
but I also see what appears to be some hex arithmatic that is common to see, especially in the context of colors?
oh wait wait wait... I missed the original context here. So @timgremore wants to enable hex colors. Maybe we should just bake this into the client so it's on by default?
SwiftUI doesn't have built-in support for hex colors. Swift supports writing numbers in hex format, as well as binary and octal as you mentioned. But using these numbers for color values isn't something built-in to SwiftUI.
This is actually possible if you use an attribute reference. Colors can be loaded by system name, hex string, or asset catalog name.
<Rectangle
style='foregroundStyle(attr("color"))'
color="#FF0000"
/>
Supporting hex values in Swift requires an extension (example implementation).
Updates to the rules parser would be needed to recognize: