siege-media / contrast-ratio

A tool to calculate the contrast ratio between any two valid CSS colors.
https://www.siegemedia.com/contrast-ratio
MIT License
2.45k stars 221 forks source link

Addition of '#' for six digit hex codes #7

Closed sam-silv closed 9 years ago

sam-silv commented 10 years ago

When copying hex codes from Photoshop, Fireworks and other graphics packages (which is often more convenient than using rgb and the like), '#' usually isn't prepended. This adds a conditional that matches only those six digit hex codes and automatically adds the '#' for convenience sake.

mgifford commented 10 years ago

Looks like a nice, simple addition. +1

LeaVerou commented 10 years ago

Hi there,

Thanks! Are you sure there aren't any 6 character color names with letters a-f?

mgifford commented 10 years ago

Of this list of color names http://www.w3.org/TR/SVG/types.html#ColorKeywords

We ony need to consider the ones that start with a-f:

aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, & fuchsia

in those there is just one with 6 characters:

bisque

So we're good.

yatil commented 9 years ago

👍

santosh commented 9 years ago

This should be merged! :+1:

LeaVerou commented 9 years ago

Sure, sorry for the huge delay, I'm gonna merge it now. Can we also add (?!bisque) before the regex just to make sure?