@charcoal-ui/theme 2.0.0-rc.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ var polished = require('polished');
1
2
  var foundation = require('@charcoal-ui/foundation');
2
3
  var utils = require('@charcoal-ui/utils');
3
4
 
@@ -19,698 +20,14 @@ function _extends() {
19
20
  return _extends.apply(this, arguments);
20
21
  }
21
22
 
22
- function _assertThisInitialized(self) {
23
- if (self === void 0) {
24
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
25
- }
26
-
27
- return self;
28
- }
29
-
30
- function _setPrototypeOf(o, p) {
31
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
32
- o.__proto__ = p;
33
- return o;
34
- };
35
-
36
- return _setPrototypeOf(o, p);
37
- }
38
-
39
- function _inheritsLoose(subClass, superClass) {
40
- subClass.prototype = Object.create(superClass.prototype);
41
- subClass.prototype.constructor = subClass;
42
- _setPrototypeOf(subClass, superClass);
43
- }
44
-
45
- function _getPrototypeOf(o) {
46
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
47
- return o.__proto__ || Object.getPrototypeOf(o);
48
- };
49
- return _getPrototypeOf(o);
50
- }
51
-
52
- function _isNativeFunction(fn) {
53
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
54
- }
55
-
56
- function _isNativeReflectConstruct() {
57
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
58
- if (Reflect.construct.sham) return false;
59
- if (typeof Proxy === "function") return true;
60
-
61
- try {
62
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
63
- return true;
64
- } catch (e) {
65
- return false;
66
- }
67
- }
68
-
69
- function _construct(Parent, args, Class) {
70
- if (_isNativeReflectConstruct()) {
71
- _construct = Reflect.construct;
72
- } else {
73
- _construct = function _construct(Parent, args, Class) {
74
- var a = [null];
75
- a.push.apply(a, args);
76
- var Constructor = Function.bind.apply(Parent, a);
77
- var instance = new Constructor();
78
- if (Class) _setPrototypeOf(instance, Class.prototype);
79
- return instance;
80
- };
81
- }
82
-
83
- return _construct.apply(null, arguments);
84
- }
85
-
86
- function _wrapNativeSuper(Class) {
87
- var _cache = typeof Map === "function" ? new Map() : undefined;
88
-
89
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
90
- if (Class === null || !_isNativeFunction(Class)) return Class;
91
-
92
- if (typeof Class !== "function") {
93
- throw new TypeError("Super expression must either be null or a function");
94
- }
95
-
96
- if (typeof _cache !== "undefined") {
97
- if (_cache.has(Class)) return _cache.get(Class);
98
-
99
- _cache.set(Class, Wrapper);
100
- }
101
-
102
- function Wrapper() {
103
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
104
- }
105
-
106
- Wrapper.prototype = Object.create(Class.prototype, {
107
- constructor: {
108
- value: Wrapper,
109
- enumerable: false,
110
- writable: true,
111
- configurable: true
112
- }
113
- });
114
- return _setPrototypeOf(Wrapper, Class);
115
- };
116
-
117
- return _wrapNativeSuper(Class);
118
- }
119
-
120
- /**
121
- * Parse errors.md and turn it into a simple hash of code: message
122
- * @private
123
- */
124
-
125
- var ERRORS = {
126
- "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
127
- "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
128
- "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
129
- "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
130
- "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
131
- "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
132
- "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
133
- "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
134
- "9": "Please provide a number of steps to the modularScale helper.\n\n",
135
- "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
136
- "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
137
- "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
138
- "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
139
- "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
140
- "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
141
- "16": "You must provide a template to this method.\n\n",
142
- "17": "You passed an unsupported selector state to this method.\n\n",
143
- "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
144
- "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
145
- "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
146
- "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
147
- "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
148
- "23": "fontFace expects a name of a font-family.\n\n",
149
- "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
150
- "25": "fontFace expects localFonts to be an array.\n\n",
151
- "26": "fontFace expects fileFormats to be an array.\n\n",
152
- "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
153
- "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
154
- "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
155
- "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
156
- "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
157
- "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
158
- "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
159
- "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
160
- "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
161
- "36": "Property must be a string value.\n\n",
162
- "37": "Syntax Error at %s.\n\n",
163
- "38": "Formula contains a function that needs parentheses at %s.\n\n",
164
- "39": "Formula is missing closing parenthesis at %s.\n\n",
165
- "40": "Formula has too many closing parentheses at %s.\n\n",
166
- "41": "All values in a formula must have the same unit or be unitless.\n\n",
167
- "42": "Please provide a number of steps to the modularScale helper.\n\n",
168
- "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
169
- "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
170
- "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
171
- "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
172
- "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
173
- "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
174
- "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
175
- "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
176
- "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
177
- "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
178
- "53": "fontFace expects localFonts to be an array.\n\n",
179
- "54": "fontFace expects fileFormats to be an array.\n\n",
180
- "55": "fontFace expects a name of a font-family.\n\n",
181
- "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
182
- "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
183
- "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
184
- "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
185
- "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
186
- "61": "Property must be a string value.\n\n",
187
- "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
188
- "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
189
- "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
190
- "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
191
- "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
192
- "67": "You must provide a template to this method.\n\n",
193
- "68": "You passed an unsupported selector state to this method.\n\n",
194
- "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
195
- "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
196
- "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
197
- "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
198
- "73": "Please provide a valid CSS variable.\n\n",
199
- "74": "CSS variable not found and no default was provided.\n\n",
200
- "75": "important requires a valid style object, got a %s instead.\n\n",
201
- "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
202
- "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
203
- "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
204
- };
205
- /**
206
- * super basic version of sprintf
207
- * @private
208
- */
209
-
210
- function format() {
211
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
212
- args[_key] = arguments[_key];
213
- }
214
-
215
- var a = args[0];
216
- var b = [];
217
- var c;
218
-
219
- for (c = 1; c < args.length; c += 1) {
220
- b.push(args[c]);
221
- }
222
-
223
- b.forEach(function (d) {
224
- a = a.replace(/%[a-z]/, d);
225
- });
226
- return a;
227
- }
228
- /**
229
- * Create an error file out of errors.md for development and a simple web link to the full errors
230
- * in production mode.
231
- * @private
232
- */
233
-
234
-
235
- var PolishedError = /*#__PURE__*/function (_Error) {
236
- _inheritsLoose(PolishedError, _Error);
237
-
238
- function PolishedError(code) {
239
- var _this;
240
-
241
- if (process.env.NODE_ENV === 'production') {
242
- _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
243
- } else {
244
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
245
- args[_key2 - 1] = arguments[_key2];
246
- }
247
-
248
- _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
249
- }
250
-
251
- return _assertThisInitialized(_this);
252
- }
253
-
254
- return PolishedError;
255
- }( /*#__PURE__*/_wrapNativeSuper(Error));
256
-
257
- function colorToInt(color) {
258
- return Math.round(color * 255);
259
- }
260
-
261
- function convertToInt(red, green, blue) {
262
- return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
263
- }
264
-
265
- function hslToRgb(hue, saturation, lightness, convert) {
266
- if (convert === void 0) {
267
- convert = convertToInt;
268
- }
269
-
270
- if (saturation === 0) {
271
- // achromatic
272
- return convert(lightness, lightness, lightness);
273
- } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
274
-
275
-
276
- var huePrime = (hue % 360 + 360) % 360 / 60;
277
- var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
278
- var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
279
- var red = 0;
280
- var green = 0;
281
- var blue = 0;
282
-
283
- if (huePrime >= 0 && huePrime < 1) {
284
- red = chroma;
285
- green = secondComponent;
286
- } else if (huePrime >= 1 && huePrime < 2) {
287
- red = secondComponent;
288
- green = chroma;
289
- } else if (huePrime >= 2 && huePrime < 3) {
290
- green = chroma;
291
- blue = secondComponent;
292
- } else if (huePrime >= 3 && huePrime < 4) {
293
- green = secondComponent;
294
- blue = chroma;
295
- } else if (huePrime >= 4 && huePrime < 5) {
296
- red = secondComponent;
297
- blue = chroma;
298
- } else if (huePrime >= 5 && huePrime < 6) {
299
- red = chroma;
300
- blue = secondComponent;
301
- }
302
-
303
- var lightnessModification = lightness - chroma / 2;
304
- var finalRed = red + lightnessModification;
305
- var finalGreen = green + lightnessModification;
306
- var finalBlue = blue + lightnessModification;
307
- return convert(finalRed, finalGreen, finalBlue);
308
- }
309
-
310
- var namedColorMap = {
311
- aliceblue: 'f0f8ff',
312
- antiquewhite: 'faebd7',
313
- aqua: '00ffff',
314
- aquamarine: '7fffd4',
315
- azure: 'f0ffff',
316
- beige: 'f5f5dc',
317
- bisque: 'ffe4c4',
318
- black: '000',
319
- blanchedalmond: 'ffebcd',
320
- blue: '0000ff',
321
- blueviolet: '8a2be2',
322
- brown: 'a52a2a',
323
- burlywood: 'deb887',
324
- cadetblue: '5f9ea0',
325
- chartreuse: '7fff00',
326
- chocolate: 'd2691e',
327
- coral: 'ff7f50',
328
- cornflowerblue: '6495ed',
329
- cornsilk: 'fff8dc',
330
- crimson: 'dc143c',
331
- cyan: '00ffff',
332
- darkblue: '00008b',
333
- darkcyan: '008b8b',
334
- darkgoldenrod: 'b8860b',
335
- darkgray: 'a9a9a9',
336
- darkgreen: '006400',
337
- darkgrey: 'a9a9a9',
338
- darkkhaki: 'bdb76b',
339
- darkmagenta: '8b008b',
340
- darkolivegreen: '556b2f',
341
- darkorange: 'ff8c00',
342
- darkorchid: '9932cc',
343
- darkred: '8b0000',
344
- darksalmon: 'e9967a',
345
- darkseagreen: '8fbc8f',
346
- darkslateblue: '483d8b',
347
- darkslategray: '2f4f4f',
348
- darkslategrey: '2f4f4f',
349
- darkturquoise: '00ced1',
350
- darkviolet: '9400d3',
351
- deeppink: 'ff1493',
352
- deepskyblue: '00bfff',
353
- dimgray: '696969',
354
- dimgrey: '696969',
355
- dodgerblue: '1e90ff',
356
- firebrick: 'b22222',
357
- floralwhite: 'fffaf0',
358
- forestgreen: '228b22',
359
- fuchsia: 'ff00ff',
360
- gainsboro: 'dcdcdc',
361
- ghostwhite: 'f8f8ff',
362
- gold: 'ffd700',
363
- goldenrod: 'daa520',
364
- gray: '808080',
365
- green: '008000',
366
- greenyellow: 'adff2f',
367
- grey: '808080',
368
- honeydew: 'f0fff0',
369
- hotpink: 'ff69b4',
370
- indianred: 'cd5c5c',
371
- indigo: '4b0082',
372
- ivory: 'fffff0',
373
- khaki: 'f0e68c',
374
- lavender: 'e6e6fa',
375
- lavenderblush: 'fff0f5',
376
- lawngreen: '7cfc00',
377
- lemonchiffon: 'fffacd',
378
- lightblue: 'add8e6',
379
- lightcoral: 'f08080',
380
- lightcyan: 'e0ffff',
381
- lightgoldenrodyellow: 'fafad2',
382
- lightgray: 'd3d3d3',
383
- lightgreen: '90ee90',
384
- lightgrey: 'd3d3d3',
385
- lightpink: 'ffb6c1',
386
- lightsalmon: 'ffa07a',
387
- lightseagreen: '20b2aa',
388
- lightskyblue: '87cefa',
389
- lightslategray: '789',
390
- lightslategrey: '789',
391
- lightsteelblue: 'b0c4de',
392
- lightyellow: 'ffffe0',
393
- lime: '0f0',
394
- limegreen: '32cd32',
395
- linen: 'faf0e6',
396
- magenta: 'f0f',
397
- maroon: '800000',
398
- mediumaquamarine: '66cdaa',
399
- mediumblue: '0000cd',
400
- mediumorchid: 'ba55d3',
401
- mediumpurple: '9370db',
402
- mediumseagreen: '3cb371',
403
- mediumslateblue: '7b68ee',
404
- mediumspringgreen: '00fa9a',
405
- mediumturquoise: '48d1cc',
406
- mediumvioletred: 'c71585',
407
- midnightblue: '191970',
408
- mintcream: 'f5fffa',
409
- mistyrose: 'ffe4e1',
410
- moccasin: 'ffe4b5',
411
- navajowhite: 'ffdead',
412
- navy: '000080',
413
- oldlace: 'fdf5e6',
414
- olive: '808000',
415
- olivedrab: '6b8e23',
416
- orange: 'ffa500',
417
- orangered: 'ff4500',
418
- orchid: 'da70d6',
419
- palegoldenrod: 'eee8aa',
420
- palegreen: '98fb98',
421
- paleturquoise: 'afeeee',
422
- palevioletred: 'db7093',
423
- papayawhip: 'ffefd5',
424
- peachpuff: 'ffdab9',
425
- peru: 'cd853f',
426
- pink: 'ffc0cb',
427
- plum: 'dda0dd',
428
- powderblue: 'b0e0e6',
429
- purple: '800080',
430
- rebeccapurple: '639',
431
- red: 'f00',
432
- rosybrown: 'bc8f8f',
433
- royalblue: '4169e1',
434
- saddlebrown: '8b4513',
435
- salmon: 'fa8072',
436
- sandybrown: 'f4a460',
437
- seagreen: '2e8b57',
438
- seashell: 'fff5ee',
439
- sienna: 'a0522d',
440
- silver: 'c0c0c0',
441
- skyblue: '87ceeb',
442
- slateblue: '6a5acd',
443
- slategray: '708090',
444
- slategrey: '708090',
445
- snow: 'fffafa',
446
- springgreen: '00ff7f',
447
- steelblue: '4682b4',
448
- tan: 'd2b48c',
449
- teal: '008080',
450
- thistle: 'd8bfd8',
451
- tomato: 'ff6347',
452
- turquoise: '40e0d0',
453
- violet: 'ee82ee',
454
- wheat: 'f5deb3',
455
- white: 'fff',
456
- whitesmoke: 'f5f5f5',
457
- yellow: 'ff0',
458
- yellowgreen: '9acd32'
459
- };
460
- /**
461
- * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
462
- * @private
463
- */
464
-
465
- function nameToHex(color) {
466
- if (typeof color !== 'string') return color;
467
- var normalizedColorName = color.toLowerCase();
468
- return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
469
- }
470
-
471
- var hexRegex = /^#[a-fA-F0-9]{6}$/;
472
- var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
473
- var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
474
- var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
475
- var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
476
- var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
477
- var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
478
- var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
479
- /**
480
- * Returns an RgbColor or RgbaColor object. This utility function is only useful
481
- * if want to extract a color component. With the color util `toColorString` you
482
- * can convert a RgbColor or RgbaColor object back to a string.
483
- *
484
- * @example
485
- * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
486
- * const color1 = parseToRgb('rgb(255, 0, 0)');
487
- * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
488
- * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
489
- */
490
-
491
- function parseToRgb(color) {
492
- if (typeof color !== 'string') {
493
- throw new PolishedError(3);
494
- }
495
-
496
- var normalizedColor = nameToHex(color);
497
-
498
- if (normalizedColor.match(hexRegex)) {
499
- return {
500
- red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
501
- green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
502
- blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
503
- };
504
- }
505
-
506
- if (normalizedColor.match(hexRgbaRegex)) {
507
- var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
508
- return {
509
- red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
510
- green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
511
- blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
512
- alpha: alpha
513
- };
514
- }
515
-
516
- if (normalizedColor.match(reducedHexRegex)) {
517
- return {
518
- red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
519
- green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
520
- blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
521
- };
522
- }
523
-
524
- if (normalizedColor.match(reducedRgbaHexRegex)) {
525
- var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
526
-
527
- return {
528
- red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
529
- green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
530
- blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
531
- alpha: _alpha
532
- };
533
- }
534
-
535
- var rgbMatched = rgbRegex.exec(normalizedColor);
536
-
537
- if (rgbMatched) {
538
- return {
539
- red: parseInt("" + rgbMatched[1], 10),
540
- green: parseInt("" + rgbMatched[2], 10),
541
- blue: parseInt("" + rgbMatched[3], 10)
542
- };
543
- }
544
-
545
- var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
546
-
547
- if (rgbaMatched) {
548
- return {
549
- red: parseInt("" + rgbaMatched[1], 10),
550
- green: parseInt("" + rgbaMatched[2], 10),
551
- blue: parseInt("" + rgbaMatched[3], 10),
552
- alpha: parseFloat("" + rgbaMatched[4])
553
- };
554
- }
555
-
556
- var hslMatched = hslRegex.exec(normalizedColor);
557
-
558
- if (hslMatched) {
559
- var hue = parseInt("" + hslMatched[1], 10);
560
- var saturation = parseInt("" + hslMatched[2], 10) / 100;
561
- var lightness = parseInt("" + hslMatched[3], 10) / 100;
562
- var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
563
- var hslRgbMatched = rgbRegex.exec(rgbColorString);
564
-
565
- if (!hslRgbMatched) {
566
- throw new PolishedError(4, normalizedColor, rgbColorString);
567
- }
568
-
569
- return {
570
- red: parseInt("" + hslRgbMatched[1], 10),
571
- green: parseInt("" + hslRgbMatched[2], 10),
572
- blue: parseInt("" + hslRgbMatched[3], 10)
573
- };
574
- }
575
-
576
- var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
577
-
578
- if (hslaMatched) {
579
- var _hue = parseInt("" + hslaMatched[1], 10);
580
-
581
- var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
582
-
583
- var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
584
-
585
- var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
586
-
587
- var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
588
-
589
- if (!_hslRgbMatched) {
590
- throw new PolishedError(4, normalizedColor, _rgbColorString);
591
- }
592
-
593
- return {
594
- red: parseInt("" + _hslRgbMatched[1], 10),
595
- green: parseInt("" + _hslRgbMatched[2], 10),
596
- blue: parseInt("" + _hslRgbMatched[3], 10),
597
- alpha: parseFloat("" + hslaMatched[4])
598
- };
599
- }
600
-
601
- throw new PolishedError(5);
602
- }
603
- /**
604
- * Reduces hex values if possible e.g. #ff8866 to #f86
605
- * @private
606
- */
607
-
608
-
609
- var reduceHexValue = function reduceHexValue(value) {
610
- if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
611
- return "#" + value[1] + value[3] + value[5];
612
- }
613
-
614
- return value;
615
- };
616
-
617
- var reduceHexValue$1 = reduceHexValue;
618
-
619
- function numberToHex(value) {
620
- var hex = value.toString(16);
621
- return hex.length === 1 ? "0" + hex : hex;
622
- }
623
- /**
624
- * Returns a string value for the color. The returned result is the smallest possible hex notation.
625
- *
626
- * @example
627
- * // Styles as object usage
628
- * const styles = {
629
- * background: rgb(255, 205, 100),
630
- * background: rgb({ red: 255, green: 205, blue: 100 }),
631
- * }
632
- *
633
- * // styled-components usage
634
- * const div = styled.div`
635
- * background: ${rgb(255, 205, 100)};
636
- * background: ${rgb({ red: 255, green: 205, blue: 100 })};
637
- * `
638
- *
639
- * // CSS in JS Output
640
- *
641
- * element {
642
- * background: "#ffcd64";
643
- * background: "#ffcd64";
644
- * }
645
- */
646
-
647
-
648
- function rgb(value, green, blue) {
649
- if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
650
- return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
651
- } else if (typeof value === 'object' && green === undefined && blue === undefined) {
652
- return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
653
- }
654
-
655
- throw new PolishedError(6);
656
- }
657
- /**
658
- * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
659
- *
660
- * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
661
- *
662
- * @example
663
- * // Styles as object usage
664
- * const styles = {
665
- * background: rgba(255, 205, 100, 0.7),
666
- * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
667
- * background: rgba(255, 205, 100, 1),
668
- * background: rgba('#ffffff', 0.4),
669
- * background: rgba('black', 0.7),
670
- * }
671
- *
672
- * // styled-components usage
673
- * const div = styled.div`
674
- * background: ${rgba(255, 205, 100, 0.7)};
675
- * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
676
- * background: ${rgba(255, 205, 100, 1)};
677
- * background: ${rgba('#ffffff', 0.4)};
678
- * background: ${rgba('black', 0.7)};
679
- * `
680
- *
681
- * // CSS in JS Output
682
- *
683
- * element {
684
- * background: "rgba(255,205,100,0.7)";
685
- * background: "rgba(255,205,100,0.7)";
686
- * background: "#ffcd64";
687
- * background: "rgba(255,255,255,0.4)";
688
- * background: "rgba(0,0,0,0.7)";
689
- * }
690
- */
691
-
692
-
693
- function rgba(firstValue, secondValue, thirdValue, fourthValue) {
694
- if (typeof firstValue === 'string' && typeof secondValue === 'number') {
695
- var rgbValue = parseToRgb(firstValue);
696
- return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
697
- } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
698
- return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
699
- } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
700
- return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
701
- }
702
-
703
- throw new PolishedError(7);
704
- }
705
-
706
23
  var outlineEffect = {
707
24
  type: 'opacity',
708
25
  opacity: 0.32
709
26
  };
710
27
  var assertive = '#ff2b00';
711
28
  var brand = '#0096fa';
712
- var borderForLight = rgba('#000000', 0.08);
713
- var borderForDark = rgba('#ffffff', 0.12);
29
+ var borderForLight = polished.rgba('#000000', 0.08);
30
+ var borderForDark = polished.rgba('#ffffff', 0.12);
714
31
  var common = {
715
32
  typography: {
716
33
  size: foundation.TYPOGRAPHY_SIZE
@@ -736,10 +53,10 @@ var common = {
736
53
  },
737
54
  gradientColor: {
738
55
  surface5: [{
739
- color: rgba('#000000', 0.32),
56
+ color: polished.rgba('#000000', 0.32),
740
57
  ratio: 0
741
58
  }, {
742
- color: rgba('#000000', 0),
59
+ color: polished.rgba('#000000', 0),
743
60
  ratio: 100
744
61
  }],
745
62
  callToAction: [{
@@ -771,32 +88,32 @@ var light = _extends({}, common, {
771
88
  effect: {
772
89
  hover: {
773
90
  type: 'alpha',
774
- color: rgba('#000000', 0.04) // surface3
91
+ color: polished.rgba('#000000', 0.04) // surface3
775
92
 
776
93
  },
777
94
  press: {
778
95
  type: 'alpha',
779
- color: rgba('#000000', 0.16) // surface10
96
+ color: polished.rgba('#000000', 0.16) // surface10
780
97
 
781
98
  }
782
99
  },
783
100
  color: {
784
101
  // TODO: colors should be picked from foundation color palette
785
- transparent: rgba('#000000', 0),
102
+ transparent: polished.rgba('#000000', 0),
786
103
  background1: '#ffffff',
787
104
  background2: '#f5f5f5',
788
- icon6: rgba('#ffffff', 0.28),
105
+ icon6: polished.rgba('#ffffff', 0.28),
789
106
  link1: '#3d7699',
790
- link2: rgba('#ffffff', 0.36),
107
+ link2: polished.rgba('#ffffff', 0.36),
791
108
  surface1: '#ffffff',
792
- surface2: rgba('#000000', 0.02),
793
- surface3: rgba('#000000', 0.04),
794
- surface4: rgba('#000000', 0.32),
795
- surface6: rgba('#000000', 0.88),
796
- surface7: rgba('#000000', 0.02),
797
- surface8: rgba('#000000', 0.88),
109
+ surface2: polished.rgba('#000000', 0.02),
110
+ surface3: polished.rgba('#000000', 0.04),
111
+ surface4: polished.rgba('#000000', 0.32),
112
+ surface6: polished.rgba('#000000', 0.88),
113
+ surface7: polished.rgba('#000000', 0.02),
114
+ surface8: polished.rgba('#000000', 0.88),
798
115
  surface9: '#ffffff',
799
- surface10: rgba('#000000', 0.16),
116
+ surface10: polished.rgba('#000000', 0.16),
800
117
  text1: '#1f1f1f',
801
118
  text2: '#474747',
802
119
  text3: '#858585',
@@ -806,7 +123,7 @@ var light = _extends({}, common, {
806
123
  assertive: assertive,
807
124
  warning: '#ffaf0f',
808
125
  success: '#b1cc29',
809
- updatedItem: rgba(0, 150, 250, 0.04),
126
+ updatedItem: polished.rgba(0, 150, 250, 0.04),
810
127
  border: borderForLight
811
128
  },
812
129
  border: {
@@ -819,31 +136,31 @@ var dark = _extends({}, common, {
819
136
  effect: {
820
137
  hover: {
821
138
  type: 'alpha',
822
- color: rgba('#ffffff', 0.12) // surface3
139
+ color: polished.rgba('#ffffff', 0.12) // surface3
823
140
 
824
141
  },
825
142
  press: {
826
143
  type: 'alpha',
827
- color: rgba('#ffffff', 0.2) // surface10
144
+ color: polished.rgba('#ffffff', 0.2) // surface10
828
145
 
829
146
  }
830
147
  },
831
148
  color: {
832
- transparent: rgba('#000000', 0),
149
+ transparent: polished.rgba('#000000', 0),
833
150
  background1: '#1f1f1f',
834
151
  background2: '#000000',
835
152
  icon6: light.color.icon6,
836
153
  link1: '#669FC2',
837
154
  link2: light.color.link2,
838
155
  surface1: '#1f1f1f',
839
- surface2: rgba('#000000', 0.16),
840
- surface3: rgba('#ffffff', 0.12),
156
+ surface2: polished.rgba('#000000', 0.16),
157
+ surface3: polished.rgba('#ffffff', 0.12),
841
158
  surface4: light.color.surface4,
842
- surface6: rgba('#ffffff', 0.12),
159
+ surface6: polished.rgba('#ffffff', 0.12),
843
160
  surface7: light.color.surface7,
844
161
  surface8: light.color.surface8,
845
162
  surface9: '#333333',
846
- surface10: rgba('#ffffff', 0.2),
163
+ surface10: polished.rgba('#ffffff', 0.2),
847
164
  text1: '#f5f5f5',
848
165
  text2: '#d6d6d6',
849
166
  text3: '#858585',
@@ -853,7 +170,7 @@ var dark = _extends({}, common, {
853
170
  assertive: assertive,
854
171
  warning: light.color.warning,
855
172
  success: light.color.success,
856
- updatedItem: rgba(0, 150, 250, 0.12),
173
+ updatedItem: polished.rgba(0, 150, 250, 0.12),
857
174
  border: borderForDark
858
175
  },
859
176
  border: {