meodai / color-names

Large list of handpicked color names 🌈
https://meodai.github.io/color-names/
MIT License
2.39k stars 180 forks source link

When passing in a hex code to get color name, the hex code needs to be in lower case. So it would be better to accept uppercase too #159

Closed gibtang closed 9 months ago

gibtang commented 1 year ago

Example, this works

let someColor = namedColors.find(color => color.hex === '#ffffff'); console.log(someColor.name); // => white

But

let someColor = namedColors.find(color => color.hex === '#FFFFFF'); console.log(someColor.name); //does not work

Following Postel's Law, it would be good to accept uppercase hexcodes too. I can file a PR for this if needed

meodai commented 1 year ago

hey @gibtang thanks for reporting that. This repository only contains the names, this is example code to help people implement it. I don't need it to be robust, just get the point across. But I guess adding a simple .toLowerCase() in the example does not hurt too much.