How to use the postcss.list function in postcss

To help you get started, we’ve selected a few postcss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github corysimmons / postcss-ant / lib / index.js View on Github external
const ant: Function = postcss.plugin('postcss-ant', (opts: {
  rounders: Array,
  gutters: Array,
  bump: string,
  pluck: number,
  namespace: string,
  support: string,
  technique: string,
  children: string
} = {
  rounders: postcss.list.comma('99.99%, 99.999999%'),
  gutters: postcss.list.comma('30px, 30px'),
  bump: '',
  pluck: 1,
  namespace: '',
  support: 'flexbox',
  technique: 'nth',
  children: 'nth-child'
}) => {
  return (css: {
    walkAtRules: Function,
    walkDecls: Function
  }) => {
    // Update global settings if there are atRule settings
    css.walkAtRules((rule: {
      name: string,
      params: string,
github luisrudge / postcss-flexbugs-fixes / bugs / bug4.js View on Github external
module.exports = function(decl) {
    if (decl.prop === 'flex') {
        var values = postcss.list.space(decl.value);

        // set default values
        var flexGrow = '0';
        var flexShrink = '1';
        var flexBasis = '0%';

        if (values[0]) {
            flexGrow = values[0];
        }

        if (values[1]) {
            if (!isNaN(values[1])) {
                flexShrink = values[1];
            } else {
                flexBasis = values[1];
            }
github antyakushev / postcss-default-unit / index.js View on Github external
function transformDecl(decl) {
        if (!opts.ignore[decl.prop]) {
            var parts = postcss.list.space(decl.value);

            for (var i = 0; i < parts.length; i++) {

                var isColor = /#[0-9a-fA-F]+/.test(parts[i]),
                    hasParenths =  /\w\(.*\)/.test(parts[i]);

                if (!hasParenths && !isColor) {
                    parts[i] = parts[i].replace(/\d+(\s|\/|,|$)/g, replacer);
                }
            }
            decl.value = parts.join(' ');
        }
    }
github lintopher0315 / Quick-Math / node_modules / postcss-merge-longhand / dist / lib / parseWsc.js View on Github external
function parseWsc(value) {
    if (none.test(value)) {
        return ['medium', 'none', 'currentcolor'];
    }

    let width, style, color;

    const values = _postcss.list.space(value);
    if (values.length > 1 && (0, _validateWsc.isStyle)(values[1]) && values[0].toLowerCase() === 'none') {
        values.unshift();
        width = '0';
    }

    const unknown = [];

    values.forEach(v => {
        if ((0, _validateWsc.isStyle)(v)) {
            style = toLower(v);
        } else if ((0, _validateWsc.isWidth)(v)) {
            width = toLower(v);
        } else if ((0, _validateWsc.isColor)(v)) {
            color = toLower(v);
        } else {
            unknown.push(v);
github eschirtz / Computer-Science-Series / node_modules / postcss-merge-longhand / dist / lib / decl / borders.js View on Github external
}
            const props = nodes.filter(node => node.prop && ~names.indexOf(node.prop) && node.important === lastNode.important);
            const rules = (0, _getRules2.default)(props, names);
            if ((0, _hasAllProps2.default)(rules, ...names) && !rules.some(_stylehacks.detect)) {
                const values = rules.map(node => node ? node.value : null);
                const filteredValues = values.filter(Boolean);
                const lastNodeValue = _postcss.list.space(lastNode.value)[i];
                values[directions.indexOf(lastNode.prop)] = lastNodeValue;
                let value = (0, _minifyTrbl2.default)(values.join(' '));
                if (filteredValues[0] === filteredValues[1] && filteredValues[1] === filteredValues[2]) {
                    value = filteredValues[0];
                }
                let refNode = props[props.length - 1];
                if (value === lastNodeValue) {
                    refNode = lastNode;
                    let valueArray = _postcss.list.space(lastNode.value);
                    valueArray.splice(i, 1);
                    lastNode.value = valueArray.join(' ');
                }
                (0, _insertCloned2.default)(refNode.parent, refNode, {
                    prop: borderProperty(d),
                    value
                });
                decls = decls.filter(node => !~rules.indexOf(node));
                rules.forEach(_remove2.default);
            }
        });
        decls = decls.filter(node => node !== lastNode);
github GoogleContainerTools / kpt / node_modules / autoprefixer / lib / hacks / cross-fade.js View on Github external
* Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

"use strict";

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var list = require('postcss').list;

var Value = require('../value');

var CrossFade =
/*#__PURE__*/
function (_Value) {
  _inheritsLoose(CrossFade, _Value);

  function CrossFade() {
    return _Value.apply(this, arguments) || this;
  }

  var _proto = CrossFade.prototype;

  _proto.replace = function replace(string, prefix) {
    var _this = this;
github sindresorhus / sublime-autoprefixer / node_modules / autoprefixer / lib / hacks / flex.js View on Github external
"use strict";

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var list = require('postcss').list;

var flexSpec = require('./flex-spec');

var Declaration = require('../declaration');

var Flex =
/*#__PURE__*/
function (_Declaration) {
  _inheritsLoose(Flex, _Declaration);

  function Flex() {
    return _Declaration.apply(this, arguments) || this;
  }

  var _proto = Flex.prototype;
github GoogleContainerTools / kpt / node_modules / autoprefixer / lib / selector.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

"use strict";

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }

var _require = require('postcss'),
    list = _require.list;

var OldSelector = require('./old-selector');

var Prefixer = require('./prefixer');

var Browsers = require('./browsers');

var utils = require('./utils');

var Selector =
/*#__PURE__*/
function (_Prefixer) {
  _inheritsLoose(Selector, _Prefixer);

  function Selector(name, prefixes, all) {
    var _this;
github erikjung / postcss-modular-scale-unit / src / index.js View on Github external
css.walkDecls(CONFIG_PROPERTY_PATTERN, decl => {
      if (propEq('selector', ':root', decl.parent)) {
        let [ratio, ...bases] = postcss.list.space(decl.value)

        let matchingKey = find(
          val => toLowerWords(val) === toLowerWords(ratio),
          keys(Ratios)
        )

        ratio = Ratios[matchingKey] || ratio
        msOptions = evolve({
          /**
           * If `ratio` appears as a fraction string:
           * convert the fraction string to a float,
           * else, parse the raw value as a float.
           */
          ratio: ifElse(hasSlash, fractionToFloat, toFloat),
          /**
           * If `bases` has a length of elements: