Created
May 28, 2019 21:32
-
-
Save jepser/fbca1b314fd1b479e69e8b04c127d410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Call the styles factory for with the correct props for each media query | |
* @param {function} stylesGenerator function that generates the styles | |
* | |
* @returns {array} array of styles to be applied for the registered media queries | |
*/ | |
export const generateResponsiveStyles = stylesGenerator => props => | |
Object.keys(mediaqueries).reduce((rules, mq) => { | |
if (!props[mq]) return rules; | |
const styles = mediaqueries[mq]` | |
${stylesGenerator(props[mq])} | |
`; | |
return [...rules, styles]; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment