Open AsbjornOlling opened 4 years ago
Sorry for the slow reply.
The reason I didn't expose them was because there were some API decisions that needed to be made that didn't seem to have a clear answer. Specifically, a lot of uses would prefer to have a fromHex : String -> Color
instead of String -> Maybe Color
. I'll take another look at the other discussion thread, though.
FWIW, It doesn't seem crazy to me for the user to add a Maybe.withDefault to handle the Maybe Color
. They could even write their own wrapper function that uses their preferred fall back color.
Just figured I'd check in here. Is this likely to be merged in or should I just go ahead and create my own functions?
I went ahead implemented my own functions (basically an exact copy of those in this module).
Would still love to see this merged though.
Pinging @avh4
Hi,
If I could add my voice here, I agree that String -> Maybe Color
is totally reasonable as we expect some safety in Elm.
It would be awesome to have them merged, but for now, I will just copy the implementation in my own files :man_facepalming:
Hi there,
@avh4 what would be the API design concerns regarding the use cases that would prefer fromHex
to be String -> Color
instead of String -> Maybe Color
?
As far as I'm concerned I would appreciate that safety I get from the Maybe and that would be expected for me as other libraries handles a string to x conversion similarly with a Maybe. Some examples here:
I think there are two places those hex strings would most likely come from:
Would it be an option that avh4/elm-color
exposes the fromHex
function as String -> Maybe Color
and users who need it without the Maybe
can just wrap it in their own code like this according to their needs?
fromHexWithDefault : String -> Color
fromHexWithDefault = fromHex >> Maybe.withDefault Color.black
Please merge this, it would be a quality of life improvement (and I wouldn't have to fork it into my own repo.)
Hi all 👋
since this package seems to be stale, I created a library that shares the same API and thus could be used as a drop-in replacement, if anyone is interested!
It also exposes fromHex
, fromHexUnsafe
and many more functions to work with colors in elm.
📦 https://package.elm-lang.org/packages/escherlies/elm-color/latest/
Would love to hear some feedback! (Feel free to open an issue for that)
Peace ✌️
Hi @avh4 I also stumbled upon this and would find those functions useful, actually had to copy the code from your lib which is not ideal, thanks in advance! 🙏🏻
These can be useful, and are already implemented. Let's expose them.
I understand that the have been hidden before the release of 1.0.0, but I don't see any good reason to not expose them. In contrary, I think these functions will often be useful.
There are open issues where a handful of users are dissatisfied with this decision
20
The only code change is exposing these two functions, and adding
@docs
tags in the appropriate places.