Sha256: 57e8e4cdabdb6b2b836ccc84d6639e27f44986bfc682c686f77bcecc208994c6

Contents?: true

Size: 1.18 KB

Versions: 26

Compression:

Stored size: 1.18 KB

Contents

import postcss from 'postcss';
import parser from 'postcss-values-parser';

const placeMatch = /^place-(content|items|self)/;
var index = postcss.plugin('postcss-place', opts => {
  // prepare options
  const preserve = 'preserve' in Object(opts) ? Boolean(opts.prefix) : true;
  return root => {
    // walk each matching declaration
    root.walkDecls(placeMatch, decl => {
      // alignment
      const alignment = decl.prop.match(placeMatch)[1]; // value ast and child nodes

      const value = parser(decl.value).parse();
      const children = value.nodes[0].nodes; // new justify-[alignment] and align-[alignment] declarations

      const alignValue = children.length === 1 ? decl.value : String(children.slice(0, 1)).trim();
      const justifyValue = children.length === 1 ? decl.value : String(children.slice(1)).trim();
      decl.cloneBefore({
        prop: `align-${alignment}`,
        value: alignValue
      });
      decl.cloneBefore({
        prop: `justify-${alignment}`,
        value: justifyValue
      }); // conditionally remove place-[alignment]

      if (!preserve) {
        decl.remove();
      }
    });
  };
});

export default index;
//# sourceMappingURL=index.es.mjs.map

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.18.0 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.18.2 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.16.1 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.15.2 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.18.4 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.18.1 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.14.0 test/dummy/node_modules/postcss-place/index.es.mjs
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/postcss-place/index.es.mjs
tang-0.2.1 spec/tang_app/node_modules/postcss-place/index.es.mjs
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/postcss-place/index.es.mjs
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/postcss-place/index.es.mjs
ruby2js-4.0.4 lib/tasks/testrails/node_modules/postcss-place/index.es.mjs
ruby2js-4.0.3 lib/tasks/testrails/node_modules/postcss-place/index.es.mjs
tang-0.2.0 spec/tang_app/node_modules/postcss-place/index.es.mjs
tang-0.1.0 spec/tang_app/node_modules/postcss-place/index.es.mjs
tang-0.0.9 spec/tang_app/node_modules/postcss-place/index.es.mjs
enju_library-0.3.8 spec/dummy/node_modules/postcss-place/index.es.mjs
jester-data-8.0.0 node_modules/postcss-place/index.es.mjs