packages/plugins/media-queries/dist/index.js
function generateMediaQueries(breakPoints, unit) {
    // Sort breakpoints by size
    var breakpointNames = Object.keys(breakPoints).sort(function (breakpointNameA, breakpointNameB) {
        if (breakPoints[breakpointNameA] > breakPoints[breakpointNameB]) {
            return 1;
        }
        if (breakPoints[breakpointNameA] < breakPoints[breakpointNameB]) {
            return -1;
        }
        return 0;
    });
    // Convert breakpoints from 980 into (min-width: 700) and (max-width: 980)
    // by using the previous breakpoint
    return breakpointNames.map(function (breakpointName, i) {
        // If this is the first breakpoint we don't need a min value
        var min = breakpointNames[i - 1] === undefined ? undefined : breakPoints[breakpointNames[i - 1]] + 1;
        // If this is the last breakpoint we don't need a max value
        var max = breakPoints[breakpointName] === Infinity ? undefined : breakPoints[breakpointName];
        var queryString;
        if (min && max) {
            queryString = "(min-width: " + min + unit + ") and (max-width: " + max + unit + ")";
        }
        else if (min) {
            queryString = "(min-width: " + min + unit + ")";
        }
        else if (max) {
            queryString = "(max-width: " + max + unit + ")";
        }
        else {
            // This should only happen if the user did a miss configuration
            // with only a single breakpoint which is set to infinity
            throw new Error("The smallest provided viewport must not be set to Infinity");
        }
        return { name: breakpointName, query: queryString, min: min, max: max };
    });
}
function generateMediaQueries(breakPoints, unit) {
    // Sort breakpoints by size
    var breakpointNames = Object.keys(breakPoints).sort(function (breakpointNameA, breakpointNameB) {
        if (breakPoints[breakpointNameA] > breakPoints[breakpointNameB]) {
            return 1;
        }
        if (breakPoints[breakpointNameA] < breakPoints[breakpointNameB]) {
            return -1;
        }
        return 0;
    });
    // Convert breakpoints from 980 into (min-width: 700) and (max-width: 980)
    // by using the previous breakpoint
    return breakpointNames.map(function (breakpointName, i) {
        // If this is the first breakpoint we don't need a min value
        var min = breakpointNames[i - 1] === undefined ? undefined : breakPoints[breakpointNames[i - 1]] + 1;
        // If this is the last breakpoint we don't need a max value
        var max = breakPoints[breakpointName] === Infinity ? undefined : breakPoints[breakpointName];
        var queryString;
        if (min && max) {
            queryString = "(min-width: " + min + unit + ") and (max-width: " + max + unit + ")";
        }
        else if (min) {
            queryString = "(min-width: " + min + unit + ")";
        }
        else if (max) {
            queryString = "(max-width: " + max + unit + ")";
        }
        else {
            // This should only happen if the user did a miss configuration
            // with only a single breakpoint which is set to infinity
            throw new Error("The smallest provided viewport must not be set to Infinity");
        }
        return { name: breakpointName, query: queryString, min: min, max: max };
    });
}
function generateMediaQueries ( breakPoints , unit ) { // Sort breakpoints by size var breakpointNames = Object . keys ( breakPoints ) . sort ( function ( breakpointNameA , breakpointNameB ) { if ( breakPoints [ breakpointNameA ] > breakPoints [ breakpointNameB ] ) { return 1 ; } if ( breakPoints [ breakpointNameA ] < breakPoints [ breakpointNameB ] ) { return - 1 ; } return 0 ; } ) ; // Convert breakpoints from 980 into (min-width: 700) and (max-width: 980) // by using the previous breakpoint return breakpointNames . map ( function ( breakpointName , i ) { // If this is the first breakpoint we don't need a min value var min = breakpointNames [ i - 1 ] === undefined ? undefined : breakPoints [ breakpointNames [ i - 1 ] ] + 1 ; // If this is the last breakpoint we don't need a max value var max = breakPoints [ breakpointName ] === Infinity ? undefined : breakPoints [ breakpointName ] ; var queryString ; if ( min && max ) { queryString = "(min-width: " + min + unit + ") and (max-width: " + max + unit + ")" ; } else if ( min ) { queryString = "(min-width: " + min + unit + ")" ; } else if ( max ) { queryString = "(max-width: " + max + unit + ")" ; } else { // This should only happen if the user did a miss configuration // with only a single breakpoint which is set to infinity throw new Error ( "The smallest provided viewport must not be set to Infinity" ) ; } return { name : breakpointName , query : queryString , min : min , max : max } ; } ) ; }
This function generate mediaQueries from breakPoints
This function generate mediaQueries from breakPoints