Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tastycode/d340b38fc1bb256debf9c5a95b4c358f to your computer and use it in GitHub Desktop.
Save tastycode/d340b38fc1bb256debf9c5a95b4c358f to your computer and use it in GitHub Desktop.
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