index.wxs 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* eslint-disable */
  2. var style = require('../wxs/style.wxs');
  3. var addUnit = require('../wxs/add-unit.wxs');
  4. function isImage(name) {
  5. return name.indexOf('/') !== -1;
  6. }
  7. function rootClass(data) {
  8. var classes = ['custom-class'];
  9. if (data.classPrefix !== 'van-icon') {
  10. classes.push('van-icon--custom')
  11. }
  12. if (data.classPrefix != null) {
  13. classes.push(data.classPrefix);
  14. }
  15. if (isImage(data.name)) {
  16. classes.push('van-icon--image');
  17. } else if (data.classPrefix != null) {
  18. classes.push(data.classPrefix + '-' + data.name);
  19. }
  20. return classes.join(' ');
  21. }
  22. function rootStyle(data) {
  23. return style([
  24. {
  25. color: data.color,
  26. 'font-size': addUnit(data.size),
  27. },
  28. data.customStyle,
  29. ]);
  30. }
  31. module.exports = {
  32. isImage: isImage,
  33. rootClass: rootClass,
  34. rootStyle: rootStyle,
  35. };