Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "facepaint", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Responsive style values for css-in-js.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -11,3 +11,3 @@ # facepaint | ||
const mq = facepaint(css, [ | ||
const mq = facepaint([ | ||
'@media(min-width: 420px)', | ||
@@ -18,3 +18,3 @@ '@media(min-width: 920px)', | ||
const myClassName = mq({ | ||
const myClassName = css(mq({ | ||
width: ['25%', '50%', '75%', '100%'], | ||
@@ -27,3 +27,3 @@ '& .foo': { | ||
} | ||
}) | ||
})) | ||
``` | ||
@@ -30,0 +30,0 @@ |
/* eslint-disable no-param-reassign */ | ||
export default function(css, breakpoints) { | ||
const mq = [""].concat(breakpoints); | ||
export default function(breakpoints) { | ||
const mq = [''].concat(breakpoints) | ||
function flatten(obj) { | ||
return css( | ||
Object.keys(obj).reduce((slots, key) => { | ||
if (Array.isArray(obj[key])) { | ||
obj[key].forEach((v, index) => { | ||
if (index === 0) { | ||
slots[key] = v; | ||
} else if (!slots[mq[index]]) { | ||
slots[mq[index]] = { [key]: v }; | ||
} else { | ||
slots[mq[index]][key] = v; | ||
} | ||
}); | ||
} else if (typeof obj[key] === "object") { | ||
slots[key] = flatten(obj[key]); | ||
} else { | ||
slots[key] = obj[key]; | ||
} | ||
return slots; | ||
}, {}) | ||
); | ||
return Object.keys(obj).reduce((slots, key) => { | ||
if (Array.isArray(obj[key])) { | ||
obj[key].forEach((v, index) => { | ||
if (index === 0) { | ||
slots[key] = v | ||
} else if (!slots[mq[index]]) { | ||
slots[mq[index]] = { [key]: v } | ||
} else { | ||
slots[mq[index]][key] = v | ||
} | ||
}) | ||
} else if (typeof obj[key] === 'object') { | ||
slots[key] = flatten(obj[key]) | ||
} else { | ||
slots[key] = obj[key] | ||
} | ||
return slots | ||
}, {}) | ||
} | ||
return (...values) => values.map(flatten); | ||
return (...values) => values.map(flatten) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12944
96