mdgriffith / elm-ui

What if you never had to write CSS again?
https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/
BSD 3-Clause "New" or "Revised" License
1.35k stars 111 forks source link

Use new Color type #28

Open kuon opened 6 years ago

kuon commented 6 years ago

To help with consistency, we created a new color package.

https://package.elm-lang.org/packages/avh4/elm-color/latest/Color

Elm-UI is a good candidate to use that new package.

There are two solutions:

  1. Use the new Color type and the remove custom Color type from elm-ui.
  2. Keep the elm-ui own Color type and create constructors that accept the new Color type.

I know 2. is needed to help elm-ui optimize (by keeping css string maybe) but I think the drawback of having multiple color type is too high and that 1. should be preferred.

RalfNorthman commented 6 years ago

Yes, I just got a surprise when I was about to List.map an elm-color palette to a function that creates elm-ui elements and the Color types didn't match. I guess I'll use typed-svg instead for this particular example, but it would be nice to be able to do it in the future.

How would such a constructor look? Is it something that is easy to do and be used ad-hoc in the meantime?

AlienKevin commented 4 years ago

A temporary workaround for those who want to convert avh4/elm-color to elm-ui color:

toElmUiColor : Color.Color -> Element.Color
toElmUiColor color =
    Element.fromRgb <| Color.toRgba color

To convert from elm-ui color to avh4/elm-color:

toElmColor : Element.Color -> Color.Color
toElmColor color =
    Color.fromRgba <| Element.toRgb color
klemola commented 4 years ago

It would be great if elm-ui used elm-color indeed. I'm trying to use it in an app that also uses elm-collage, which has a peer depedency for elm-color .