2018-03-05 16:32:22 -05:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
import postcss from 'postcss'
|
2018-03-06 14:08:30 -05:00
|
|
|
import postcssNested from 'postcss-nested'
|
|
|
|
|
import postcssJs from 'postcss-js'
|
2018-03-05 16:32:22 -05:00
|
|
|
|
2018-03-06 14:08:30 -05:00
|
|
|
export default function parseObjectStyles(styles) {
|
2018-03-05 16:32:22 -05:00
|
|
|
if (!Array.isArray(styles)) {
|
|
|
|
|
return parseObjectStyles([styles])
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 08:05:51 +02:00
|
|
|
return _.flatMap(styles, style => {
|
|
|
|
|
return postcss([
|
|
|
|
|
postcssNested({
|
|
|
|
|
bubble: ['screen'],
|
|
|
|
|
}),
|
|
|
|
|
]).process(style, {
|
|
|
|
|
parser: postcssJs,
|
|
|
|
|
}).root.nodes
|
|
|
|
|
})
|
2018-03-05 16:32:22 -05:00
|
|
|
}
|