Created
June 9, 2020 14:59
-
-
Save jsmanifest/ad08270f2a1db770afb1806a1903f59e 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 resolveStyles(component) { | |
let result = {} | |
// Restrict it from displaying in a smaller size | |
if (component.style.height < 300) { | |
result['height'] = 300 | |
} | |
if (component.type === 'button') { | |
// Give all button components a dashed teal border | |
result['border'] = '1px dashed teal' | |
} | |
if (component.type === 'input') { | |
if (component.inputType === 'email') { | |
// Uppercase every letter for email inputs | |
result['textTransform'] = 'uppercase' | |
} | |
} | |
return result | |
} | |
function resolveChildren(component) { | |
if (Array.isArray(component.children)) { | |
return { | |
children: component.children.map((child) => { | |
return resolveStyles(child) | |
}), | |
} | |
} | |
} | |
function start(component, resolvers = []) { | |
return resolvers.reduce((acc, resolve) => { | |
return resolve(acc) | |
}, component) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment