From 6eed7ab4ff7ec2b9834153874d3b8813d0eda54f Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Tue, 5 Sep 2017 21:55:17 -0400 Subject: [PATCH] Add ability to define more complex breakpoints. --- src/lib/addCustomMediaQueries.js | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/lib/addCustomMediaQueries.js b/src/lib/addCustomMediaQueries.js index 5700c6dd5..9ad38a055 100644 --- a/src/lib/addCustomMediaQueries.js +++ b/src/lib/addCustomMediaQueries.js @@ -1,21 +1,26 @@ import _ from 'lodash' import postcss from 'postcss' -function buildMediaQuery(breakpoint) { - if (_.isString(breakpoint)) { - breakpoint = {min: breakpoint} +function buildMediaQuery(breakpoints) { + if (_.isString(breakpoints)) { + breakpoints = {min: breakpoints} } - return _(breakpoint).map((value, feature) => { - feature = _.get( - { - min: 'min-width', - max: 'max-width', - }, - feature, - feature - ) - return `(${feature}: ${value})` - }).join(' and ') + if (!_.isArray(breakpoints)) { + breakpoints = [breakpoints] + } + return _(breakpoints).map((breakpoint) => { + return _(breakpoint).map((value, feature) => { + feature = _.get( + { + min: 'min-width', + max: 'max-width', + }, + feature, + feature + ) + return `(${feature}: ${value})` + }).join(' and ') + }).join(', ') } export default function(options) {