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.0 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.columnsRule = exports.column = void 0;
|
---|
7 |
|
---|
8 | var _postcssValueParser = require("postcss-value-parser");
|
---|
9 |
|
---|
10 | var _border = _interopRequireDefault(require("./border.js"));
|
---|
11 |
|
---|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
13 |
|
---|
14 | function hasUnit(value) {
|
---|
15 | const parsedVal = (0, _postcssValueParser.unit)(value);
|
---|
16 | return parsedVal && parsedVal.unit !== '';
|
---|
17 | }
|
---|
18 |
|
---|
19 | const column = columns => {
|
---|
20 | const widths = [];
|
---|
21 | const other = [];
|
---|
22 | columns.walk(node => {
|
---|
23 | const {
|
---|
24 | type,
|
---|
25 | value
|
---|
26 | } = node;
|
---|
27 |
|
---|
28 | if (type === 'word') {
|
---|
29 | if (hasUnit(value)) {
|
---|
30 | widths.push(value);
|
---|
31 | } else {
|
---|
32 | other.push(value);
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }); // only transform if declaration is not invalid or a single value
|
---|
36 |
|
---|
37 | if (other.length === 1 && widths.length === 1) {
|
---|
38 | return `${widths[0].trimStart()} ${other[0].trimStart()}`;
|
---|
39 | }
|
---|
40 |
|
---|
41 | return columns;
|
---|
42 | };
|
---|
43 |
|
---|
44 | exports.column = column;
|
---|
45 | const columnsRule = _border.default;
|
---|
46 | exports.columnsRule = columnsRule; |
---|
Note:
See
TracBrowser
for help on using the repository browser.