source: trip-planner-front/node_modules/postcss-ordered-values/dist/rules/border.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = normalizeBorder;
7
8var _postcssValueParser = require("postcss-value-parser");
9
10// border: <line-width> || <line-style> || <color>
11// outline: <outline-color> || <outline-style> || <outline-width>
12const borderWidths = ['thin', 'medium', 'thick'];
13const borderStyles = ['none', 'auto', // only in outline-style
14'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
15
16function normalizeBorder(border) {
17 const order = {
18 width: '',
19 style: '',
20 color: ''
21 };
22 border.walk(node => {
23 const {
24 type,
25 value
26 } = node;
27
28 if (type === 'word') {
29 if (~borderStyles.indexOf(value.toLowerCase())) {
30 order.style = value;
31 return false;
32 }
33
34 if (~borderWidths.indexOf(value.toLowerCase()) || (0, _postcssValueParser.unit)(value.toLowerCase())) {
35 if (order.width !== '') {
36 order.width = `${order.width} ${value}`;
37 return false;
38 }
39
40 order.width = value;
41 return false;
42 }
43
44 order.color = value;
45 return false;
46 }
47
48 if (type === 'function') {
49 if (value.toLowerCase() === 'calc') {
50 order.width = (0, _postcssValueParser.stringify)(node);
51 } else {
52 order.color = (0, _postcssValueParser.stringify)(node);
53 }
54
55 return false;
56 }
57 });
58 return `${order.width} ${order.style} ${order.color}`.trim();
59}
60
61module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.