Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = isColorStop;
|
|
|
|
var _postcssValueParser = require("postcss-value-parser");
|
|
|
|
var _colord = require("colord");
|
|
|
|
var _names = _interopRequireDefault(require("colord/plugins/names"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
(0, _colord.extend)([_names.default]);
|
|
/* Code derived from https://github.com/pigcan/is-color-stop */
|
|
|
|
const lengthArray = ['PX', 'IN', 'CM', 'MM', 'EM', 'REM', 'POINTS', 'PC', 'EX', 'CH', 'VW', 'VH', 'VMIN', 'VMAX', '%'];
|
|
|
|
function isCSSLengthUnit(input) {
|
|
return lengthArray.includes(input.toUpperCase());
|
|
}
|
|
|
|
function isStop(str) {
|
|
let stop = !str;
|
|
|
|
if (!stop) {
|
|
const node = (0, _postcssValueParser.unit)(str);
|
|
|
|
if (node) {
|
|
if (node.number === 0 || !isNaN(node.number) && isCSSLengthUnit(node.unit)) {
|
|
stop = true;
|
|
}
|
|
} else {
|
|
stop = /^calc\(\S+\)$/g.test(str);
|
|
}
|
|
}
|
|
|
|
return stop;
|
|
}
|
|
|
|
function isColorStop(color, stop) {
|
|
return (0, _colord.colord)(color).isValid() && isStop(stop);
|
|
}
|
|
|
|
module.exports = exports.default; |