source: trip-planner-front/node_modules/postcss-merge-longhand/dist/lib/validateWsc.js@ 8d391a1

Last change on this file since 8d391a1 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 1.4 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.isStyle = isStyle;
7exports.isWidth = isWidth;
8exports.isColor = isColor;
9exports.isValidWsc = isValidWsc;
10
11var _colornames = _interopRequireDefault(require("./colornames.js"));
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15const widths = ['thin', 'medium', 'thick'];
16const styles = ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
17
18function isStyle(value) {
19 return value && !!~styles.indexOf(value.toLowerCase());
20}
21
22function isWidth(value) {
23 return value && !!~widths.indexOf(value.toLowerCase()) || /^(\d+(\.\d+)?|\.\d+)(\w+)?$/.test(value);
24}
25
26function isColor(value) {
27 if (!value) {
28 return false;
29 }
30
31 value = value.toLowerCase();
32
33 if (/rgba?\(/.test(value)) {
34 return true;
35 }
36
37 if (/hsla?\(/.test(value)) {
38 return true;
39 }
40
41 if (/#([0-9a-z]{6}|[0-9a-z]{3})/.test(value)) {
42 return true;
43 }
44
45 if (value === 'transparent') {
46 return true;
47 }
48
49 if (value === 'currentcolor') {
50 return true;
51 }
52
53 return !!~_colornames.default.indexOf(value);
54}
55
56function isValidWsc(wscs) {
57 const validWidth = isWidth(wscs[0]);
58 const validStyle = isStyle(wscs[1]);
59 const validColor = isColor(wscs[2]);
60 return validWidth && validStyle || validWidth && validColor || validStyle && validColor;
61}
Note: See TracBrowser for help on using the repository browser.