Created
February 4, 2020 19:58
-
-
Save crswll/de1a1703c07e47957dc6a212c7549edf to your computer and use it in GitHub Desktop.
This file contains 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
const getTailwindExtend = themeUiConfig => { | |
const propertyMap = { | |
"borderStyles": ["borderStyle"], | |
"borderWidths": ["borderWidth"], | |
"breakpoints": ["screens"], | |
"colors": ["colors"], | |
"letterSpacings": ["letterSpacing"], | |
"lineHeights": ["lineHeight"], | |
"radii": ["borderRadius"], | |
"fontWeights": ["fontWeight"], | |
"fontSizes": ["fontSize"], | |
"shadows": ["boxShadow"], | |
"space": ["spacing"], | |
"zIndices": ["zIndex"], | |
"sizes": [ | |
"width", | |
"minWidth", | |
"maxWidth", | |
"height", | |
"minHeight", | |
"maxHeight", | |
], | |
} | |
return Object.keys(themeUiConfig).reduce((tailwindConfig, themeUiKey) => { | |
const additionalTailwindConfig = propertyMap[themeUiKey] && | |
propertyMap[themeUiKey].reduce((acc, tailwindConfigKey) => ({ | |
...acc, | |
[tailwindConfigKey]: themeUiConfig[themeUiKey], | |
}), {}) | |
return { | |
...tailwindConfig, | |
...(additionalTailwindConfig || {}), | |
} | |
}, {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment