Created
October 25, 2020 21:14
-
-
Save phlego/94fbe6c4f5dbe457746965f71af47afc 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 serializeCSS(cssProperties: CSSProperties | undefined): string { | |
if (!cssProperties) return ''; | |
let cssString = ''; | |
for (const [key, value] of Object.entries(cssProperties)) { | |
cssString += key.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) + ':' + value + ';'; | |
} | |
return cssString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment