How to use the postcss-value-parser.stringify function in postcss-value-parser

To help you get started, we’ve selected a few postcss-value-parser 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 parcel-bundler / parcel / packages / core / parcel-bundler / src / assets / CSSAsset.js View on Github external
throw new Error('Could not find import name for ' + rule);
      }

      if (PROTOCOL_RE.test(dep)) {
        return;
      }

      // If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
      // TODO: run CSSPackager on inline style tags.
      let inlineHTML =
        this.options.rendition && this.options.rendition.inlineHTML;
      if (inlineHTML) {
        name.value = this.addURLDependency(dep, {loc: rule.source.start});
        rule.params = params.toString();
      } else {
        media = valueParser.stringify(media).trim();
        this.addDependency(dep, {media, loc: rule.source.start});
        rule.remove();
      }

      this.ast.dirty = true;
    });
</style>
github corysimmons / postcss-ant / lib / helpers / generate-grid.js View on Github external
export default (node, localOpts, direction, decl, firstColumnSetLength, foundColumnsAndRows, prevSourceIndex, locallySpecified, lastColumnSetLength) =&gt; {
  // Grab all the contents within the function and sort them into size sets.
  const value: string = valueParser.stringify(node.nodes)
  const sizeSets: Array = postcss.list.comma(value)
  let totalSizes: number = 0
  sizeSets.map(sizeSet =&gt; {
    totalSizes += postcss.list.space(sizeSet).length
  })

  // Determine if this is the last/first columns() or rows() call in the declaration value.
  let lastCall: boolean = false
  let firstCall: boolean = false
  if (node.sourceIndex &gt; prevSourceIndex) {
    lastCall = true
  }
  if (node.sourceIndex === 0){
    firstCall = true
  }
github corysimmons / postcss-ant / lib / index.js View on Github external
break

            case `${localOpts.namespace}support`:
              localOpts.support = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.support
              break

            case `${localOpts.namespace}pluck`:
              localOpts.pluck = Number(valueParser.stringify(node.nodes)) ? Number(valueParser.stringify(node.nodes)) : opts.pluck
              break

            case `${localOpts.namespace}bump`:
              localOpts.bump = ` ${valueParser.stringify(node.nodes)}` ? ` ${valueParser.stringify(node.nodes)}` : opts.bump
              break

            case `${localOpts.namespace}technique`:
              localOpts.technique = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.technique
              break

            case `${localOpts.namespace}children`:
              localOpts.children = valueParser.stringify(node.nodes) ? valueParser.stringify(node.nodes) : opts.children
              break

            default:
              break
          }

          // Poorly erase the function (leaves whitespace). It would be nice if there was a .remove() method in valueParser.
          node.value = ''
        }
      }, false) // shallow
github makuga01 / dnsFookup / FE / node_modules / autoprefixer / lib / hacks / gradient.js View on Github external
_proto.oldWebkit = function oldWebkit(node) {
    var nodes = node.nodes;
    var string = parser.stringify(node.nodes);

    if (this.name !== 'linear-gradient') {
      return false;
    }

    if (nodes[0] && nodes[0].value.includes('deg')) {
      return false;
    }

    if (string.includes('px') || string.includes('-corner') || string.includes('-side')) {
      return false;
    }

    var params = [[]];

    for (var _iterator4 = _createForOfIteratorHelperLoose(nodes), _step4; !(_step4 = _iterator4()).done;) {
github daviddbarrero / Ionic-4-firebase / node_modules / autoprefixer / lib / hacks / gradient.js View on Github external
Gradient.prototype.oldWebkit = function oldWebkit(node) {
        var nodes = node.nodes;

        var string = parser.stringify(node.nodes);

        if (this.name !== 'linear-gradient') {
            return false;
        }
        if (nodes[0] && nodes[0].value.indexOf('deg') !== -1) {
            return false;
        }
        if (string.indexOf('px') !== -1 || string.indexOf('-corner') !== -1 || string.indexOf('-side') !== -1) {
            return false;
        }

        var params = [[]];
        for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
            var _ref3;

            if (_isArray3) {
github rashmiap / personal-website-react / node_modules / css-to-react-native / index.js View on Github external
var matchColor = function matchColor(node) {
  if (node.type === 'word' && (hexColorRe.test(node.value) || node.value in cssColorKeywords || node.value === 'transparent')) {
    return node.value;
  } else if (node.type === 'function' && cssFunctionNameRe.test(node.value)) {
    return parse.stringify(node);
  }
  return null;
};
github stylelint / stylelint / lib / rules / shorthand-property-no-redundant-values / index.js View on Github external
valueParser(value).walk((valueNode) => {
				if (valueNode.type !== 'word') {
					return;
				}

				valuesToShorthand.push(valueParser.stringify(valueNode));
			});
github ben-eb / midas / src / stringifier.js View on Github external
}
                            if (
                                child.nodes[i + 1] &&
                                child.nodes[i + 1].value === ':'
                            ) {
                                n.value = span(n.value, t.property);
                            }
                        }
                    });
                    child.value = span('(', t.parenthesis) +
                                 stringify(child.nodes) +
                                 span(')', t.parenthesis);
                    child.nodes = null;
                }
            });
            params = stringify(parsed);
        }

        if (typeof node.raws.afterName !== 'undefined') {
            name += node.raws.afterName;
        } else if (params) {
            name += ' ';
        }

        if (node.nodes) {
            this.block(node, span(name + params, t.atRule));
        } else {
            let semi = semicolon ? span(';', t.semicolon) : '';
            let end = (node.raws.between || '') + semi;
            this.builder(span(name + params + end, t.atRule), node);
        }
    }
github retyui / postcss-animations / src / index.js View on Github external
.forEach(e => {
						proxyAllCssVar.appendKeyframes(
							root,
							e.type === "function" ? valueParser.stringify(e) : e.value
						);
					});
			});
github aermin / ghChat / node_modules / autoprefixer / lib / hacks / gradient.js View on Github external
Gradient.prototype.colorStops = function colorStops(params) {
        var result = [];
        for (var i = 0; i &lt; params.length; i++) {
            var pos = void 0;
            var param = params[i];
            var item = void 0;
            if (i === 0) {
                continue;
            }

            var color = parser.stringify(param[0]);
            if (param[1] &amp;&amp; param[1].type === 'word') {
                pos = param[1].value;
            } else if (param[2] &amp;&amp; param[2].type === 'word') {
                pos = param[2].value;
            }

            var stop = void 0;
            if (i === 1 &amp;&amp; (!pos || pos === '0%')) {
                stop = 'from(' + color + ')';
            } else if (i === params.length - 1 &amp;&amp; (!pos || pos === '100%')) {
                stop = 'to(' + color + ')';
            } else if (pos) {
                stop = 'color-stop(' + pos + ', ' + color + ')';
            } else {
                stop = 'color-stop(' + color + ')';
            }

postcss-value-parser

Transforms css values and at-rule params into the tree

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis