Created
April 3, 2020 20:48
-
-
Save tastycode/d340b38fc1bb256debf9c5a95b4c358f 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
let final = "" | |
for (let el in styles ) { | |
const tagName = el.charAt(0).toUpperCase() + el.slice(1) | |
const rules = styles[el] | |
const transformedRules = Object.keys(rules).map( ruleName => { | |
const cssRule = ruleName.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase(); | |
const convertedStyle = ` ${cssRule}: ${rules[ruleName]};` | |
return convertedStyle | |
}).join("\n") | |
const finalComponent = `const ${tagName} = styled(View)\` | |
${transformedRules} | |
\`` | |
final += `${finalComponent}\n` | |
} | |
console.log(final) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment