source: trip-planner-front/node_modules/postcss-minify-gradients/dist/isColorStop.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = isColorStop;
7
8var _postcssValueParser = require("postcss-value-parser");
9
10var _colord = require("colord");
11
12var _names = _interopRequireDefault(require("colord/plugins/names"));
13
14function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16(0, _colord.extend)([_names.default]);
17/* Code derived from https://github.com/pigcan/is-color-stop */
18
19const lengthArray = ['PX', 'IN', 'CM', 'MM', 'EM', 'REM', 'POINTS', 'PC', 'EX', 'CH', 'VW', 'VH', 'VMIN', 'VMAX', '%'];
20
21function isCSSLengthUnit(input) {
22 return lengthArray.includes(input.toUpperCase());
23}
24
25function isStop(str) {
26 let stop = !str;
27
28 if (!stop) {
29 const node = (0, _postcssValueParser.unit)(str);
30
31 if (node) {
32 if (node.number === 0 || !isNaN(node.number) && isCSSLengthUnit(node.unit)) {
33 stop = true;
34 }
35 } else {
36 stop = /^calc\(\S+\)$/g.test(str);
37 }
38 }
39
40 return stop;
41}
42
43function isColorStop(color, stop) {
44 return (0, _colord.colord)(color).isValid() && isStop(stop);
45}
46
47module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.