|
|
- 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
- })
|