icon.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. import { SuperComponent, wxComponent } from '../common/src/index';
  8. import config from '../common/config';
  9. import props from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-icon`;
  12. const sizeKeywordMap = {
  13. xs: '24rpx',
  14. small: '28rpx',
  15. middle: '32rpx',
  16. large: '36rpx',
  17. xl: '40rpx',
  18. };
  19. let Icon = class Icon extends SuperComponent {
  20. constructor() {
  21. super(...arguments);
  22. this.externalClasses = ['t-class'];
  23. this.properties = props;
  24. this.data = {
  25. classPrefix: name,
  26. fontSize: '',
  27. };
  28. this.observers = {
  29. size(val) {
  30. let fontSize = val;
  31. if (Object.prototype.hasOwnProperty.call(sizeKeywordMap, val)) {
  32. fontSize = sizeKeywordMap[val];
  33. }
  34. this.setData({ fontSize });
  35. },
  36. };
  37. this.methods = {
  38. onTap(event) {
  39. this.triggerEvent('click', event.detail);
  40. },
  41. };
  42. }
  43. };
  44. Icon = __decorate([
  45. wxComponent()
  46. ], Icon);
  47. export default Icon;
  48. //# sourceMappingURL=icon.js.map