bvaughn/planner

Planner should support color keywords, not just hex

rachelnabors opened this issue · 5 comments

Example

Assigning a CSS color keyword like black instead of #000000 to color throws error:

Screen Shot 2022-02-03 at 1 21 20 PM

Expected Behavior

  1. If color's value doesn't begin with a #, compare it to a dictionary of CSS colors.
  2. If not in the dictionary, either throw error or use "transparent" (your choice).
  3. If in the dictionary, use that keyword for the color.

Totally understand why this would be a nice convenience feature- but it’s a hard limitation currently because of how my color highlighting (on hover) and contrast (foreground vs background color determination) works. Both require converting between hex and rgb values. I’d like to avoid having to hardcode a long list of CSS color names. (I think there are well over 100 of them?)

It’s not about confirmation- but rather, how to covert a color name to an rgb value (so I can calculate contrast).

Oh, nice! That looks like it could work then as a fallback for non-hex colors.