alpinejs-flux
Version:
Simplifies the process of applying CSS classes with x-transition as a template and makes them reusable within single attribute.
13 lines (10 loc) • 343 B
JavaScript
export default function ( templateName ) {
const words = templateName.split( '-' );
if ( words.length === 1 ) {
return templateName;
}
const camelCasedWords = words.slice( 1 ).map( word => {
return word.charAt( 0 ).toUpperCase() + word.slice( 1 );
} );
return words[0] + camelCasedWords.join( '' );
}