Last active
February 6, 2018 20:45
-
-
Save 1-800-jono/728eadf09fa6f5e6c76853e190f2c7b9 to your computer and use it in GitHub Desktop.
Creates fluid/responsive properties using 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
//The fp() “Fluid Property” SCSS mixin | |
export function fp(property, min, max, start = 320, end = 1400, clip = true, clipAtStart = true, clipAtEnd = true) { | |
const multiplier = (max - min) / (end - start) * 100; | |
const adder = (min * end - max * start) / (end - start); | |
const formula = `calc((${multiplier}vw) + (${adder}px))`; | |
return` | |
@media (max-width: ${start}px) { | |
${property}: ${min}px; | |
} | |
@media (min-width: ${end}px) { | |
${property}: ${max}px; | |
} | |
${property}: ${formula}; | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment