source: trip-planner-front/node_modules/postcss-place/index.cjs.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
5var postcss = _interopDefault(require('postcss'));
6var parser = _interopDefault(require('postcss-values-parser'));
7
8const placeMatch = /^place-(content|items|self)/;
9var index = postcss.plugin('postcss-place', opts => {
10 // prepare options
11 const preserve = 'preserve' in Object(opts) ? Boolean(opts.prefix) : true;
12 return root => {
13 // walk each matching declaration
14 root.walkDecls(placeMatch, decl => {
15 // alignment
16 const alignment = decl.prop.match(placeMatch)[1]; // value ast and child nodes
17
18 const value = parser(decl.value).parse();
19 const children = value.nodes[0].nodes; // new justify-[alignment] and align-[alignment] declarations
20
21 const alignValue = children.length === 1 ? decl.value : String(children.slice(0, 1)).trim();
22 const justifyValue = children.length === 1 ? decl.value : String(children.slice(1)).trim();
23 decl.cloneBefore({
24 prop: `align-${alignment}`,
25 value: alignValue
26 });
27 decl.cloneBefore({
28 prop: `justify-${alignment}`,
29 value: justifyValue
30 }); // conditionally remove place-[alignment]
31
32 if (!preserve) {
33 decl.remove();
34 }
35 });
36 };
37});
38
39module.exports = index;
40//# sourceMappingURL=index.cjs.js.map
Note: See TracBrowser for help on using the repository browser.