How to use the postcss-value-parser.walk 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 ben-eb / css-values / packages / css-values / index.js View on Github external
function isRgb(node) {
    if (!isFunction(node, 'rgb')) {
        return;
    }
    var valid = true;
    walk(node.nodes, function (child, index) {
        var even = isEven(index);
        if (even && !isInteger(child) && !isPercentage(child) || !even && !isComma(child)) {
            valid = false;
        }
        return false;
    });

    return valid && node.nodes.length === 5;
}
github ben-eb / css-values / src / validators / isImage.js View on Github external
function isImageFunction (node) {
    if (!isFunction(node, 'image')) {
        return false;
    }
    let valid = true;
    walk(node.nodes, (child, index) => {
        if (index === 0 && !isImage(child) && !isString(child) && !isColor(child)) {
            valid = false;
        }
        if (index === 1 && !isComma(child)) {
            valid = false;
        }
        if (index === 2 && (isColor(node.nodes[0]) || !isColor(child))) {
            valid = false;
        }
        return false;
    });
    return valid && node.nodes.length <= 3;
}
github ben-eb / css-values / packages / css-values / index.js View on Github external
function isInset(node) {
    if (!isFunction(node, 'inset')) {
        return false;
    }
    var valid = true;
    walk(node.nodes, function (child, index) {
        var even = isEven(index);
        if (!even && !isSpace(child)) {
            valid = false;
            return false;
        }
        if (even && !isLengthPercentage(child)) {
            valid = false;
            return false;
        }
    });
    return valid;
}
github ben-eb / css-values / src / validators / isColor.js View on Github external
export function isRgb (node) {
    if (!isFunction(node, 'rgb')) {
        return;
    }
    let valid = true;
    walk(node.nodes, (child, index) => {
        const even = isEven(index);
        if (
            even && (!isInteger(child) && !isPercentage(child)) ||
            !even && !isComma(child)
        ) {
            valid = false;
        }
        return false;
    });

    return valid && node.nodes.length === 5;
}
github ben-eb / css-values / packages / css-values / index.js View on Github external
function isMatrix(node) {
    if (!isFunction(node, [matrix, matrix3d])) {
        return false;
    }
    if (node.value === matrix && node.nodes.length !== 11 || node.value === matrix3d && node.nodes.length !== 31) {
        return false;
    }

    var valid = true;

    walk(node.nodes, function (child, index) {
        var even = isEven(index);
        if (even && !isNumber(child) || !even && !isComma(child)) {
            valid = false;
        }
        return false;
    });

    return valid;
}
github ben-eb / css-values / src / validators / isSingleTransitionTimingFunction.js View on Github external
export function isCubicBezier (node) {
    if (!isFunction(node, 'cubic-bezier')) {
        return false;
    }
    let valid = true;
    walk(node.nodes, (child, index) => {
        const even = isEven(index);
        if (
            even && (
                ((index === 0 || index === 4) && !isValidAbscissa(child)) ||
                ((index === 2 || index === 6) && !isNumber(child))
            ) || !even && !isComma(child)
        ) {
            valid = false;
        }
        return false;
    });

    return valid && node.nodes.length === 7;
}
github ben-eb / css-values / packages / css-values / index.js View on Github external
function isSymbols(node) {
    if (!isFunction(node, 'symbols')) {
        return false;
    }
    var validSym = true;
    walk(node.nodes, function (child, index) {
        var even = isEven(index);
        if (even && (index === 0 && !isKeyword(child, symbolTypes) && !isString(child) && !isImage(child) || index > 1 && !isString(child) && !isImage(child)) || !even && !isSpace(child)) {
            validSym = false;
        }
        return false;
    });
    return validSym;
}
github ben-eb / css-values / packages / css-values / index.js View on Github external
function isDropShadow(node) {
    if (!isFunction(node, 'drop-shadow')) {
        return false;
    }
    var valid = true;
    walk(node.nodes, function (child, index) {
        var even = isEven(index);
        if (even && index <= 2 && !isLength(child)) {
            valid = false;
            return false;
        }
        if (even && index === 4 && !isLength(child) && !isColor(child)) {
            valid = false;
            return false;
        }
        if (even && index === 6 && !isColor(child)) {
            valid = false;
            return false;
        }
        if (!even && !isSpace(child)) {
            valid = false;
            return false;
github ben-eb / css-values / src / validators / isTransformList.js View on Github external
function isMatrix (node) {
    if (!isFunction(node, [matrix, matrix3d])) {
        return false;
    }
    if (
        node.value === matrix && node.nodes.length !== 11 ||
        node.value === matrix3d && node.nodes.length !== 31
    ) {
        return false;
    }

    let valid = true;

    walk(node.nodes, (child, index) => {
        const even = isEven(index);
        if (even && !isNumber(child) || !even && !isComma(child)) {
            valid = false;
        }
        return false;
    });

    return valid;
}

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