Created
June 28, 2017 17:17
-
-
Save danielpost/1a5eef80a3745a2842f44abbcf2ef69e to your computer and use it in GitHub Desktop.
Vue Functional Component
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
// Used to change camelCase props to kebab-case classes | |
import decamelize from 'decamelize' | |
export function propsToClasses (base, props) { | |
return Object.keys(props).reduce((classes, key) => { | |
if (props[key] && typeof props[key] === 'boolean') { | |
classes += ` ${base}--${decamelize(key, '-')}` | |
} | |
return classes | |
}, base) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment