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

3 years ago
3 years ago
  1. window.axios = require('axios')
  2. window.riot = require('riot')
  3. // riot-class-names-plugin.js
  4. /**
  5. * Convert object class constructs into strings
  6. * @param {Object} classes - class list as object
  7. * @returns {string} return only the classes having a truthy value
  8. */
  9. function classNames(classes) {
  10. return Object.entries(classes).reduce((acc, item) => {
  11. const [key, value] = item
  12. if (value) return [...acc, key]
  13. return acc
  14. }, []).join(' ')
  15. }
  16. // install the classNames plugin
  17. riot.install(function(component) {
  18. // add the classNames helper to all the riot components
  19. component.classNames = classNames
  20. return component
  21. })