I have an application where the user can type in a color name, say blue, once he/she has done that, a div will turn into that color.
The code is pretty simple at the moment:
<div class="colorBox" style="background-color: <%= color.name %>;">
</div>
Is it possible to check whether or not that particular color exists?
At the moment I can only think of one solution:
Loop through a list of color names, like this one, but isn’t there a more elegant way? E.g
CSS.exists("blue")
=> true
Also, I don’t want the user to enter a color hex.
The Color gem/Color::CSS is what you want: