chushihua
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const colorNames = require('css-color-names');
|
||||
|
||||
function isCSSColorName(str) {
|
||||
return !!colorNames[str];
|
||||
}
|
||||
|
||||
module.exports = isCSSColorName;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
const lengthArray = [
|
||||
'PX',
|
||||
'IN',
|
||||
'CM',
|
||||
'MM',
|
||||
'EM',
|
||||
'REM',
|
||||
'POINTS',
|
||||
'PC',
|
||||
'EX',
|
||||
'CH',
|
||||
'VW',
|
||||
'VH',
|
||||
'VMIN',
|
||||
'VMAX',
|
||||
'%',
|
||||
];
|
||||
|
||||
function isCSSLengthUnit(unit) {
|
||||
return lengthArray.indexOf(unit.toUpperCase()) >= 0;
|
||||
}
|
||||
|
||||
module.exports = isCSSLengthUnit;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const hslRegex = require('hsl-regex');
|
||||
|
||||
function isHSL(str) {
|
||||
return hslRegex({ exact: true }).test(str);
|
||||
}
|
||||
|
||||
module.exports = isHSL;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const hslaRegex = require('hsla-regex');
|
||||
|
||||
function isHSLA(str) {
|
||||
return hslaRegex({ exact: true }).test(str);
|
||||
}
|
||||
|
||||
module.exports = isHSLA;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const hexRegex = require('hex-color-regex');
|
||||
|
||||
function isHex(str) {
|
||||
return hexRegex({ exact: true }).test(str);
|
||||
}
|
||||
|
||||
module.exports = isHex;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const rgbRegex = require('rgb-regex');
|
||||
|
||||
function isRGB(str) {
|
||||
return rgbRegex({ exact: true }).test(str);
|
||||
}
|
||||
|
||||
module.exports = isRGB;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const rgbaRegex = require('rgba-regex');
|
||||
|
||||
function isRgba(str) {
|
||||
return rgbaRegex({ exact: true }).test(str);
|
||||
}
|
||||
|
||||
module.exports = isRgba;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const isCSSLengthUnit = require('./isCSSLengthUnit');
|
||||
const unit = require('../util/unit');
|
||||
|
||||
function isStop(str) {
|
||||
let stop = !str;
|
||||
|
||||
if (!stop) {
|
||||
const node = 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;
|
||||
}
|
||||
|
||||
module.exports = isStop;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
function isTransparent(str) {
|
||||
return str === 'transparent';
|
||||
}
|
||||
|
||||
module.exports = isTransparent;
|
||||
Reference in New Issue
Block a user