Open Anton-4 opened 4 years ago
One trick you can do in elm:
Element.rgb255 0xEE 0xFF 0xEE
So you need to format it slightly differently, but it should work!
I should also add it to the docs.
Ah thank you, that is useful.
In my opinion it would still be beneficial to have a hex function that does not require you to split up the triplet. There are many online design tools that let you directly copy hex codes and it's nice to be able to paste them right in. It also makes it easier for people converting their frontend to elm-ui. It seems likely a large portion of new users would waste some time looking for a hex function.
True! I should definitely add a note in the docs, but pointing to a way to parse hex strings is a good idea as well 👍
I'll try to submit a PR this week.
Another possibility is creating an Int -> Color
function (either in elm-ui or your own codebase) that accepts the RGB triple directly. This is not parsing (so no Maybe
s) but it's much more comfortable to use when copypasting colors
@miniBill do you mean without spaces like 25500?
@miniBill I have not personally encountered colors being formatted like that, is this not quite rare?
No, you don't usually find colors written that way, and it would make it impractical if the input is dynamic, but for hardcoded colors it's ok, just do #d000de
-> 0xd000de
and it's ready to be used
Alright, it does make more sense with the hex formatting. I will add a function for this.
Hex triplets for colors are very common on the web, it would be useful to be able to construct colors from hex strings.
If allowed I would be happy to implement it myself.