Refactor toPairs to object map; move private function to top

This commit is contained in:
Adam Wathan 2017-08-28 11:26:34 -04:00
parent 6bbbe47e9b
commit 8eb25475b4

View File

@ -1,6 +1,23 @@
import _ from 'lodash'
import postcss from 'postcss'
function buildMediaQuery(breakpoint) {
if (_.isString(breakpoint)) {
breakpoint = {min: breakpoint}
}
return _(breakpoint).map((value, feature) => {
feature = _.get(
{
min: 'min-width',
max: 'max-width',
},
feature,
feature
)
return `(${feature}: ${value})`
}).join(' and ')
}
export default function(options) {
let breakpoints = options.breakpoints
@ -16,23 +33,3 @@ export default function(options) {
})
}
}
function buildMediaQuery(breakpoint) {
if (_.isString(breakpoint)) {
breakpoint = {min: breakpoint}
}
return _(breakpoint)
.toPairs()
.map(([feature, value]) => {
feature = _.get(
{
min: 'min-width',
max: 'max-width',
},
feature,
feature
)
return `(${feature}: ${value})`
})
.join(' and ')
}