You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
646 B

window.axios = require('axios')
window.riot = require('riot')
// riot-class-names-plugin.js
/**
* Convert object class constructs into strings
* @param {Object} classes - class list as object
* @returns {string} return only the classes having a truthy value
*/
function classNames(classes) {
return Object.entries(classes).reduce((acc, item) => {
const [key, value] = item
if (value) return [...acc, key]
return acc
}, []).join(' ')
}
// install the classNames plugin
riot.install(function(component) {
// add the classNames helper to all the riot components
component.classNames = classNames
return component
})