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.34k stars 110 forks source link

Added a function that creates a color from a hexadecimal string. #229

Closed wcourtney31415 closed 4 years ago

wcourtney31415 commented 4 years ago

In response to issue #217 by Anton-4, I wrote a function specifically for creating an elm-ui color using a hexadecimal color code. The hex function returns a color given a valid string, but returns red if the input was invalid. The string is considered to be invalid if it doesn't start with a '#' sign, if it isn't 7 characters long including the '#', or if it includes characters that do not exist in hexadecimal format.

Anton-4 commented 4 years ago

@wcourtney31415 thanks for your contribution, however I did implement this already in pr #222. @mdgriffith can of course decide which implementation he likes best or combine them.

Anton-4 commented 4 years ago

I only linked to the issue with the commit, not with the PR so I can see how you could have missed it.

wcourtney31415 commented 4 years ago

After I submitted my code, I noticed yours and looked it over. Yours has tests and some additional functionality that mine doesn't. That in mind, I believe yours is more fully fledged than mine. I expect mine to be rejected, but i'm going to leave it open for now in case pieces of my algorithm may be of some use. Constructive criticism is much welcomed. This is one of my first pull requests, so there's still much for me to learn. Thanks!