Created
October 23, 2019 06:45
-
-
Save dburles/3d48b022a33cb7a72b8716f046d0b053 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function compileStyles(strings, ...expressions) { | |
let styles = ''; | |
strings.forEach((string, i) => { | |
const expression = expressions[i]; | |
let expressionResult = ''; | |
if (expression !== undefined) { | |
expressionResult = expressions[i]; | |
} | |
styles += string + expressionResult; | |
}); | |
const formattedStyles = styles | |
.split(/\n/) | |
.filter(property => Boolean(property)) | |
.map(property => property.trim()) | |
.join(''); | |
return formattedStyles; | |
} | |
export default compileStyles; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment