Created
May 10, 2019 22:03
-
-
Save juice49/6f08670ea26141c210fef24891aa7f52 to your computer and use it in GitHub Desktop.
Fluid values mixin for CSS-in-JS
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
const fluid = (properties, [ minVw, maxVw ], [ minVal, maxVal ]) => properties | |
.map(property => ` | |
${property}: ${minVal}; | |
@media (min-width: ${minVw}) { | |
${property}: calc(${minVal} + ${parseFloat(maxVal) - parseFloat(minVal)} * (100vw - ${minVw}) / ${parseFloat(maxVw) - parseFloat(minVw)}); | |
} | |
@media (min-width: ${maxVw}) { | |
${property}: ${maxVal}; | |
} | |
`) | |
.join('\n') | |
export default fluid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment