UNPKG

3.9 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var namedColorMap = {
6 aliceblue: 'f0f8ff',
7 antiquewhite: 'faebd7',
8 aqua: '00ffff',
9 aquamarine: '7fffd4',
10 azure: 'f0ffff',
11 beige: 'f5f5dc',
12 bisque: 'ffe4c4',
13 black: '000',
14 blanchedalmond: 'ffebcd',
15 blue: '0000ff',
16 blueviolet: '8a2be2',
17 brown: 'a52a2a',
18 burlywood: 'deb887',
19 cadetblue: '5f9ea0',
20 chartreuse: '7fff00',
21 chocolate: 'd2691e',
22 coral: 'ff7f50',
23 cornflowerblue: '6495ed',
24 cornsilk: 'fff8dc',
25 crimson: 'dc143c',
26 cyan: '00ffff',
27 darkblue: '00008b',
28 darkcyan: '008b8b',
29 darkgoldenrod: 'b8860b',
30 darkgray: 'a9a9a9',
31 darkgreen: '006400',
32 darkgrey: 'a9a9a9',
33 darkkhaki: 'bdb76b',
34 darkmagenta: '8b008b',
35 darkolivegreen: '556b2f',
36 darkorange: 'ff8c00',
37 darkorchid: '9932cc',
38 darkred: '8b0000',
39 darksalmon: 'e9967a',
40 darkseagreen: '8fbc8f',
41 darkslateblue: '483d8b',
42 darkslategray: '2f4f4f',
43 darkslategrey: '2f4f4f',
44 darkturquoise: '00ced1',
45 darkviolet: '9400d3',
46 deeppink: 'ff1493',
47 deepskyblue: '00bfff',
48 dimgray: '696969',
49 dimgrey: '696969',
50 dodgerblue: '1e90ff',
51 firebrick: 'b22222',
52 floralwhite: 'fffaf0',
53 forestgreen: '228b22',
54 fuchsia: 'ff00ff',
55 gainsboro: 'dcdcdc',
56 ghostwhite: 'f8f8ff',
57 gold: 'ffd700',
58 goldenrod: 'daa520',
59 gray: '808080',
60 green: '008000',
61 greenyellow: 'adff2f',
62 grey: '808080',
63 honeydew: 'f0fff0',
64 hotpink: 'ff69b4',
65 indianred: 'cd5c5c',
66 indigo: '4b0082',
67 ivory: 'fffff0',
68 khaki: 'f0e68c',
69 lavender: 'e6e6fa',
70 lavenderblush: 'fff0f5',
71 lawngreen: '7cfc00',
72 lemonchiffon: 'fffacd',
73 lightblue: 'add8e6',
74 lightcoral: 'f08080',
75 lightcyan: 'e0ffff',
76 lightgoldenrodyellow: 'fafad2',
77 lightgray: 'd3d3d3',
78 lightgreen: '90ee90',
79 lightgrey: 'd3d3d3',
80 lightpink: 'ffb6c1',
81 lightsalmon: 'ffa07a',
82 lightseagreen: '20b2aa',
83 lightskyblue: '87cefa',
84 lightslategray: '789',
85 lightslategrey: '789',
86 lightsteelblue: 'b0c4de',
87 lightyellow: 'ffffe0',
88 lime: '0f0',
89 limegreen: '32cd32',
90 linen: 'faf0e6',
91 magenta: 'f0f',
92 maroon: '800000',
93 mediumaquamarine: '66cdaa',
94 mediumblue: '0000cd',
95 mediumorchid: 'ba55d3',
96 mediumpurple: '9370db',
97 mediumseagreen: '3cb371',
98 mediumslateblue: '7b68ee',
99 mediumspringgreen: '00fa9a',
100 mediumturquoise: '48d1cc',
101 mediumvioletred: 'c71585',
102 midnightblue: '191970',
103 mintcream: 'f5fffa',
104 mistyrose: 'ffe4e1',
105 moccasin: 'ffe4b5',
106 navajowhite: 'ffdead',
107 navy: '000080',
108 oldlace: 'fdf5e6',
109 olive: '808000',
110 olivedrab: '6b8e23',
111 orange: 'ffa500',
112 orangered: 'ff4500',
113 orchid: 'da70d6',
114 palegoldenrod: 'eee8aa',
115 palegreen: '98fb98',
116 paleturquoise: 'afeeee',
117 palevioletred: 'db7093',
118 papayawhip: 'ffefd5',
119 peachpuff: 'ffdab9',
120 peru: 'cd853f',
121 pink: 'ffc0cb',
122 plum: 'dda0dd',
123 powderblue: 'b0e0e6',
124 purple: '800080',
125 rebeccapurple: '639',
126 red: 'f00',
127 rosybrown: 'bc8f8f',
128 royalblue: '4169e1',
129 saddlebrown: '8b4513',
130 salmon: 'fa8072',
131 sandybrown: 'f4a460',
132 seagreen: '2e8b57',
133 seashell: 'fff5ee',
134 sienna: 'a0522d',
135 silver: 'c0c0c0',
136 skyblue: '87ceeb',
137 slateblue: '6a5acd',
138 slategray: '708090',
139 slategrey: '708090',
140 snow: 'fffafa',
141 springgreen: '00ff7f',
142 steelblue: '4682b4',
143 tan: 'd2b48c',
144 teal: '008080',
145 thistle: 'd8bfd8',
146 tomato: 'ff6347',
147 turquoise: '40e0d0',
148 violet: 'ee82ee',
149 wheat: 'f5deb3',
150 white: 'fff',
151 whitesmoke: 'f5f5f5',
152 yellow: 'ff0',
153 yellowgreen: '9acd32'
154};
155
156/**
157 * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
158 * @private
159 */
160function nameToHex(color) {
161 if (typeof color !== 'string') return color;
162 var normalizedColorName = color.toLowerCase();
163 return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
164}
165var _default = exports["default"] = nameToHex;
166module.exports = exports.default;
\No newline at end of file