1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/esm/extends'), require('@babel/runtime/helpers/esm/assertThisInitialized'), require('@babel/runtime/helpers/esm/inheritsLoose'), require('@babel/runtime/helpers/esm/wrapNativeSuper'), require('@babel/runtime/helpers/esm/taggedTemplateLiteralLoose')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/esm/extends', '@babel/runtime/helpers/esm/assertThisInitialized', '@babel/runtime/helpers/esm/inheritsLoose', '@babel/runtime/helpers/esm/wrapNativeSuper', '@babel/runtime/helpers/esm/taggedTemplateLiteralLoose'], factory) :
|
4 | (global = global || self, factory(global.polished = {}, global.extends, global.assertThisInitialized, global.inheritsLoose, global.wrapNativeSuper, global.taggedTemplateLiteralLoose));
|
5 | }(this, (function (exports, _extends, _assertThisInitialized, _inheritsLoose, _wrapNativeSuper, _taggedTemplateLiteralLoose) { 'use strict';
|
6 |
|
7 | _extends = _extends && Object.prototype.hasOwnProperty.call(_extends, 'default') ? _extends['default'] : _extends;
|
8 | _assertThisInitialized = _assertThisInitialized && Object.prototype.hasOwnProperty.call(_assertThisInitialized, 'default') ? _assertThisInitialized['default'] : _assertThisInitialized;
|
9 | _inheritsLoose = _inheritsLoose && Object.prototype.hasOwnProperty.call(_inheritsLoose, 'default') ? _inheritsLoose['default'] : _inheritsLoose;
|
10 | _wrapNativeSuper = _wrapNativeSuper && Object.prototype.hasOwnProperty.call(_wrapNativeSuper, 'default') ? _wrapNativeSuper['default'] : _wrapNativeSuper;
|
11 | _taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose && Object.prototype.hasOwnProperty.call(_taggedTemplateLiteralLoose, 'default') ? _taggedTemplateLiteralLoose['default'] : _taggedTemplateLiteralLoose;
|
12 |
|
13 | function last() {
|
14 | var _ref;
|
15 |
|
16 | return _ref = arguments.length - 1, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref];
|
17 | }
|
18 |
|
19 | function negation(a) {
|
20 | return -a;
|
21 | }
|
22 |
|
23 | function addition(a, b) {
|
24 | return a + b;
|
25 | }
|
26 |
|
27 | function subtraction(a, b) {
|
28 | return a - b;
|
29 | }
|
30 |
|
31 | function multiplication(a, b) {
|
32 | return a * b;
|
33 | }
|
34 |
|
35 | function division(a, b) {
|
36 | return a / b;
|
37 | }
|
38 |
|
39 | function factorial(a) {
|
40 | if (a % 1 || !(+a >= 0)) return NaN;
|
41 | if (a > 170) return Infinity;else if (a === 0) return 1;else {
|
42 | return a * factorial(a - 1);
|
43 | }
|
44 | }
|
45 |
|
46 | function power(a, b) {
|
47 | return Math.pow(a, b);
|
48 | }
|
49 |
|
50 | function sqrt(a) {
|
51 | return Math.sqrt(a);
|
52 | }
|
53 |
|
54 | function max() {
|
55 | return Math.max.apply(Math, arguments);
|
56 | }
|
57 |
|
58 | function min() {
|
59 | return Math.min.apply(Math, arguments);
|
60 | }
|
61 |
|
62 | function comma() {
|
63 | return Array.of.apply(Array, arguments);
|
64 | }
|
65 |
|
66 | var defaultMathSymbols = {
|
67 | symbols: {
|
68 | '!': {
|
69 | postfix: {
|
70 | symbol: '!',
|
71 | f: factorial,
|
72 | notation: 'postfix',
|
73 | precedence: 6,
|
74 | rightToLeft: 0,
|
75 | argCount: 1
|
76 | },
|
77 | symbol: '!',
|
78 | regSymbol: '!'
|
79 | },
|
80 | '^': {
|
81 | infix: {
|
82 | symbol: '^',
|
83 | f: power,
|
84 | notation: 'infix',
|
85 | precedence: 5,
|
86 | rightToLeft: 1,
|
87 | argCount: 2
|
88 | },
|
89 | symbol: '^',
|
90 | regSymbol: '\\^'
|
91 | },
|
92 | '*': {
|
93 | infix: {
|
94 | symbol: '*',
|
95 | f: multiplication,
|
96 | notation: 'infix',
|
97 | precedence: 4,
|
98 | rightToLeft: 0,
|
99 | argCount: 2
|
100 | },
|
101 | symbol: '*',
|
102 | regSymbol: '\\*'
|
103 | },
|
104 | '/': {
|
105 | infix: {
|
106 | symbol: '/',
|
107 | f: division,
|
108 | notation: 'infix',
|
109 | precedence: 4,
|
110 | rightToLeft: 0,
|
111 | argCount: 2
|
112 | },
|
113 | symbol: '/',
|
114 | regSymbol: '/'
|
115 | },
|
116 | '+': {
|
117 | infix: {
|
118 | symbol: '+',
|
119 | f: addition,
|
120 | notation: 'infix',
|
121 | precedence: 2,
|
122 | rightToLeft: 0,
|
123 | argCount: 2
|
124 | },
|
125 | prefix: {
|
126 | symbol: '+',
|
127 | f: last,
|
128 | notation: 'prefix',
|
129 | precedence: 3,
|
130 | rightToLeft: 0,
|
131 | argCount: 1
|
132 | },
|
133 | symbol: '+',
|
134 | regSymbol: '\\+'
|
135 | },
|
136 | '-': {
|
137 | infix: {
|
138 | symbol: '-',
|
139 | f: subtraction,
|
140 | notation: 'infix',
|
141 | precedence: 2,
|
142 | rightToLeft: 0,
|
143 | argCount: 2
|
144 | },
|
145 | prefix: {
|
146 | symbol: '-',
|
147 | f: negation,
|
148 | notation: 'prefix',
|
149 | precedence: 3,
|
150 | rightToLeft: 0,
|
151 | argCount: 1
|
152 | },
|
153 | symbol: '-',
|
154 | regSymbol: '-'
|
155 | },
|
156 | ',': {
|
157 | infix: {
|
158 | symbol: ',',
|
159 | f: comma,
|
160 | notation: 'infix',
|
161 | precedence: 1,
|
162 | rightToLeft: 0,
|
163 | argCount: 2
|
164 | },
|
165 | symbol: ',',
|
166 | regSymbol: ','
|
167 | },
|
168 | '(': {
|
169 | prefix: {
|
170 | symbol: '(',
|
171 | f: last,
|
172 | notation: 'prefix',
|
173 | precedence: 0,
|
174 | rightToLeft: 0,
|
175 | argCount: 1
|
176 | },
|
177 | symbol: '(',
|
178 | regSymbol: '\\('
|
179 | },
|
180 | ')': {
|
181 | postfix: {
|
182 | symbol: ')',
|
183 | f: undefined,
|
184 | notation: 'postfix',
|
185 | precedence: 0,
|
186 | rightToLeft: 0,
|
187 | argCount: 1
|
188 | },
|
189 | symbol: ')',
|
190 | regSymbol: '\\)'
|
191 | },
|
192 | min: {
|
193 | func: {
|
194 | symbol: 'min',
|
195 | f: min,
|
196 | notation: 'func',
|
197 | precedence: 0,
|
198 | rightToLeft: 0,
|
199 | argCount: 1
|
200 | },
|
201 | symbol: 'min',
|
202 | regSymbol: 'min\\b'
|
203 | },
|
204 | max: {
|
205 | func: {
|
206 | symbol: 'max',
|
207 | f: max,
|
208 | notation: 'func',
|
209 | precedence: 0,
|
210 | rightToLeft: 0,
|
211 | argCount: 1
|
212 | },
|
213 | symbol: 'max',
|
214 | regSymbol: 'max\\b'
|
215 | },
|
216 | sqrt: {
|
217 | func: {
|
218 | symbol: 'sqrt',
|
219 | f: sqrt,
|
220 | notation: 'func',
|
221 | precedence: 0,
|
222 | rightToLeft: 0,
|
223 | argCount: 1
|
224 | },
|
225 | symbol: 'sqrt',
|
226 | regSymbol: 'sqrt\\b'
|
227 | }
|
228 | }
|
229 | };
|
230 |
|
231 |
|
232 |
|
233 | |
234 |
|
235 |
|
236 |
|
237 | var ERRORS = {
|
238 | "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",
|
239 | "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",
|
240 | "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
|
241 | "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
|
242 | "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
|
243 | "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",
|
244 | "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",
|
245 | "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
|
246 | "9": "Please provide a number of steps to the modularScale helper.\n\n",
|
247 | "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
248 | "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
|
249 | "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
|
250 | "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
|
251 | "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
252 | "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
253 | "16": "You must provide a template to this method.\n\n",
|
254 | "17": "You passed an unsupported selector state to this method.\n\n",
|
255 | "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
256 | "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
257 | "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
258 | "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
259 | "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
260 | "23": "fontFace expects a name of a font-family.\n\n",
|
261 | "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
262 | "25": "fontFace expects localFonts to be an array.\n\n",
|
263 | "26": "fontFace expects fileFormats to be an array.\n\n",
|
264 | "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
265 | "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
266 | "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
267 | "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
268 | "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
269 | "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",
|
270 | "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
271 | "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
272 | "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
273 | "36": "Property must be a string value.\n\n",
|
274 | "37": "Syntax Error at %s.\n\n",
|
275 | "38": "Formula contains a function that needs parentheses at %s.\n\n",
|
276 | "39": "Formula is missing closing parenthesis at %s.\n\n",
|
277 | "40": "Formula has too many closing parentheses at %s.\n\n",
|
278 | "41": "All values in a formula must have the same unit or be unitless.\n\n",
|
279 | "42": "Please provide a number of steps to the modularScale helper.\n\n",
|
280 | "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
281 | "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
282 | "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
283 | "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
284 | "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
285 | "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
286 | "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
287 | "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
288 | "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
289 | "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
290 | "53": "fontFace expects localFonts to be an array.\n\n",
|
291 | "54": "fontFace expects fileFormats to be an array.\n\n",
|
292 | "55": "fontFace expects a name of a font-family.\n\n",
|
293 | "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
294 | "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
295 | "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
296 | "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
297 | "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
298 | "61": "Property must be a string value.\n\n",
|
299 | "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
300 | "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
301 | "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
302 | "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",
|
303 | "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
304 | "67": "You must provide a template to this method.\n\n",
|
305 | "68": "You passed an unsupported selector state to this method.\n\n",
|
306 | "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
|
307 | "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
|
308 | "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
309 | "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
310 | "73": "Please provide a valid CSS variable.\n\n",
|
311 | "74": "CSS variable not found.\n"
|
312 | };
|
313 | |
314 |
|
315 |
|
316 |
|
317 |
|
318 | function format() {
|
319 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
320 | args[_key] = arguments[_key];
|
321 | }
|
322 |
|
323 | var a = args[0];
|
324 | var b = [];
|
325 | var c;
|
326 |
|
327 | for (c = 1; c < args.length; c += 1) {
|
328 | b.push(args[c]);
|
329 | }
|
330 |
|
331 | b.forEach(function (d) {
|
332 | a = a.replace(/%[a-z]/, d);
|
333 | });
|
334 | return a;
|
335 | }
|
336 | |
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 | var PolishedError = function (_Error) {
|
344 | _inheritsLoose(PolishedError, _Error);
|
345 |
|
346 | function PolishedError(code) {
|
347 | var _this;
|
348 |
|
349 | {
|
350 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
351 | args[_key2 - 1] = arguments[_key2];
|
352 | }
|
353 |
|
354 | _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
355 | }
|
356 |
|
357 | return _assertThisInitialized(_this);
|
358 | }
|
359 |
|
360 | return PolishedError;
|
361 | }( _wrapNativeSuper(Error));
|
362 |
|
363 | var unitRegExp = /((?!\w)a|na|hc|mc|dg|me[r]?|xe|ni(?![a-zA-Z])|mm|cp|tp|xp|q(?!s)|hv|xamv|nimv|wv|sm|s(?!\D|$)|ged|darg?|nrut)/g;
|
364 |
|
365 | function mergeSymbolMaps(additionalSymbols) {
|
366 | var symbolMap = {};
|
367 | symbolMap.symbols = additionalSymbols ? _extends({}, defaultMathSymbols.symbols, {}, additionalSymbols.symbols) : _extends({}, defaultMathSymbols.symbols);
|
368 | return symbolMap;
|
369 | }
|
370 |
|
371 | function exec(operators, values) {
|
372 | var _ref;
|
373 |
|
374 | var op = operators.pop();
|
375 | values.push(op.f.apply(op, (_ref = []).concat.apply(_ref, values.splice(-op.argCount))));
|
376 | return op.precedence;
|
377 | }
|
378 |
|
379 | function calculate(expression, additionalSymbols) {
|
380 | var symbolMap = mergeSymbolMaps(additionalSymbols);
|
381 | var match;
|
382 | var operators = [symbolMap.symbols['('].prefix];
|
383 | var values = [];
|
384 | var pattern = new RegExp(
|
385 | "\\d+(?:\\.\\d+)?|" +
|
386 | Object.keys(symbolMap.symbols).map(function (key) {
|
387 | return symbolMap.symbols[key];
|
388 | })
|
389 |
|
390 | .sort(function (a, b) {
|
391 | return b.symbol.length - a.symbol.length;
|
392 | })
|
393 | .map(function (val) {
|
394 | return val.regSymbol;
|
395 | }).join('|') + "|(\\S)", 'g');
|
396 | pattern.lastIndex = 0;
|
397 |
|
398 | var afterValue = false;
|
399 |
|
400 | do {
|
401 | match = pattern.exec(expression);
|
402 |
|
403 | var _ref2 = match || [')', undefined],
|
404 | token = _ref2[0],
|
405 | bad = _ref2[1];
|
406 |
|
407 | var notNumber = symbolMap.symbols[token];
|
408 | var notNewValue = notNumber && !notNumber.prefix && !notNumber.func;
|
409 | var notAfterValue = !notNumber || !notNumber.postfix && !notNumber.infix;
|
410 |
|
411 | if (bad || (afterValue ? notAfterValue : notNewValue)) {
|
412 | throw new PolishedError(37, match ? match.index : expression.length, expression);
|
413 | }
|
414 |
|
415 | if (afterValue) {
|
416 |
|
417 | var curr = notNumber.postfix || notNumber.infix;
|
418 |
|
419 | do {
|
420 | var prev = operators[operators.length - 1];
|
421 | if ((curr.precedence - prev.precedence || prev.rightToLeft) > 0) break;
|
422 | } while (exec(operators, values));
|
423 |
|
424 |
|
425 | afterValue = curr.notation === 'postfix';
|
426 |
|
427 | if (curr.symbol !== ')') {
|
428 | operators.push(curr);
|
429 |
|
430 | if (afterValue) exec(operators, values);
|
431 | }
|
432 | } else if (notNumber) {
|
433 |
|
434 | operators.push(notNumber.prefix || notNumber.func);
|
435 |
|
436 | if (notNumber.func) {
|
437 |
|
438 | match = pattern.exec(expression);
|
439 |
|
440 | if (!match || match[0] !== '(') {
|
441 | throw new PolishedError(38, match ? match.index : expression.length, expression);
|
442 | }
|
443 | }
|
444 | } else {
|
445 |
|
446 | values.push(+token);
|
447 | afterValue = true;
|
448 | }
|
449 | } while (match && operators.length);
|
450 |
|
451 | if (operators.length) {
|
452 | throw new PolishedError(39, match ? match.index : expression.length, expression);
|
453 | } else if (match) {
|
454 | throw new PolishedError(40, match ? match.index : expression.length, expression);
|
455 | } else {
|
456 | return values.pop();
|
457 | }
|
458 | }
|
459 |
|
460 | function reverseString(str) {
|
461 | return str.split('').reverse().join('');
|
462 | }
|
463 | |
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 | function math(formula, additionalSymbols) {
|
495 | var reversedFormula = reverseString(formula);
|
496 | var formulaMatch = reversedFormula.match(unitRegExp);
|
497 |
|
498 | if (formulaMatch && !formulaMatch.every(function (unit) {
|
499 | return unit === formulaMatch[0];
|
500 | })) {
|
501 | throw new PolishedError(41);
|
502 | }
|
503 |
|
504 | var cleanFormula = reverseString(reversedFormula.replace(unitRegExp, ''));
|
505 | return "" + calculate(cleanFormula, additionalSymbols) + (formulaMatch ? reverseString(formulaMatch[0]) : '');
|
506 | }
|
507 |
|
508 | var cssVariableRegex = /--[\S]*/g;
|
509 | |
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 | function cssVar(cssVariable, passThrough) {
|
533 | if (!cssVariable || !cssVariable.match(cssVariableRegex)) {
|
534 | if (passThrough) return cssVariable;
|
535 | throw new PolishedError(73);
|
536 | }
|
537 |
|
538 | var variableValue;
|
539 |
|
540 |
|
541 |
|
542 |
|
543 | if (document.documentElement !== null) {
|
544 | variableValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariable);
|
545 | }
|
546 |
|
547 |
|
548 |
|
549 | if (variableValue) {
|
550 | return variableValue.trim();
|
551 | } else {
|
552 | throw new PolishedError(74);
|
553 | }
|
554 | }
|
555 |
|
556 |
|
557 | function capitalizeString(string) {
|
558 | return string.charAt(0).toUpperCase() + string.slice(1);
|
559 | }
|
560 |
|
561 | var positionMap = ['Top', 'Right', 'Bottom', 'Left'];
|
562 |
|
563 | function generateProperty(property, position) {
|
564 | if (!property) return position.toLowerCase();
|
565 | var splitProperty = property.split('-');
|
566 |
|
567 | if (splitProperty.length > 1) {
|
568 | splitProperty.splice(1, 0, position);
|
569 | return splitProperty.reduce(function (acc, val) {
|
570 | return "" + acc + capitalizeString(val);
|
571 | });
|
572 | }
|
573 |
|
574 | var joinedProperty = property.replace(/([a-z])([A-Z])/g, "$1" + position + "$2");
|
575 | return property === joinedProperty ? "" + property + position : joinedProperty;
|
576 | }
|
577 |
|
578 | function generateStyles(property, valuesWithDefaults) {
|
579 | var styles = {};
|
580 |
|
581 | for (var i = 0; i < valuesWithDefaults.length; i += 1) {
|
582 | if (valuesWithDefaults[i] || valuesWithDefaults[i] === 0) {
|
583 | styles[generateProperty(property, positionMap[i])] = valuesWithDefaults[i];
|
584 | }
|
585 | }
|
586 |
|
587 | return styles;
|
588 | }
|
589 | |
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 | function directionalProperty(property) {
|
614 | for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
615 | values[_key - 1] = arguments[_key];
|
616 | }
|
617 |
|
618 |
|
619 | var firstValue = values[0],
|
620 | _values$ = values[1],
|
621 | secondValue = _values$ === void 0 ? firstValue : _values$,
|
622 | _values$2 = values[2],
|
623 | thirdValue = _values$2 === void 0 ? firstValue : _values$2,
|
624 | _values$3 = values[3],
|
625 | fourthValue = _values$3 === void 0 ? secondValue : _values$3;
|
626 | var valuesWithDefaults = [firstValue, secondValue, thirdValue, fourthValue];
|
627 | return generateStyles(property, valuesWithDefaults);
|
628 | }
|
629 |
|
630 | |
631 |
|
632 |
|
633 |
|
634 | function endsWith (string, suffix) {
|
635 | return string.substr(-suffix.length) === suffix;
|
636 | }
|
637 |
|
638 | var cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
639 | |
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 | function stripUnit(value, unitReturn) {
|
663 | if (typeof value !== 'string') return unitReturn ? [value, undefined] : value;
|
664 | var matchedValue = value.match(cssRegex);
|
665 |
|
666 | if (unitReturn) {
|
667 |
|
668 | console.warn("stripUnit's unitReturn functionality has been marked for deprecation in polished 4.0. It's functionality has been been moved to getValueAndUnit.");
|
669 | if (matchedValue) return [parseFloat(value), matchedValue[2]];
|
670 | return [value, undefined];
|
671 | }
|
672 |
|
673 | if (matchedValue) return parseFloat(value);
|
674 | return value;
|
675 | }
|
676 |
|
677 | |
678 |
|
679 |
|
680 |
|
681 |
|
682 | var pxtoFactory = function pxtoFactory(to) {
|
683 | return function (pxval, base) {
|
684 | if (base === void 0) {
|
685 | base = '16px';
|
686 | }
|
687 |
|
688 | var newPxval = pxval;
|
689 | var newBase = base;
|
690 |
|
691 | if (typeof pxval === 'string') {
|
692 | if (!endsWith(pxval, 'px')) {
|
693 | throw new PolishedError(69, to, pxval);
|
694 | }
|
695 |
|
696 | newPxval = stripUnit(pxval);
|
697 | }
|
698 |
|
699 | if (typeof base === 'string') {
|
700 | if (!endsWith(base, 'px')) {
|
701 | throw new PolishedError(70, to, base);
|
702 | }
|
703 |
|
704 | newBase = stripUnit(base);
|
705 | }
|
706 |
|
707 | if (typeof newPxval === 'string') {
|
708 | throw new PolishedError(71, pxval, to);
|
709 | }
|
710 |
|
711 | if (typeof newBase === 'string') {
|
712 | throw new PolishedError(72, base, to);
|
713 | }
|
714 |
|
715 | return "" + newPxval / newBase + to;
|
716 | };
|
717 | };
|
718 |
|
719 | |
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 | var em = pxtoFactory('em');
|
744 |
|
745 | var cssRegex$1 = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
746 | |
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 | function getValueAndUnit(value) {
|
771 | if (typeof value !== 'string') return [value, ''];
|
772 | var matchedValue = value.match(cssRegex$1);
|
773 | if (matchedValue) return [parseFloat(value), matchedValue[2]];
|
774 | return [value, undefined];
|
775 | }
|
776 |
|
777 | var ratioNames = {
|
778 | minorSecond: 1.067,
|
779 | majorSecond: 1.125,
|
780 | minorThird: 1.2,
|
781 | majorThird: 1.25,
|
782 | perfectFourth: 1.333,
|
783 | augFourth: 1.414,
|
784 | perfectFifth: 1.5,
|
785 | minorSixth: 1.6,
|
786 | goldenSection: 1.618,
|
787 | majorSixth: 1.667,
|
788 | minorSeventh: 1.778,
|
789 | majorSeventh: 1.875,
|
790 | octave: 2,
|
791 | majorTenth: 2.5,
|
792 | majorEleventh: 2.667,
|
793 | majorTwelfth: 3,
|
794 | doubleOctave: 4
|
795 | };
|
796 |
|
797 | function getRatio(ratioName) {
|
798 | return ratioNames[ratioName];
|
799 | }
|
800 | |
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 | function modularScale(steps, base, ratio) {
|
824 | if (base === void 0) {
|
825 | base = '1em';
|
826 | }
|
827 |
|
828 | if (ratio === void 0) {
|
829 | ratio = 1.333;
|
830 | }
|
831 |
|
832 | if (typeof steps !== 'number') {
|
833 | throw new PolishedError(42);
|
834 | }
|
835 |
|
836 | if (typeof ratio === 'string' && !ratioNames[ratio]) {
|
837 | throw new PolishedError(43);
|
838 | }
|
839 |
|
840 | var _ref = typeof base === 'string' ? getValueAndUnit(base) : [base, ''],
|
841 | realBase = _ref[0],
|
842 | unit = _ref[1];
|
843 |
|
844 | var realRatio = typeof ratio === 'string' ? getRatio(ratio) : ratio;
|
845 |
|
846 | if (typeof realBase === 'string') {
|
847 | throw new PolishedError(44, base);
|
848 | }
|
849 |
|
850 | return "" + realBase * Math.pow(realRatio, steps) + (unit || '');
|
851 | }
|
852 |
|
853 | |
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 | var rem = pxtoFactory('rem');
|
878 |
|
879 | |
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 | function between(fromSize, toSize, minScreen, maxScreen) {
|
904 | if (minScreen === void 0) {
|
905 | minScreen = '320px';
|
906 | }
|
907 |
|
908 | if (maxScreen === void 0) {
|
909 | maxScreen = '1200px';
|
910 | }
|
911 |
|
912 | var _getValueAndUnit = getValueAndUnit(fromSize),
|
913 | unitlessFromSize = _getValueAndUnit[0],
|
914 | fromSizeUnit = _getValueAndUnit[1];
|
915 |
|
916 | var _getValueAndUnit2 = getValueAndUnit(toSize),
|
917 | unitlessToSize = _getValueAndUnit2[0],
|
918 | toSizeUnit = _getValueAndUnit2[1];
|
919 |
|
920 | var _getValueAndUnit3 = getValueAndUnit(minScreen),
|
921 | unitlessMinScreen = _getValueAndUnit3[0],
|
922 | minScreenUnit = _getValueAndUnit3[1];
|
923 |
|
924 | var _getValueAndUnit4 = getValueAndUnit(maxScreen),
|
925 | unitlessMaxScreen = _getValueAndUnit4[0],
|
926 | maxScreenUnit = _getValueAndUnit4[1];
|
927 |
|
928 | if (typeof unitlessMinScreen !== 'number' || typeof unitlessMaxScreen !== 'number' || !minScreenUnit || !maxScreenUnit || minScreenUnit !== maxScreenUnit) {
|
929 | throw new PolishedError(47);
|
930 | }
|
931 |
|
932 | if (typeof unitlessFromSize !== 'number' || typeof unitlessToSize !== 'number' || fromSizeUnit !== toSizeUnit) {
|
933 | throw new PolishedError(48);
|
934 | }
|
935 |
|
936 | var slope = (unitlessFromSize - unitlessToSize) / (unitlessMinScreen - unitlessMaxScreen);
|
937 | var base = unitlessToSize - slope * unitlessMaxScreen;
|
938 | return "calc(" + base.toFixed(2) + (fromSizeUnit || '') + " + " + (100 * slope).toFixed(2) + "vw)";
|
939 | }
|
940 |
|
941 | |
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 | function clearFix(parent) {
|
964 | var _ref;
|
965 |
|
966 | if (parent === void 0) {
|
967 | parent = '&';
|
968 | }
|
969 |
|
970 | var pseudoSelector = parent + "::after";
|
971 | return _ref = {}, _ref[pseudoSelector] = {
|
972 | clear: 'both',
|
973 | content: '""',
|
974 | display: 'table'
|
975 | }, _ref;
|
976 | }
|
977 |
|
978 | |
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 | function cover(offset) {
|
1003 | if (offset === void 0) {
|
1004 | offset = 0;
|
1005 | }
|
1006 |
|
1007 | return {
|
1008 | position: 'absolute',
|
1009 | top: offset,
|
1010 | right: offset,
|
1011 | bottom: offset,
|
1012 | left: offset
|
1013 | };
|
1014 | }
|
1015 |
|
1016 | |
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 | function ellipsis(width) {
|
1042 | if (width === void 0) {
|
1043 | width = '100%';
|
1044 | }
|
1045 |
|
1046 | return {
|
1047 | display: 'inline-block',
|
1048 | maxWidth: width,
|
1049 | overflow: 'hidden',
|
1050 | textOverflow: 'ellipsis',
|
1051 | whiteSpace: 'nowrap',
|
1052 | wordWrap: 'normal'
|
1053 | };
|
1054 | }
|
1055 |
|
1056 | function _createForOfIteratorHelperLoose(o) { var i = 0; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } i = o[Symbol.iterator](); return i.next.bind(i); }
|
1057 |
|
1058 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
1059 |
|
1060 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
1061 |
|
1062 | |
1063 |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 | function fluidRange(cssProp, minScreen, maxScreen) {
|
1105 | if (minScreen === void 0) {
|
1106 | minScreen = '320px';
|
1107 | }
|
1108 |
|
1109 | if (maxScreen === void 0) {
|
1110 | maxScreen = '1200px';
|
1111 | }
|
1112 |
|
1113 | if (!Array.isArray(cssProp) && typeof cssProp !== 'object' || cssProp === null) {
|
1114 | throw new PolishedError(49);
|
1115 | }
|
1116 |
|
1117 | if (Array.isArray(cssProp)) {
|
1118 | var mediaQueries = {};
|
1119 | var fallbacks = {};
|
1120 |
|
1121 | for (var _iterator = _createForOfIteratorHelperLoose(cssProp), _step; !(_step = _iterator()).done;) {
|
1122 | var _extends2, _extends3;
|
1123 |
|
1124 | var obj = _step.value;
|
1125 |
|
1126 | if (!obj.prop || !obj.fromSize || !obj.toSize) {
|
1127 | throw new PolishedError(50);
|
1128 | }
|
1129 |
|
1130 | fallbacks[obj.prop] = obj.fromSize;
|
1131 | mediaQueries["@media (min-width: " + minScreen + ")"] = _extends({}, mediaQueries["@media (min-width: " + minScreen + ")"], (_extends2 = {}, _extends2[obj.prop] = between(obj.fromSize, obj.toSize, minScreen, maxScreen), _extends2));
|
1132 | mediaQueries["@media (min-width: " + maxScreen + ")"] = _extends({}, mediaQueries["@media (min-width: " + maxScreen + ")"], (_extends3 = {}, _extends3[obj.prop] = obj.toSize, _extends3));
|
1133 | }
|
1134 |
|
1135 | return _extends({}, fallbacks, {}, mediaQueries);
|
1136 | } else {
|
1137 | var _ref, _ref2, _ref3;
|
1138 |
|
1139 | if (!cssProp.prop || !cssProp.fromSize || !cssProp.toSize) {
|
1140 | throw new PolishedError(51);
|
1141 | }
|
1142 |
|
1143 | return _ref3 = {}, _ref3[cssProp.prop] = cssProp.fromSize, _ref3["@media (min-width: " + minScreen + ")"] = (_ref = {}, _ref[cssProp.prop] = between(cssProp.fromSize, cssProp.toSize, minScreen, maxScreen), _ref), _ref3["@media (min-width: " + maxScreen + ")"] = (_ref2 = {}, _ref2[cssProp.prop] = cssProp.toSize, _ref2), _ref3;
|
1144 | }
|
1145 | }
|
1146 |
|
1147 | var dataURIRegex = /^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i;
|
1148 | var formatHintMap = {
|
1149 | woff: 'woff',
|
1150 | woff2: 'woff2',
|
1151 | ttf: 'truetype',
|
1152 | otf: 'opentype',
|
1153 | eot: 'embedded-opentype',
|
1154 | svg: 'svg',
|
1155 | svgz: 'svg'
|
1156 | };
|
1157 |
|
1158 | function generateFormatHint(format, formatHint) {
|
1159 | if (!formatHint) return '';
|
1160 | return " format(\"" + formatHintMap[format] + "\")";
|
1161 | }
|
1162 |
|
1163 | function isDataURI(fontFilePath) {
|
1164 | return !!fontFilePath.match(dataURIRegex);
|
1165 | }
|
1166 |
|
1167 | function generateFileReferences(fontFilePath, fileFormats, formatHint) {
|
1168 | if (isDataURI(fontFilePath)) {
|
1169 | return "url(\"" + fontFilePath + "\")" + generateFormatHint(fileFormats[0], formatHint);
|
1170 | }
|
1171 |
|
1172 | var fileFontReferences = fileFormats.map(function (format) {
|
1173 | return "url(\"" + fontFilePath + "." + format + "\")" + generateFormatHint(format, formatHint);
|
1174 | });
|
1175 | return fileFontReferences.join(', ');
|
1176 | }
|
1177 |
|
1178 | function generateLocalReferences(localFonts) {
|
1179 | var localFontReferences = localFonts.map(function (font) {
|
1180 | return "local(\"" + font + "\")";
|
1181 | });
|
1182 | return localFontReferences.join(', ');
|
1183 | }
|
1184 |
|
1185 | function generateSources(fontFilePath, localFonts, fileFormats, formatHint) {
|
1186 | var fontReferences = [];
|
1187 | if (localFonts) fontReferences.push(generateLocalReferences(localFonts));
|
1188 |
|
1189 | if (fontFilePath) {
|
1190 | fontReferences.push(generateFileReferences(fontFilePath, fileFormats, formatHint));
|
1191 | }
|
1192 |
|
1193 | return fontReferences.join(', ');
|
1194 | }
|
1195 | |
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 | function fontFace(_ref) {
|
1225 | var fontFamily = _ref.fontFamily,
|
1226 | fontFilePath = _ref.fontFilePath,
|
1227 | fontStretch = _ref.fontStretch,
|
1228 | fontStyle = _ref.fontStyle,
|
1229 | fontVariant = _ref.fontVariant,
|
1230 | fontWeight = _ref.fontWeight,
|
1231 | _ref$fileFormats = _ref.fileFormats,
|
1232 | fileFormats = _ref$fileFormats === void 0 ? ['eot', 'woff2', 'woff', 'ttf', 'svg'] : _ref$fileFormats,
|
1233 | _ref$formatHint = _ref.formatHint,
|
1234 | formatHint = _ref$formatHint === void 0 ? false : _ref$formatHint,
|
1235 | localFonts = _ref.localFonts,
|
1236 | unicodeRange = _ref.unicodeRange,
|
1237 | fontDisplay = _ref.fontDisplay,
|
1238 | fontVariationSettings = _ref.fontVariationSettings,
|
1239 | fontFeatureSettings = _ref.fontFeatureSettings;
|
1240 |
|
1241 | if (!fontFamily) throw new PolishedError(55);
|
1242 |
|
1243 | if (!fontFilePath && !localFonts) {
|
1244 | throw new PolishedError(52);
|
1245 | }
|
1246 |
|
1247 | if (localFonts && !Array.isArray(localFonts)) {
|
1248 | throw new PolishedError(53);
|
1249 | }
|
1250 |
|
1251 | if (!Array.isArray(fileFormats)) {
|
1252 | throw new PolishedError(54);
|
1253 | }
|
1254 |
|
1255 | var fontFaceDeclaration = {
|
1256 | '@font-face': {
|
1257 | fontFamily: fontFamily,
|
1258 | src: generateSources(fontFilePath, localFonts, fileFormats, formatHint),
|
1259 | unicodeRange: unicodeRange,
|
1260 | fontStretch: fontStretch,
|
1261 | fontStyle: fontStyle,
|
1262 | fontVariant: fontVariant,
|
1263 | fontWeight: fontWeight,
|
1264 | fontDisplay: fontDisplay,
|
1265 | fontVariationSettings: fontVariationSettings,
|
1266 | fontFeatureSettings: fontFeatureSettings
|
1267 | }
|
1268 | };
|
1269 |
|
1270 | return JSON.parse(JSON.stringify(fontFaceDeclaration));
|
1271 | }
|
1272 |
|
1273 | |
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 | function hideText() {
|
1299 | return {
|
1300 | textIndent: '101%',
|
1301 | overflow: 'hidden',
|
1302 | whiteSpace: 'nowrap'
|
1303 | };
|
1304 | }
|
1305 |
|
1306 | |
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 | function hideVisually() {
|
1336 | return {
|
1337 | border: '0',
|
1338 | clip: 'rect(0 0 0 0)',
|
1339 | height: '1px',
|
1340 | margin: '-1px',
|
1341 | overflow: 'hidden',
|
1342 | padding: '0',
|
1343 | position: 'absolute',
|
1344 | whiteSpace: 'nowrap',
|
1345 | width: '1px'
|
1346 | };
|
1347 | }
|
1348 |
|
1349 | |
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 | function hiDPI(ratio) {
|
1378 | if (ratio === void 0) {
|
1379 | ratio = 1.3;
|
1380 | }
|
1381 |
|
1382 | return "\n @media only screen and (-webkit-min-device-pixel-ratio: " + ratio + "),\n only screen and (min--moz-device-pixel-ratio: " + ratio + "),\n only screen and (-o-min-device-pixel-ratio: " + ratio + "/1),\n only screen and (min-resolution: " + Math.round(ratio * 96) + "dpi),\n only screen and (min-resolution: " + ratio + "dppx)\n ";
|
1383 | }
|
1384 |
|
1385 | function constructGradientValue(literals) {
|
1386 | var template = '';
|
1387 |
|
1388 | for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1389 | substitutions[_key - 1] = arguments[_key];
|
1390 | }
|
1391 |
|
1392 | for (var i = 0; i < literals.length; i += 1) {
|
1393 | template += literals[i];
|
1394 |
|
1395 | if (i === substitutions.length - 1 && substitutions[i]) {
|
1396 | var definedValues = substitutions.filter(function (substitute) {
|
1397 | return !!substitute;
|
1398 | });
|
1399 |
|
1400 | if (definedValues.length > 1) {
|
1401 | template = template.slice(0, -1);
|
1402 | template += ", " + substitutions[i];
|
1403 | } else if (definedValues.length === 1) {
|
1404 | template += "" + substitutions[i];
|
1405 | }
|
1406 | } else if (substitutions[i]) {
|
1407 | template += substitutions[i] + " ";
|
1408 | }
|
1409 | }
|
1410 |
|
1411 | return template.trim();
|
1412 | }
|
1413 |
|
1414 | function _templateObject() {
|
1415 | var data = _taggedTemplateLiteralLoose(["linear-gradient(", "", ")"]);
|
1416 |
|
1417 | _templateObject = function _templateObject() {
|
1418 | return data;
|
1419 | };
|
1420 |
|
1421 | return data;
|
1422 | }
|
1423 |
|
1424 | |
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 | function linearGradient(_ref) {
|
1454 | var colorStops = _ref.colorStops,
|
1455 | fallback = _ref.fallback,
|
1456 | _ref$toDirection = _ref.toDirection,
|
1457 | toDirection = _ref$toDirection === void 0 ? '' : _ref$toDirection;
|
1458 |
|
1459 | if (!colorStops || colorStops.length < 2) {
|
1460 | throw new PolishedError(56);
|
1461 | }
|
1462 |
|
1463 | return {
|
1464 | backgroundColor: fallback || colorStops[0].split(' ')[0],
|
1465 | backgroundImage: constructGradientValue(_templateObject(), toDirection, colorStops.join(', '))
|
1466 | };
|
1467 | }
|
1468 |
|
1469 | |
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 | function normalize() {
|
1489 | var _ref;
|
1490 |
|
1491 | return [(_ref = {
|
1492 | html: {
|
1493 | lineHeight: '1.15',
|
1494 | textSizeAdjust: '100%'
|
1495 | },
|
1496 | body: {
|
1497 | margin: '0'
|
1498 | },
|
1499 | h1: {
|
1500 | fontSize: '2em',
|
1501 | margin: '0.67em 0'
|
1502 | },
|
1503 | hr: {
|
1504 | boxSizing: 'content-box',
|
1505 | height: '0',
|
1506 | overflow: 'visible'
|
1507 | },
|
1508 | pre: {
|
1509 | fontFamily: 'monospace, monospace',
|
1510 | fontSize: '1em'
|
1511 | },
|
1512 | a: {
|
1513 | backgroundColor: 'transparent'
|
1514 | },
|
1515 | 'abbr[title]': {
|
1516 | borderBottom: 'none',
|
1517 | textDecoration: 'underline'
|
1518 | }
|
1519 | }, _ref["b,\n strong"] = {
|
1520 | fontWeight: 'bolder'
|
1521 | }, _ref["code,\n kbd,\n samp"] = {
|
1522 | fontFamily: 'monospace, monospace',
|
1523 | fontSize: '1em'
|
1524 | }, _ref.small = {
|
1525 | fontSize: '80%'
|
1526 | }, _ref["sub,\n sup"] = {
|
1527 | fontSize: '75%',
|
1528 | lineHeight: '0',
|
1529 | position: 'relative',
|
1530 | verticalAlign: 'baseline'
|
1531 | }, _ref.sub = {
|
1532 | bottom: '-0.25em'
|
1533 | }, _ref.sup = {
|
1534 | top: '-0.5em'
|
1535 | }, _ref.img = {
|
1536 | borderStyle: 'none'
|
1537 | }, _ref["button,\n input,\n optgroup,\n select,\n textarea"] = {
|
1538 | fontFamily: 'inherit',
|
1539 | fontSize: '100%',
|
1540 | lineHeight: '1.15',
|
1541 | margin: '0'
|
1542 | }, _ref["button,\n input"] = {
|
1543 | overflow: 'visible'
|
1544 | }, _ref["button,\n select"] = {
|
1545 | textTransform: 'none'
|
1546 | }, _ref["button,\n html [type=\"button\"],\n [type=\"reset\"],\n [type=\"submit\"]"] = {
|
1547 | WebkitAppearance: 'button'
|
1548 | }, _ref["button::-moz-focus-inner,\n [type=\"button\"]::-moz-focus-inner,\n [type=\"reset\"]::-moz-focus-inner,\n [type=\"submit\"]::-moz-focus-inner"] = {
|
1549 | borderStyle: 'none',
|
1550 | padding: '0'
|
1551 | }, _ref["button:-moz-focusring,\n [type=\"button\"]:-moz-focusring,\n [type=\"reset\"]:-moz-focusring,\n [type=\"submit\"]:-moz-focusring"] = {
|
1552 | outline: '1px dotted ButtonText'
|
1553 | }, _ref.fieldset = {
|
1554 | padding: '0.35em 0.625em 0.75em'
|
1555 | }, _ref.legend = {
|
1556 | boxSizing: 'border-box',
|
1557 | color: 'inherit',
|
1558 | display: 'table',
|
1559 | maxWidth: '100%',
|
1560 | padding: '0',
|
1561 | whiteSpace: 'normal'
|
1562 | }, _ref.progress = {
|
1563 | verticalAlign: 'baseline'
|
1564 | }, _ref.textarea = {
|
1565 | overflow: 'auto'
|
1566 | }, _ref["[type=\"checkbox\"],\n [type=\"radio\"]"] = {
|
1567 | boxSizing: 'border-box',
|
1568 | padding: '0'
|
1569 | }, _ref["[type=\"number\"]::-webkit-inner-spin-button,\n [type=\"number\"]::-webkit-outer-spin-button"] = {
|
1570 | height: 'auto'
|
1571 | }, _ref['[type="search"]'] = {
|
1572 | WebkitAppearance: 'textfield',
|
1573 | outlineOffset: '-2px'
|
1574 | }, _ref['[type="search"]::-webkit-search-decoration'] = {
|
1575 | WebkitAppearance: 'none'
|
1576 | }, _ref['::-webkit-file-upload-button'] = {
|
1577 | WebkitAppearance: 'button',
|
1578 | font: 'inherit'
|
1579 | }, _ref.details = {
|
1580 | display: 'block'
|
1581 | }, _ref.summary = {
|
1582 | display: 'list-item'
|
1583 | }, _ref.template = {
|
1584 | display: 'none'
|
1585 | }, _ref['[hidden]'] = {
|
1586 | display: 'none'
|
1587 | }, _ref), {
|
1588 | 'abbr[title]': {
|
1589 | textDecoration: 'underline dotted'
|
1590 | }
|
1591 | }];
|
1592 | }
|
1593 |
|
1594 | function _templateObject$1() {
|
1595 | var data = _taggedTemplateLiteralLoose(["radial-gradient(", "", "", "", ")"]);
|
1596 |
|
1597 | _templateObject$1 = function _templateObject() {
|
1598 | return data;
|
1599 | };
|
1600 |
|
1601 | return data;
|
1602 | }
|
1603 |
|
1604 | |
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 | function radialGradient(_ref) {
|
1636 | var colorStops = _ref.colorStops,
|
1637 | _ref$extent = _ref.extent,
|
1638 | extent = _ref$extent === void 0 ? '' : _ref$extent,
|
1639 | fallback = _ref.fallback,
|
1640 | _ref$position = _ref.position,
|
1641 | position = _ref$position === void 0 ? '' : _ref$position,
|
1642 | _ref$shape = _ref.shape,
|
1643 | shape = _ref$shape === void 0 ? '' : _ref$shape;
|
1644 |
|
1645 | if (!colorStops || colorStops.length < 2) {
|
1646 | throw new PolishedError(57);
|
1647 | }
|
1648 |
|
1649 | return {
|
1650 | backgroundColor: fallback || colorStops[0].split(' ')[0],
|
1651 | backgroundImage: constructGradientValue(_templateObject$1(), position, shape, extent, colorStops.join(', '))
|
1652 | };
|
1653 | }
|
1654 |
|
1655 | |
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 | function retinaImage(filename, backgroundSize, extension, retinaFilename, retinaSuffix) {
|
1684 | var _ref;
|
1685 |
|
1686 | if (extension === void 0) {
|
1687 | extension = 'png';
|
1688 | }
|
1689 |
|
1690 | if (retinaSuffix === void 0) {
|
1691 | retinaSuffix = '_2x';
|
1692 | }
|
1693 |
|
1694 | if (!filename) {
|
1695 | throw new PolishedError(58);
|
1696 | }
|
1697 |
|
1698 |
|
1699 | var ext = extension.replace(/^\./, '');
|
1700 | var rFilename = retinaFilename ? retinaFilename + "." + ext : "" + filename + retinaSuffix + "." + ext;
|
1701 | return _ref = {
|
1702 | backgroundImage: "url(" + filename + "." + ext + ")"
|
1703 | }, _ref[hiDPI()] = _extends({
|
1704 | backgroundImage: "url(" + rFilename + ")"
|
1705 | }, backgroundSize ? {
|
1706 | backgroundSize: backgroundSize
|
1707 | } : {}), _ref;
|
1708 | }
|
1709 |
|
1710 |
|
1711 | var functionsMap = {
|
1712 | easeInBack: 'cubic-bezier(0.600, -0.280, 0.735, 0.045)',
|
1713 | easeInCirc: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)',
|
1714 | easeInCubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)',
|
1715 | easeInExpo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)',
|
1716 | easeInQuad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
|
1717 | easeInQuart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)',
|
1718 | easeInQuint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)',
|
1719 | easeInSine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)',
|
1720 | easeOutBack: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
|
1721 | easeOutCubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
1722 | easeOutCirc: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)',
|
1723 | easeOutExpo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)',
|
1724 | easeOutQuad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
|
1725 | easeOutQuart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
|
1726 | easeOutQuint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)',
|
1727 | easeOutSine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)',
|
1728 | easeInOutBack: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)',
|
1729 | easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)',
|
1730 | easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)',
|
1731 | easeInOutExpo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)',
|
1732 | easeInOutQuad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)',
|
1733 | easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)',
|
1734 | easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)',
|
1735 | easeInOutSine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)'
|
1736 | };
|
1737 |
|
1738 |
|
1739 | function getTimingFunction(functionName) {
|
1740 | return functionsMap[functionName];
|
1741 | }
|
1742 | |
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 | function timingFunctions(timingFunction) {
|
1765 | return getTimingFunction(timingFunction);
|
1766 | }
|
1767 |
|
1768 | var getBorderWidth = function getBorderWidth(pointingDirection, height, width) {
|
1769 | var fullWidth = "" + width[0] + (width[1] || '');
|
1770 | var halfWidth = "" + width[0] / 2 + (width[1] || '');
|
1771 | var fullHeight = "" + height[0] + (height[1] || '');
|
1772 | var halfHeight = "" + height[0] / 2 + (height[1] || '');
|
1773 |
|
1774 | switch (pointingDirection) {
|
1775 | case 'top':
|
1776 | return "0 " + halfWidth + " " + fullHeight + " " + halfWidth;
|
1777 |
|
1778 | case 'topLeft':
|
1779 | return fullWidth + " " + fullHeight + " 0 0";
|
1780 |
|
1781 | case 'left':
|
1782 | return halfHeight + " " + fullWidth + " " + halfHeight + " 0";
|
1783 |
|
1784 | case 'bottomLeft':
|
1785 | return fullWidth + " 0 0 " + fullHeight;
|
1786 |
|
1787 | case 'bottom':
|
1788 | return fullHeight + " " + halfWidth + " 0 " + halfWidth;
|
1789 |
|
1790 | case 'bottomRight':
|
1791 | return "0 0 " + fullWidth + " " + fullHeight;
|
1792 |
|
1793 | case 'right':
|
1794 | return halfHeight + " 0 " + halfHeight + " " + fullWidth;
|
1795 |
|
1796 | case 'topRight':
|
1797 | default:
|
1798 | return "0 " + fullWidth + " " + fullHeight + " 0";
|
1799 | }
|
1800 | };
|
1801 |
|
1802 | var getBorderColor = function getBorderColor(pointingDirection, foregroundColor, backgroundColor) {
|
1803 | switch (pointingDirection) {
|
1804 | case 'top':
|
1805 | case 'bottomRight':
|
1806 | return backgroundColor + " " + backgroundColor + " " + foregroundColor + " " + backgroundColor;
|
1807 |
|
1808 | case 'right':
|
1809 | case 'bottomLeft':
|
1810 | return backgroundColor + " " + backgroundColor + " " + backgroundColor + " " + foregroundColor;
|
1811 |
|
1812 | case 'bottom':
|
1813 | case 'topLeft':
|
1814 | return foregroundColor + " " + backgroundColor + " " + backgroundColor + " " + backgroundColor;
|
1815 |
|
1816 | case 'left':
|
1817 | case 'topRight':
|
1818 | return backgroundColor + " " + foregroundColor + " " + backgroundColor + " " + backgroundColor;
|
1819 |
|
1820 | default:
|
1821 | throw new PolishedError(59);
|
1822 | }
|
1823 | };
|
1824 | |
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 | function triangle(_ref) {
|
1853 | var pointingDirection = _ref.pointingDirection,
|
1854 | height = _ref.height,
|
1855 | width = _ref.width,
|
1856 | foregroundColor = _ref.foregroundColor,
|
1857 | _ref$backgroundColor = _ref.backgroundColor,
|
1858 | backgroundColor = _ref$backgroundColor === void 0 ? 'transparent' : _ref$backgroundColor;
|
1859 | var widthAndUnit = getValueAndUnit(width);
|
1860 | var heightAndUnit = getValueAndUnit(height);
|
1861 |
|
1862 | if (isNaN(heightAndUnit[0]) || isNaN(widthAndUnit[0])) {
|
1863 | throw new PolishedError(60);
|
1864 | }
|
1865 |
|
1866 | return {
|
1867 | width: '0',
|
1868 | height: '0',
|
1869 | borderColor: getBorderColor(pointingDirection, foregroundColor, backgroundColor),
|
1870 | borderStyle: 'solid',
|
1871 | borderWidth: getBorderWidth(pointingDirection, heightAndUnit, widthAndUnit)
|
1872 | };
|
1873 | }
|
1874 |
|
1875 | |
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 | function wordWrap(wrap) {
|
1898 | if (wrap === void 0) {
|
1899 | wrap = 'break-word';
|
1900 | }
|
1901 |
|
1902 | var wordBreak = wrap === 'break-word' ? 'break-all' : wrap;
|
1903 | return {
|
1904 | overflowWrap: wrap,
|
1905 | wordWrap: wrap,
|
1906 | wordBreak: wordBreak
|
1907 | };
|
1908 | }
|
1909 |
|
1910 | function colorToInt(color) {
|
1911 | return Math.round(color * 255);
|
1912 | }
|
1913 |
|
1914 | function convertToInt(red, green, blue) {
|
1915 | return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
1916 | }
|
1917 |
|
1918 | function hslToRgb(hue, saturation, lightness, convert) {
|
1919 | if (convert === void 0) {
|
1920 | convert = convertToInt;
|
1921 | }
|
1922 |
|
1923 | if (saturation === 0) {
|
1924 |
|
1925 | return convert(lightness, lightness, lightness);
|
1926 | }
|
1927 |
|
1928 |
|
1929 | var huePrime = (hue % 360 + 360) % 360 / 60;
|
1930 | var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
1931 | var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
1932 | var red = 0;
|
1933 | var green = 0;
|
1934 | var blue = 0;
|
1935 |
|
1936 | if (huePrime >= 0 && huePrime < 1) {
|
1937 | red = chroma;
|
1938 | green = secondComponent;
|
1939 | } else if (huePrime >= 1 && huePrime < 2) {
|
1940 | red = secondComponent;
|
1941 | green = chroma;
|
1942 | } else if (huePrime >= 2 && huePrime < 3) {
|
1943 | green = chroma;
|
1944 | blue = secondComponent;
|
1945 | } else if (huePrime >= 3 && huePrime < 4) {
|
1946 | green = secondComponent;
|
1947 | blue = chroma;
|
1948 | } else if (huePrime >= 4 && huePrime < 5) {
|
1949 | red = secondComponent;
|
1950 | blue = chroma;
|
1951 | } else if (huePrime >= 5 && huePrime < 6) {
|
1952 | red = chroma;
|
1953 | blue = secondComponent;
|
1954 | }
|
1955 |
|
1956 | var lightnessModification = lightness - chroma / 2;
|
1957 | var finalRed = red + lightnessModification;
|
1958 | var finalGreen = green + lightnessModification;
|
1959 | var finalBlue = blue + lightnessModification;
|
1960 | return convert(finalRed, finalGreen, finalBlue);
|
1961 | }
|
1962 |
|
1963 | var namedColorMap = {
|
1964 | aliceblue: 'f0f8ff',
|
1965 | antiquewhite: 'faebd7',
|
1966 | aqua: '00ffff',
|
1967 | aquamarine: '7fffd4',
|
1968 | azure: 'f0ffff',
|
1969 | beige: 'f5f5dc',
|
1970 | bisque: 'ffe4c4',
|
1971 | black: '000',
|
1972 | blanchedalmond: 'ffebcd',
|
1973 | blue: '0000ff',
|
1974 | blueviolet: '8a2be2',
|
1975 | brown: 'a52a2a',
|
1976 | burlywood: 'deb887',
|
1977 | cadetblue: '5f9ea0',
|
1978 | chartreuse: '7fff00',
|
1979 | chocolate: 'd2691e',
|
1980 | coral: 'ff7f50',
|
1981 | cornflowerblue: '6495ed',
|
1982 | cornsilk: 'fff8dc',
|
1983 | crimson: 'dc143c',
|
1984 | cyan: '00ffff',
|
1985 | darkblue: '00008b',
|
1986 | darkcyan: '008b8b',
|
1987 | darkgoldenrod: 'b8860b',
|
1988 | darkgray: 'a9a9a9',
|
1989 | darkgreen: '006400',
|
1990 | darkgrey: 'a9a9a9',
|
1991 | darkkhaki: 'bdb76b',
|
1992 | darkmagenta: '8b008b',
|
1993 | darkolivegreen: '556b2f',
|
1994 | darkorange: 'ff8c00',
|
1995 | darkorchid: '9932cc',
|
1996 | darkred: '8b0000',
|
1997 | darksalmon: 'e9967a',
|
1998 | darkseagreen: '8fbc8f',
|
1999 | darkslateblue: '483d8b',
|
2000 | darkslategray: '2f4f4f',
|
2001 | darkslategrey: '2f4f4f',
|
2002 | darkturquoise: '00ced1',
|
2003 | darkviolet: '9400d3',
|
2004 | deeppink: 'ff1493',
|
2005 | deepskyblue: '00bfff',
|
2006 | dimgray: '696969',
|
2007 | dimgrey: '696969',
|
2008 | dodgerblue: '1e90ff',
|
2009 | firebrick: 'b22222',
|
2010 | floralwhite: 'fffaf0',
|
2011 | forestgreen: '228b22',
|
2012 | fuchsia: 'ff00ff',
|
2013 | gainsboro: 'dcdcdc',
|
2014 | ghostwhite: 'f8f8ff',
|
2015 | gold: 'ffd700',
|
2016 | goldenrod: 'daa520',
|
2017 | gray: '808080',
|
2018 | green: '008000',
|
2019 | greenyellow: 'adff2f',
|
2020 | grey: '808080',
|
2021 | honeydew: 'f0fff0',
|
2022 | hotpink: 'ff69b4',
|
2023 | indianred: 'cd5c5c',
|
2024 | indigo: '4b0082',
|
2025 | ivory: 'fffff0',
|
2026 | khaki: 'f0e68c',
|
2027 | lavender: 'e6e6fa',
|
2028 | lavenderblush: 'fff0f5',
|
2029 | lawngreen: '7cfc00',
|
2030 | lemonchiffon: 'fffacd',
|
2031 | lightblue: 'add8e6',
|
2032 | lightcoral: 'f08080',
|
2033 | lightcyan: 'e0ffff',
|
2034 | lightgoldenrodyellow: 'fafad2',
|
2035 | lightgray: 'd3d3d3',
|
2036 | lightgreen: '90ee90',
|
2037 | lightgrey: 'd3d3d3',
|
2038 | lightpink: 'ffb6c1',
|
2039 | lightsalmon: 'ffa07a',
|
2040 | lightseagreen: '20b2aa',
|
2041 | lightskyblue: '87cefa',
|
2042 | lightslategray: '789',
|
2043 | lightslategrey: '789',
|
2044 | lightsteelblue: 'b0c4de',
|
2045 | lightyellow: 'ffffe0',
|
2046 | lime: '0f0',
|
2047 | limegreen: '32cd32',
|
2048 | linen: 'faf0e6',
|
2049 | magenta: 'f0f',
|
2050 | maroon: '800000',
|
2051 | mediumaquamarine: '66cdaa',
|
2052 | mediumblue: '0000cd',
|
2053 | mediumorchid: 'ba55d3',
|
2054 | mediumpurple: '9370db',
|
2055 | mediumseagreen: '3cb371',
|
2056 | mediumslateblue: '7b68ee',
|
2057 | mediumspringgreen: '00fa9a',
|
2058 | mediumturquoise: '48d1cc',
|
2059 | mediumvioletred: 'c71585',
|
2060 | midnightblue: '191970',
|
2061 | mintcream: 'f5fffa',
|
2062 | mistyrose: 'ffe4e1',
|
2063 | moccasin: 'ffe4b5',
|
2064 | navajowhite: 'ffdead',
|
2065 | navy: '000080',
|
2066 | oldlace: 'fdf5e6',
|
2067 | olive: '808000',
|
2068 | olivedrab: '6b8e23',
|
2069 | orange: 'ffa500',
|
2070 | orangered: 'ff4500',
|
2071 | orchid: 'da70d6',
|
2072 | palegoldenrod: 'eee8aa',
|
2073 | palegreen: '98fb98',
|
2074 | paleturquoise: 'afeeee',
|
2075 | palevioletred: 'db7093',
|
2076 | papayawhip: 'ffefd5',
|
2077 | peachpuff: 'ffdab9',
|
2078 | peru: 'cd853f',
|
2079 | pink: 'ffc0cb',
|
2080 | plum: 'dda0dd',
|
2081 | powderblue: 'b0e0e6',
|
2082 | purple: '800080',
|
2083 | rebeccapurple: '639',
|
2084 | red: 'f00',
|
2085 | rosybrown: 'bc8f8f',
|
2086 | royalblue: '4169e1',
|
2087 | saddlebrown: '8b4513',
|
2088 | salmon: 'fa8072',
|
2089 | sandybrown: 'f4a460',
|
2090 | seagreen: '2e8b57',
|
2091 | seashell: 'fff5ee',
|
2092 | sienna: 'a0522d',
|
2093 | silver: 'c0c0c0',
|
2094 | skyblue: '87ceeb',
|
2095 | slateblue: '6a5acd',
|
2096 | slategray: '708090',
|
2097 | slategrey: '708090',
|
2098 | snow: 'fffafa',
|
2099 | springgreen: '00ff7f',
|
2100 | steelblue: '4682b4',
|
2101 | tan: 'd2b48c',
|
2102 | teal: '008080',
|
2103 | thistle: 'd8bfd8',
|
2104 | tomato: 'ff6347',
|
2105 | turquoise: '40e0d0',
|
2106 | violet: 'ee82ee',
|
2107 | wheat: 'f5deb3',
|
2108 | white: 'fff',
|
2109 | whitesmoke: 'f5f5f5',
|
2110 | yellow: 'ff0',
|
2111 | yellowgreen: '9acd32'
|
2112 | };
|
2113 | |
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 | function nameToHex(color) {
|
2119 | if (typeof color !== 'string') return color;
|
2120 | var normalizedColorName = color.toLowerCase();
|
2121 | return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
2122 | }
|
2123 |
|
2124 | var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
2125 | var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
2126 | var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
2127 | var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
2128 | var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
|
2129 | 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;
|
2130 | 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;
|
2131 | 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;
|
2132 | |
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 | function parseToRgb(color) {
|
2145 | if (typeof color !== 'string') {
|
2146 | throw new PolishedError(3);
|
2147 | }
|
2148 |
|
2149 | var normalizedColor = nameToHex(color);
|
2150 |
|
2151 | if (normalizedColor.match(hexRegex)) {
|
2152 | return {
|
2153 | red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
2154 | green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
2155 | blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
2156 | };
|
2157 | }
|
2158 |
|
2159 | if (normalizedColor.match(hexRgbaRegex)) {
|
2160 | var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
2161 | return {
|
2162 | red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
2163 | green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
2164 | blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
2165 | alpha: alpha
|
2166 | };
|
2167 | }
|
2168 |
|
2169 | if (normalizedColor.match(reducedHexRegex)) {
|
2170 | return {
|
2171 | red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
2172 | green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
2173 | blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
2174 | };
|
2175 | }
|
2176 |
|
2177 | if (normalizedColor.match(reducedRgbaHexRegex)) {
|
2178 | var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
2179 |
|
2180 | return {
|
2181 | red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
2182 | green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
2183 | blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
2184 | alpha: _alpha
|
2185 | };
|
2186 | }
|
2187 |
|
2188 | var rgbMatched = rgbRegex.exec(normalizedColor);
|
2189 |
|
2190 | if (rgbMatched) {
|
2191 | return {
|
2192 | red: parseInt("" + rgbMatched[1], 10),
|
2193 | green: parseInt("" + rgbMatched[2], 10),
|
2194 | blue: parseInt("" + rgbMatched[3], 10)
|
2195 | };
|
2196 | }
|
2197 |
|
2198 | var rgbaMatched = rgbaRegex.exec(normalizedColor);
|
2199 |
|
2200 | if (rgbaMatched) {
|
2201 | return {
|
2202 | red: parseInt("" + rgbaMatched[1], 10),
|
2203 | green: parseInt("" + rgbaMatched[2], 10),
|
2204 | blue: parseInt("" + rgbaMatched[3], 10),
|
2205 | alpha: parseFloat("" + rgbaMatched[4])
|
2206 | };
|
2207 | }
|
2208 |
|
2209 | var hslMatched = hslRegex.exec(normalizedColor);
|
2210 |
|
2211 | if (hslMatched) {
|
2212 | var hue = parseInt("" + hslMatched[1], 10);
|
2213 | var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
2214 | var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
2215 | var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
2216 | var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
2217 |
|
2218 | if (!hslRgbMatched) {
|
2219 | throw new PolishedError(4, normalizedColor, rgbColorString);
|
2220 | }
|
2221 |
|
2222 | return {
|
2223 | red: parseInt("" + hslRgbMatched[1], 10),
|
2224 | green: parseInt("" + hslRgbMatched[2], 10),
|
2225 | blue: parseInt("" + hslRgbMatched[3], 10)
|
2226 | };
|
2227 | }
|
2228 |
|
2229 | var hslaMatched = hslaRegex.exec(normalizedColor);
|
2230 |
|
2231 | if (hslaMatched) {
|
2232 | var _hue = parseInt("" + hslaMatched[1], 10);
|
2233 |
|
2234 | var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
2235 |
|
2236 | var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
2237 |
|
2238 | var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
2239 |
|
2240 | var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
2241 |
|
2242 | if (!_hslRgbMatched) {
|
2243 | throw new PolishedError(4, normalizedColor, _rgbColorString);
|
2244 | }
|
2245 |
|
2246 | return {
|
2247 | red: parseInt("" + _hslRgbMatched[1], 10),
|
2248 | green: parseInt("" + _hslRgbMatched[2], 10),
|
2249 | blue: parseInt("" + _hslRgbMatched[3], 10),
|
2250 | alpha: parseFloat("" + hslaMatched[4])
|
2251 | };
|
2252 | }
|
2253 |
|
2254 | throw new PolishedError(5);
|
2255 | }
|
2256 |
|
2257 | function rgbToHsl(color) {
|
2258 |
|
2259 | var red = color.red / 255;
|
2260 | var green = color.green / 255;
|
2261 | var blue = color.blue / 255;
|
2262 | var max = Math.max(red, green, blue);
|
2263 | var min = Math.min(red, green, blue);
|
2264 | var lightness = (max + min) / 2;
|
2265 |
|
2266 | if (max === min) {
|
2267 |
|
2268 | if (color.alpha !== undefined) {
|
2269 | return {
|
2270 | hue: 0,
|
2271 | saturation: 0,
|
2272 | lightness: lightness,
|
2273 | alpha: color.alpha
|
2274 | };
|
2275 | } else {
|
2276 | return {
|
2277 | hue: 0,
|
2278 | saturation: 0,
|
2279 | lightness: lightness
|
2280 | };
|
2281 | }
|
2282 | }
|
2283 |
|
2284 | var hue;
|
2285 | var delta = max - min;
|
2286 | var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
2287 |
|
2288 | switch (max) {
|
2289 | case red:
|
2290 | hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
2291 | break;
|
2292 |
|
2293 | case green:
|
2294 | hue = (blue - red) / delta + 2;
|
2295 | break;
|
2296 |
|
2297 | default:
|
2298 |
|
2299 | hue = (red - green) / delta + 4;
|
2300 | break;
|
2301 | }
|
2302 |
|
2303 | hue *= 60;
|
2304 |
|
2305 | if (color.alpha !== undefined) {
|
2306 | return {
|
2307 | hue: hue,
|
2308 | saturation: saturation,
|
2309 | lightness: lightness,
|
2310 | alpha: color.alpha
|
2311 | };
|
2312 | }
|
2313 |
|
2314 | return {
|
2315 | hue: hue,
|
2316 | saturation: saturation,
|
2317 | lightness: lightness
|
2318 | };
|
2319 | }
|
2320 |
|
2321 | |
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 | function parseToHsl(color) {
|
2333 |
|
2334 |
|
2335 | return rgbToHsl(parseToRgb(color));
|
2336 | }
|
2337 |
|
2338 | |
2339 |
|
2340 |
|
2341 |
|
2342 | var reduceHexValue = function reduceHexValue(value) {
|
2343 | if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
2344 | return "#" + value[1] + value[3] + value[5];
|
2345 | }
|
2346 |
|
2347 | return value;
|
2348 | };
|
2349 |
|
2350 | function numberToHex(value) {
|
2351 | var hex = value.toString(16);
|
2352 | return hex.length === 1 ? "0" + hex : hex;
|
2353 | }
|
2354 |
|
2355 | function colorToHex(color) {
|
2356 | return numberToHex(Math.round(color * 255));
|
2357 | }
|
2358 |
|
2359 | function convertToHex(red, green, blue) {
|
2360 | return reduceHexValue("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
2361 | }
|
2362 |
|
2363 | function hslToHex(hue, saturation, lightness) {
|
2364 | return hslToRgb(hue, saturation, lightness, convertToHex);
|
2365 | }
|
2366 |
|
2367 | |
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 |
|
2390 | function hsl(value, saturation, lightness) {
|
2391 | if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
|
2392 | return hslToHex(value, saturation, lightness);
|
2393 | } else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
|
2394 | return hslToHex(value.hue, value.saturation, value.lightness);
|
2395 | }
|
2396 |
|
2397 | throw new PolishedError(1);
|
2398 | }
|
2399 |
|
2400 | |
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 | function hsla(value, saturation, lightness, alpha) {
|
2427 | if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
|
2428 | return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
|
2429 | } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
2430 | return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
2431 | }
|
2432 |
|
2433 | throw new PolishedError(2);
|
2434 | }
|
2435 |
|
2436 | |
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 |
|
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 |
|
2456 |
|
2457 |
|
2458 |
|
2459 | function rgb(value, green, blue) {
|
2460 | if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
2461 | return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
2462 | } else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
2463 | return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
2464 | }
|
2465 |
|
2466 | throw new PolishedError(6);
|
2467 | }
|
2468 |
|
2469 | |
2470 |
|
2471 |
|
2472 |
|
2473 |
|
2474 |
|
2475 |
|
2476 |
|
2477 |
|
2478 |
|
2479 |
|
2480 |
|
2481 |
|
2482 |
|
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 |
|
2494 |
|
2495 |
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 | function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
2504 | if (typeof firstValue === 'string' && typeof secondValue === 'number') {
|
2505 | var rgbValue = parseToRgb(firstValue);
|
2506 | return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
2507 | } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
|
2508 | return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
2509 | } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
2510 | return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
2511 | }
|
2512 |
|
2513 | throw new PolishedError(7);
|
2514 | }
|
2515 |
|
2516 | var isRgb = function isRgb(color) {
|
2517 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
2518 | };
|
2519 |
|
2520 | var isRgba = function isRgba(color) {
|
2521 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
2522 | };
|
2523 |
|
2524 | var isHsl = function isHsl(color) {
|
2525 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
2526 | };
|
2527 |
|
2528 | var isHsla = function isHsla(color) {
|
2529 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
2530 | };
|
2531 | |
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 |
|
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 |
|
2563 | function toColorString(color) {
|
2564 | if (typeof color !== 'object') throw new PolishedError(8);
|
2565 | if (isRgba(color)) return rgba(color);
|
2566 | if (isRgb(color)) return rgb(color);
|
2567 | if (isHsla(color)) return hsla(color);
|
2568 | if (isHsl(color)) return hsl(color);
|
2569 | throw new PolishedError(8);
|
2570 | }
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 | function curried(f, length, acc) {
|
2577 | return function fn() {
|
2578 |
|
2579 | var combined = acc.concat(Array.prototype.slice.call(arguments));
|
2580 | return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
2581 | };
|
2582 | }
|
2583 |
|
2584 |
|
2585 | function curry(f) {
|
2586 |
|
2587 | return curried(f, f.length, []);
|
2588 | }
|
2589 |
|
2590 | |
2591 |
|
2592 |
|
2593 |
|
2594 |
|
2595 |
|
2596 |
|
2597 |
|
2598 |
|
2599 |
|
2600 |
|
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 |
|
2614 |
|
2615 | function adjustHue(degree, color) {
|
2616 | if (color === 'transparent') return color;
|
2617 | var hslColor = parseToHsl(color);
|
2618 | return toColorString(_extends({}, hslColor, {
|
2619 | hue: hslColor.hue + parseFloat(degree)
|
2620 | }));
|
2621 | }
|
2622 |
|
2623 |
|
2624 | var curriedAdjustHue = curry
|
2625 |
|
2626 | (adjustHue);
|
2627 |
|
2628 | |
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 |
|
2651 | function complement(color) {
|
2652 | if (color === 'transparent') return color;
|
2653 | var hslColor = parseToHsl(color);
|
2654 | return toColorString(_extends({}, hslColor, {
|
2655 | hue: (hslColor.hue + 180) % 360
|
2656 | }));
|
2657 | }
|
2658 |
|
2659 | function guard(lowerBoundary, upperBoundary, value) {
|
2660 | return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
2661 | }
|
2662 |
|
2663 | |
2664 |
|
2665 |
|
2666 |
|
2667 |
|
2668 |
|
2669 |
|
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 | function darken(amount, color) {
|
2688 | if (color === 'transparent') return color;
|
2689 | var hslColor = parseToHsl(color);
|
2690 | return toColorString(_extends({}, hslColor, {
|
2691 | lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
2692 | }));
|
2693 | }
|
2694 |
|
2695 |
|
2696 | var curriedDarken = curry
|
2697 |
|
2698 | (darken);
|
2699 |
|
2700 | |
2701 |
|
2702 |
|
2703 |
|
2704 |
|
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 |
|
2711 |
|
2712 |
|
2713 |
|
2714 |
|
2715 |
|
2716 |
|
2717 |
|
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 | function desaturate(amount, color) {
|
2726 | if (color === 'transparent') return color;
|
2727 | var hslColor = parseToHsl(color);
|
2728 | return toColorString(_extends({}, hslColor, {
|
2729 | saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
2730 | }));
|
2731 | }
|
2732 |
|
2733 |
|
2734 | var curriedDesaturate = curry
|
2735 |
|
2736 | (desaturate);
|
2737 |
|
2738 | |
2739 |
|
2740 |
|
2741 |
|
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 | function getLuminance(color) {
|
2766 | if (color === 'transparent') return 0;
|
2767 | var rgbColor = parseToRgb(color);
|
2768 |
|
2769 | var _Object$keys$map = Object.keys(rgbColor).map(function (key) {
|
2770 | var channel = rgbColor[key] / 255;
|
2771 | return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
2772 | }),
|
2773 | r = _Object$keys$map[0],
|
2774 | g = _Object$keys$map[1],
|
2775 | b = _Object$keys$map[2];
|
2776 |
|
2777 | return parseFloat((0.2126 * r + 0.7152 * g + 0.0722 * b).toFixed(3));
|
2778 | }
|
2779 |
|
2780 | |
2781 |
|
2782 |
|
2783 |
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 | function getContrast(color1, color2) {
|
2789 | var luminance1 = getLuminance(color1);
|
2790 | var luminance2 = getLuminance(color2);
|
2791 | return parseFloat((luminance1 > luminance2 ? (luminance1 + 0.05) / (luminance2 + 0.05) : (luminance2 + 0.05) / (luminance1 + 0.05)).toFixed(2));
|
2792 | }
|
2793 |
|
2794 | |
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 |
|
2807 |
|
2808 |
|
2809 |
|
2810 |
|
2811 |
|
2812 |
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 | function grayscale(color) {
|
2818 | if (color === 'transparent') return color;
|
2819 | return toColorString(_extends({}, parseToHsl(color), {
|
2820 | saturation: 0
|
2821 | }));
|
2822 | }
|
2823 |
|
2824 | |
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 |
|
2833 |
|
2834 |
|
2835 |
|
2836 |
|
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 |
|
2848 | function hslToColorString(color) {
|
2849 | if (typeof color === 'object' && typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number') {
|
2850 | if (color.alpha && typeof color.alpha === 'number') {
|
2851 | return hsla({
|
2852 | hue: color.hue,
|
2853 | saturation: color.saturation,
|
2854 | lightness: color.lightness,
|
2855 | alpha: color.alpha
|
2856 | });
|
2857 | }
|
2858 |
|
2859 | return hsl({
|
2860 | hue: color.hue,
|
2861 | saturation: color.saturation,
|
2862 | lightness: color.lightness
|
2863 | });
|
2864 | }
|
2865 |
|
2866 | throw new PolishedError(45);
|
2867 | }
|
2868 |
|
2869 | |
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 |
|
2883 |
|
2884 |
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 | function invert(color) {
|
2894 | if (color === 'transparent') return color;
|
2895 |
|
2896 | var value = parseToRgb(color);
|
2897 | return toColorString(_extends({}, value, {
|
2898 | red: 255 - value.red,
|
2899 | green: 255 - value.green,
|
2900 | blue: 255 - value.blue
|
2901 | }));
|
2902 | }
|
2903 |
|
2904 | |
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 | function lighten(amount, color) {
|
2929 | if (color === 'transparent') return color;
|
2930 | var hslColor = parseToHsl(color);
|
2931 | return toColorString(_extends({}, hslColor, {
|
2932 | lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
2933 | }));
|
2934 | }
|
2935 |
|
2936 |
|
2937 | var curriedLighten = curry
|
2938 |
|
2939 | (lighten);
|
2940 |
|
2941 | |
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 | function meetsContrastGuidelines(color1, color2) {
|
2949 | var contrastRatio = getContrast(color1, color2);
|
2950 | return {
|
2951 | AA: contrastRatio >= 4.5,
|
2952 | AALarge: contrastRatio >= 3,
|
2953 | AAA: contrastRatio >= 7,
|
2954 | AAALarge: contrastRatio >= 4.5
|
2955 | };
|
2956 | }
|
2957 |
|
2958 | |
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 |
|
2969 |
|
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 |
|
2983 |
|
2984 |
|
2985 | function mix(weight, color, otherColor) {
|
2986 | if (color === 'transparent') return otherColor;
|
2987 | if (otherColor === 'transparent') return color;
|
2988 | if (weight === 0) return otherColor;
|
2989 | var parsedColor1 = parseToRgb(color);
|
2990 |
|
2991 | var color1 = _extends({}, parsedColor1, {
|
2992 | alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
|
2993 | });
|
2994 |
|
2995 | var parsedColor2 = parseToRgb(otherColor);
|
2996 |
|
2997 | var color2 = _extends({}, parsedColor2, {
|
2998 | alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
|
2999 | });
|
3000 |
|
3001 |
|
3002 |
|
3003 | var alphaDelta = color1.alpha - color2.alpha;
|
3004 | var x = parseFloat(weight) * 2 - 1;
|
3005 | var y = x * alphaDelta === -1 ? x : x + alphaDelta;
|
3006 | var z = 1 + x * alphaDelta;
|
3007 | var weight1 = (y / z + 1) / 2.0;
|
3008 | var weight2 = 1 - weight1;
|
3009 | var mixedColor = {
|
3010 | red: Math.floor(color1.red * weight1 + color2.red * weight2),
|
3011 | green: Math.floor(color1.green * weight1 + color2.green * weight2),
|
3012 | blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
|
3013 | alpha: color1.alpha * (parseFloat(weight) / 1.0) + color2.alpha * (1 - parseFloat(weight) / 1.0)
|
3014 | };
|
3015 | return rgba(mixedColor);
|
3016 | }
|
3017 |
|
3018 |
|
3019 | var curriedMix = curry
|
3020 |
|
3021 | (mix);
|
3022 |
|
3023 | |
3024 |
|
3025 |
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 |
|
3034 |
|
3035 |
|
3036 |
|
3037 |
|
3038 |
|
3039 |
|
3040 |
|
3041 |
|
3042 |
|
3043 |
|
3044 |
|
3045 |
|
3046 |
|
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 | function opacify(amount, color) {
|
3052 | if (color === 'transparent') return color;
|
3053 | var parsedColor = parseToRgb(color);
|
3054 | var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
3055 |
|
3056 | var colorWithAlpha = _extends({}, parsedColor, {
|
3057 | alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
3058 | });
|
3059 |
|
3060 | return rgba(colorWithAlpha);
|
3061 | }
|
3062 |
|
3063 |
|
3064 | var curriedOpacify = curry
|
3065 |
|
3066 | (opacify);
|
3067 |
|
3068 | var defaultLightReturnColor = '#000';
|
3069 | var defaultDarkReturnColor = '#fff';
|
3070 | |
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 | function readableColor(color, lightReturnColor, darkReturnColor, strict) {
|
3107 | if (lightReturnColor === void 0) {
|
3108 | lightReturnColor = defaultLightReturnColor;
|
3109 | }
|
3110 |
|
3111 | if (darkReturnColor === void 0) {
|
3112 | darkReturnColor = defaultDarkReturnColor;
|
3113 | }
|
3114 |
|
3115 | if (strict === void 0) {
|
3116 | strict = false;
|
3117 | }
|
3118 |
|
3119 | var isLightColor = getLuminance(color) > 0.179;
|
3120 | var preferredReturnColor = isLightColor ? lightReturnColor : darkReturnColor;
|
3121 |
|
3122 |
|
3123 | if (!strict || getContrast(color, preferredReturnColor) >= 4.5) {
|
3124 | return preferredReturnColor;
|
3125 | }
|
3126 |
|
3127 | return isLightColor ? defaultLightReturnColor : defaultDarkReturnColor;
|
3128 | }
|
3129 |
|
3130 | |
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
3136 |
|
3137 |
|
3138 |
|
3139 |
|
3140 |
|
3141 |
|
3142 |
|
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 |
|
3148 |
|
3149 |
|
3150 |
|
3151 |
|
3152 |
|
3153 |
|
3154 | function rgbToColorString(color) {
|
3155 | if (typeof color === 'object' && typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number') {
|
3156 | if (color.alpha && typeof color.alpha === 'number') {
|
3157 | return rgba({
|
3158 | red: color.red,
|
3159 | green: color.green,
|
3160 | blue: color.blue,
|
3161 | alpha: color.alpha
|
3162 | });
|
3163 | }
|
3164 |
|
3165 | return rgb({
|
3166 | red: color.red,
|
3167 | green: color.green,
|
3168 | blue: color.blue
|
3169 | });
|
3170 | }
|
3171 |
|
3172 | throw new PolishedError(46);
|
3173 | }
|
3174 |
|
3175 | |
3176 |
|
3177 |
|
3178 |
|
3179 |
|
3180 |
|
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 | function saturate(amount, color) {
|
3202 | if (color === 'transparent') return color;
|
3203 | var hslColor = parseToHsl(color);
|
3204 | return toColorString(_extends({}, hslColor, {
|
3205 | saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
3206 | }));
|
3207 | }
|
3208 |
|
3209 |
|
3210 | var curriedSaturate = curry
|
3211 |
|
3212 | (saturate);
|
3213 |
|
3214 | |
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 |
|
3231 |
|
3232 |
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 | function setHue(hue, color) {
|
3239 | if (color === 'transparent') return color;
|
3240 | return toColorString(_extends({}, parseToHsl(color), {
|
3241 | hue: parseFloat(hue)
|
3242 | }));
|
3243 | }
|
3244 |
|
3245 |
|
3246 | var curriedSetHue = curry
|
3247 |
|
3248 | (setHue);
|
3249 |
|
3250 | |
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 |
|
3267 |
|
3268 |
|
3269 |
|
3270 |
|
3271 |
|
3272 |
|
3273 |
|
3274 | function setLightness(lightness, color) {
|
3275 | if (color === 'transparent') return color;
|
3276 | return toColorString(_extends({}, parseToHsl(color), {
|
3277 | lightness: parseFloat(lightness)
|
3278 | }));
|
3279 | }
|
3280 |
|
3281 |
|
3282 | var curriedSetLightness = curry
|
3283 |
|
3284 | (setLightness);
|
3285 |
|
3286 | |
3287 |
|
3288 |
|
3289 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 |
|
3305 |
|
3306 |
|
3307 |
|
3308 |
|
3309 |
|
3310 | function setSaturation(saturation, color) {
|
3311 | if (color === 'transparent') return color;
|
3312 | return toColorString(_extends({}, parseToHsl(color), {
|
3313 | saturation: parseFloat(saturation)
|
3314 | }));
|
3315 | }
|
3316 |
|
3317 |
|
3318 | var curriedSetSaturation = curry
|
3319 |
|
3320 | (setSaturation);
|
3321 |
|
3322 | |
3323 |
|
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 |
|
3332 |
|
3333 |
|
3334 |
|
3335 |
|
3336 |
|
3337 |
|
3338 |
|
3339 |
|
3340 |
|
3341 |
|
3342 |
|
3343 |
|
3344 |
|
3345 | function shade(percentage, color) {
|
3346 | if (color === 'transparent') return color;
|
3347 | return curriedMix(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
3348 | }
|
3349 |
|
3350 |
|
3351 | var curriedShade = curry
|
3352 |
|
3353 | (shade);
|
3354 |
|
3355 | |
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 |
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 |
|
3375 |
|
3376 |
|
3377 |
|
3378 | function tint(percentage, color) {
|
3379 | if (color === 'transparent') return color;
|
3380 | return curriedMix(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
3381 | }
|
3382 |
|
3383 |
|
3384 | var curriedTint = curry
|
3385 |
|
3386 | (tint);
|
3387 |
|
3388 | |
3389 |
|
3390 |
|
3391 |
|
3392 |
|
3393 |
|
3394 |
|
3395 |
|
3396 |
|
3397 |
|
3398 |
|
3399 |
|
3400 |
|
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 |
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 |
|
3412 |
|
3413 |
|
3414 |
|
3415 |
|
3416 | function transparentize(amount, color) {
|
3417 | if (color === 'transparent') return color;
|
3418 | var parsedColor = parseToRgb(color);
|
3419 | var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
3420 |
|
3421 | var colorWithAlpha = _extends({}, parsedColor, {
|
3422 | alpha: guard(0, 1, (alpha * 100 - parseFloat(amount) * 100) / 100)
|
3423 | });
|
3424 |
|
3425 | return rgba(colorWithAlpha);
|
3426 | }
|
3427 |
|
3428 |
|
3429 | var curriedTransparentize = curry
|
3430 |
|
3431 | (transparentize);
|
3432 |
|
3433 | |
3434 |
|
3435 |
|
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 |
|
3443 |
|
3444 |
|
3445 |
|
3446 |
|
3447 |
|
3448 |
|
3449 |
|
3450 |
|
3451 |
|
3452 |
|
3453 |
|
3454 |
|
3455 |
|
3456 |
|
3457 |
|
3458 |
|
3459 |
|
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 |
|
3469 | function animation() {
|
3470 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3471 | args[_key] = arguments[_key];
|
3472 | }
|
3473 |
|
3474 |
|
3475 | var multiMode = Array.isArray(args[0]);
|
3476 |
|
3477 | if (!multiMode && args.length > 8) {
|
3478 | throw new PolishedError(64);
|
3479 | }
|
3480 |
|
3481 | var code = args.map(function (arg) {
|
3482 | if (multiMode && !Array.isArray(arg) || !multiMode && Array.isArray(arg)) {
|
3483 | throw new PolishedError(65);
|
3484 | }
|
3485 |
|
3486 | if (Array.isArray(arg) && arg.length > 8) {
|
3487 | throw new PolishedError(66);
|
3488 | }
|
3489 |
|
3490 | return Array.isArray(arg) ? arg.join(' ') : arg;
|
3491 | }).join(', ');
|
3492 | return {
|
3493 | animation: code
|
3494 | };
|
3495 | }
|
3496 |
|
3497 | |
3498 |
|
3499 |
|
3500 |
|
3501 |
|
3502 |
|
3503 |
|
3504 |
|
3505 |
|
3506 |
|
3507 |
|
3508 |
|
3509 |
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 | function backgroundImages() {
|
3517 | for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
|
3518 | properties[_key] = arguments[_key];
|
3519 | }
|
3520 |
|
3521 | return {
|
3522 | backgroundImage: properties.join(', ')
|
3523 | };
|
3524 | }
|
3525 |
|
3526 | |
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 |
|
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 |
|
3540 |
|
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 | function backgrounds() {
|
3546 | for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
|
3547 | properties[_key] = arguments[_key];
|
3548 | }
|
3549 |
|
3550 | return {
|
3551 | background: properties.join(', ')
|
3552 | };
|
3553 | }
|
3554 |
|
3555 | var sideMap = ['top', 'right', 'bottom', 'left'];
|
3556 | |
3557 |
|
3558 |
|
3559 |
|
3560 |
|
3561 |
|
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 |
|
3568 |
|
3569 |
|
3570 |
|
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 |
|
3577 |
|
3578 |
|
3579 |
|
3580 |
|
3581 |
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 |
|
3593 |
|
3594 |
|
3595 |
|
3596 |
|
3597 | function border(sideKeyword) {
|
3598 | for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
3599 | values[_key - 1] = arguments[_key];
|
3600 | }
|
3601 |
|
3602 | if (typeof sideKeyword === 'string' && sideMap.indexOf(sideKeyword) >= 0) {
|
3603 | var _ref;
|
3604 |
|
3605 | return _ref = {}, _ref["border" + capitalizeString(sideKeyword) + "Width"] = values[0], _ref["border" + capitalizeString(sideKeyword) + "Style"] = values[1], _ref["border" + capitalizeString(sideKeyword) + "Color"] = values[2], _ref;
|
3606 | } else {
|
3607 | values.unshift(sideKeyword);
|
3608 | return {
|
3609 | borderWidth: values[0],
|
3610 | borderStyle: values[1],
|
3611 | borderColor: values[2]
|
3612 | };
|
3613 | }
|
3614 | }
|
3615 |
|
3616 | |
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 |
|
3627 |
|
3628 |
|
3629 |
|
3630 |
|
3631 |
|
3632 |
|
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 | function borderColor() {
|
3639 | for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
3640 | values[_key] = arguments[_key];
|
3641 | }
|
3642 |
|
3643 | return directionalProperty.apply(void 0, ['borderColor'].concat(values));
|
3644 | }
|
3645 |
|
3646 | |
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 |
|
3652 |
|
3653 |
|
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 | function borderRadius(side, radius) {
|
3667 | var uppercaseSide = capitalizeString(side);
|
3668 |
|
3669 | if (!radius && radius !== 0) {
|
3670 | throw new PolishedError(62);
|
3671 | }
|
3672 |
|
3673 | if (uppercaseSide === 'Top' || uppercaseSide === 'Bottom') {
|
3674 | var _ref;
|
3675 |
|
3676 | return _ref = {}, _ref["border" + uppercaseSide + "RightRadius"] = radius, _ref["border" + uppercaseSide + "LeftRadius"] = radius, _ref;
|
3677 | }
|
3678 |
|
3679 | if (uppercaseSide === 'Left' || uppercaseSide === 'Right') {
|
3680 | var _ref2;
|
3681 |
|
3682 | return _ref2 = {}, _ref2["borderTop" + uppercaseSide + "Radius"] = radius, _ref2["borderBottom" + uppercaseSide + "Radius"] = radius, _ref2;
|
3683 | }
|
3684 |
|
3685 | throw new PolishedError(63);
|
3686 | }
|
3687 |
|
3688 | |
3689 |
|
3690 |
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 |
|
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 |
|
3710 | function borderStyle() {
|
3711 | for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
3712 | values[_key] = arguments[_key];
|
3713 | }
|
3714 |
|
3715 | return directionalProperty.apply(void 0, ['borderStyle'].concat(values));
|
3716 | }
|
3717 |
|
3718 | |
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 |
|
3730 |
|
3731 |
|
3732 |
|
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 |
|
3740 | function borderWidth() {
|
3741 | for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
3742 | values[_key] = arguments[_key];
|
3743 | }
|
3744 |
|
3745 | return directionalProperty.apply(void 0, ['borderWidth'].concat(values));
|
3746 | }
|
3747 |
|
3748 | function generateSelectors(template, state) {
|
3749 | var stateSuffix = state ? ":" + state : '';
|
3750 | return template(stateSuffix);
|
3751 | }
|
3752 | |
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 |
|
3758 | function statefulSelectors(states, template, stateMap) {
|
3759 | if (!template) throw new PolishedError(67);
|
3760 | if (states.length === 0) return generateSelectors(template, null);
|
3761 | var selectors = [];
|
3762 |
|
3763 | for (var i = 0; i < states.length; i += 1) {
|
3764 | if (stateMap && stateMap.indexOf(states[i]) < 0) {
|
3765 | throw new PolishedError(68);
|
3766 | }
|
3767 |
|
3768 | selectors.push(generateSelectors(template, states[i]));
|
3769 | }
|
3770 |
|
3771 | selectors = selectors.join(',');
|
3772 | return selectors;
|
3773 | }
|
3774 |
|
3775 | var stateMap = [undefined, null, 'active', 'focus', 'hover'];
|
3776 |
|
3777 | function template(state) {
|
3778 | return "button" + state + ",\n input[type=\"button\"]" + state + ",\n input[type=\"reset\"]" + state + ",\n input[type=\"submit\"]" + state;
|
3779 | }
|
3780 | |
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 |
|
3805 |
|
3806 |
|
3807 |
|
3808 | function buttons() {
|
3809 | for (var _len = arguments.length, states = new Array(_len), _key = 0; _key < _len; _key++) {
|
3810 | states[_key] = arguments[_key];
|
3811 | }
|
3812 |
|
3813 | return statefulSelectors(states, template, stateMap);
|
3814 | }
|
3815 |
|
3816 | |
3817 |
|
3818 |
|
3819 |
|
3820 |
|
3821 |
|
3822 |
|
3823 |
|
3824 |
|
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 |
|
3836 |
|
3837 |
|
3838 | function margin() {
|
3839 | for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
3840 | values[_key] = arguments[_key];
|
3841 | }
|
3842 |
|
3843 | return directionalProperty.apply(void 0, ['margin'].concat(values));
|
3844 | }
|
3845 |
|
3846 | |
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 |
|
3852 |
|
3853 |
|
3854 |
|
3855 |
|
3856 |
|
3857 |
|
3858 |
|
3859 |
|
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 | function padding() {
|
3869 | for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
3870 | values[_key] = arguments[_key];
|
3871 | }
|
3872 |
|
3873 | return directionalProperty.apply(void 0, ['padding'].concat(values));
|
3874 | }
|
3875 |
|
3876 | var positionMap$1 = ['absolute', 'fixed', 'relative', 'static', 'sticky'];
|
3877 | |
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 |
|
3890 |
|
3891 |
|
3892 |
|
3893 |
|
3894 |
|
3895 |
|
3896 |
|
3897 |
|
3898 |
|
3899 |
|
3900 |
|
3901 |
|
3902 |
|
3903 |
|
3904 |
|
3905 |
|
3906 |
|
3907 |
|
3908 |
|
3909 |
|
3910 |
|
3911 |
|
3912 |
|
3913 |
|
3914 |
|
3915 |
|
3916 |
|
3917 |
|
3918 |
|
3919 |
|
3920 | function position(firstValue) {
|
3921 | for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
3922 | values[_key - 1] = arguments[_key];
|
3923 | }
|
3924 |
|
3925 | if (positionMap$1.indexOf(firstValue) >= 0 && firstValue) {
|
3926 | return _extends({}, directionalProperty.apply(void 0, [''].concat(values)), {
|
3927 | position: firstValue
|
3928 | });
|
3929 | } else {
|
3930 | return directionalProperty.apply(void 0, ['', firstValue].concat(values));
|
3931 | }
|
3932 | }
|
3933 |
|
3934 | |
3935 |
|
3936 |
|
3937 |
|
3938 |
|
3939 |
|
3940 |
|
3941 |
|
3942 |
|
3943 |
|
3944 |
|
3945 |
|
3946 |
|
3947 |
|
3948 |
|
3949 |
|
3950 |
|
3951 |
|
3952 |
|
3953 |
|
3954 | function size(height, width) {
|
3955 | if (width === void 0) {
|
3956 | width = height;
|
3957 | }
|
3958 |
|
3959 | return {
|
3960 | height: height,
|
3961 | width: width
|
3962 | };
|
3963 | }
|
3964 |
|
3965 | var stateMap$1 = [undefined, null, 'active', 'focus', 'hover'];
|
3966 |
|
3967 | function template$1(state) {
|
3968 | return "input[type=\"color\"]" + state + ",\n input[type=\"date\"]" + state + ",\n input[type=\"datetime\"]" + state + ",\n input[type=\"datetime-local\"]" + state + ",\n input[type=\"email\"]" + state + ",\n input[type=\"month\"]" + state + ",\n input[type=\"number\"]" + state + ",\n input[type=\"password\"]" + state + ",\n input[type=\"search\"]" + state + ",\n input[type=\"tel\"]" + state + ",\n input[type=\"text\"]" + state + ",\n input[type=\"time\"]" + state + ",\n input[type=\"url\"]" + state + ",\n input[type=\"week\"]" + state + ",\n input:not([type])" + state + ",\n textarea" + state;
|
3969 | }
|
3970 | |
3971 |
|
3972 |
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 |
|
3987 |
|
3988 |
|
3989 |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 |
|
3995 |
|
3996 |
|
3997 |
|
3998 |
|
3999 |
|
4000 |
|
4001 |
|
4002 |
|
4003 |
|
4004 |
|
4005 |
|
4006 |
|
4007 |
|
4008 |
|
4009 |
|
4010 | function textInputs() {
|
4011 | for (var _len = arguments.length, states = new Array(_len), _key = 0; _key < _len; _key++) {
|
4012 | states[_key] = arguments[_key];
|
4013 | }
|
4014 |
|
4015 | return statefulSelectors(states, template$1, stateMap$1);
|
4016 | }
|
4017 |
|
4018 | |
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 |
|
4027 |
|
4028 |
|
4029 |
|
4030 |
|
4031 |
|
4032 |
|
4033 |
|
4034 |
|
4035 |
|
4036 |
|
4037 |
|
4038 |
|
4039 |
|
4040 |
|
4041 | function transitions() {
|
4042 | for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
|
4043 | properties[_key] = arguments[_key];
|
4044 | }
|
4045 |
|
4046 | if (Array.isArray(properties[0]) && properties.length === 2) {
|
4047 | var value = properties[1];
|
4048 |
|
4049 | if (typeof value !== 'string') {
|
4050 | throw new PolishedError(61);
|
4051 | }
|
4052 |
|
4053 | var transitionsString = properties[0].map(function (property) {
|
4054 | return property + " " + value;
|
4055 | }).join(', ');
|
4056 | return {
|
4057 | transition: transitionsString
|
4058 | };
|
4059 | } else {
|
4060 | return {
|
4061 | transition: properties.join(', ')
|
4062 | };
|
4063 | }
|
4064 | }
|
4065 |
|
4066 | exports.adjustHue = curriedAdjustHue;
|
4067 | exports.animation = animation;
|
4068 | exports.backgroundImages = backgroundImages;
|
4069 | exports.backgrounds = backgrounds;
|
4070 | exports.between = between;
|
4071 | exports.border = border;
|
4072 | exports.borderColor = borderColor;
|
4073 | exports.borderRadius = borderRadius;
|
4074 | exports.borderStyle = borderStyle;
|
4075 | exports.borderWidth = borderWidth;
|
4076 | exports.buttons = buttons;
|
4077 | exports.clearFix = clearFix;
|
4078 | exports.complement = complement;
|
4079 | exports.cover = cover;
|
4080 | exports.cssVar = cssVar;
|
4081 | exports.darken = curriedDarken;
|
4082 | exports.desaturate = curriedDesaturate;
|
4083 | exports.directionalProperty = directionalProperty;
|
4084 | exports.ellipsis = ellipsis;
|
4085 | exports.em = em;
|
4086 | exports.fluidRange = fluidRange;
|
4087 | exports.fontFace = fontFace;
|
4088 | exports.getContrast = getContrast;
|
4089 | exports.getLuminance = getLuminance;
|
4090 | exports.getValueAndUnit = getValueAndUnit;
|
4091 | exports.grayscale = grayscale;
|
4092 | exports.hiDPI = hiDPI;
|
4093 | exports.hideText = hideText;
|
4094 | exports.hideVisually = hideVisually;
|
4095 | exports.hsl = hsl;
|
4096 | exports.hslToColorString = hslToColorString;
|
4097 | exports.hsla = hsla;
|
4098 | exports.invert = invert;
|
4099 | exports.lighten = curriedLighten;
|
4100 | exports.linearGradient = linearGradient;
|
4101 | exports.margin = margin;
|
4102 | exports.math = math;
|
4103 | exports.meetsContrastGuidelines = meetsContrastGuidelines;
|
4104 | exports.mix = curriedMix;
|
4105 | exports.modularScale = modularScale;
|
4106 | exports.normalize = normalize;
|
4107 | exports.opacify = curriedOpacify;
|
4108 | exports.padding = padding;
|
4109 | exports.parseToHsl = parseToHsl;
|
4110 | exports.parseToRgb = parseToRgb;
|
4111 | exports.position = position;
|
4112 | exports.radialGradient = radialGradient;
|
4113 | exports.readableColor = readableColor;
|
4114 | exports.rem = rem;
|
4115 | exports.retinaImage = retinaImage;
|
4116 | exports.rgb = rgb;
|
4117 | exports.rgbToColorString = rgbToColorString;
|
4118 | exports.rgba = rgba;
|
4119 | exports.saturate = curriedSaturate;
|
4120 | exports.setHue = curriedSetHue;
|
4121 | exports.setLightness = curriedSetLightness;
|
4122 | exports.setSaturation = curriedSetSaturation;
|
4123 | exports.shade = curriedShade;
|
4124 | exports.size = size;
|
4125 | exports.stripUnit = stripUnit;
|
4126 | exports.textInputs = textInputs;
|
4127 | exports.timingFunctions = timingFunctions;
|
4128 | exports.tint = curriedTint;
|
4129 | exports.toColorString = toColorString;
|
4130 | exports.transitions = transitions;
|
4131 | exports.transparentize = curriedTransparentize;
|
4132 | exports.triangle = triangle;
|
4133 | exports.wordWrap = wordWrap;
|
4134 |
|
4135 | Object.defineProperty(exports, '__esModule', { value: true });
|
4136 |
|
4137 | })));
|