Skip to content

Instantly share code, notes, and snippets.

@dburles
Created October 23, 2019 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dburles/3d48b022a33cb7a72b8716f046d0b053 to your computer and use it in GitHub Desktop.
Save dburles/3d48b022a33cb7a72b8716f046d0b053 to your computer and use it in GitHub Desktop.
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