wd-icon.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const __default__ = {
  4. name: "wd-icon",
  5. options: {
  6. virtualHost: true,
  7. addGlobalClass: true,
  8. styleIsolation: "shared"
  9. }
  10. };
  11. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  12. ...__default__,
  13. props: common_vendor.iconProps,
  14. emits: ["click", "touch"],
  15. setup(__props, { emit: __emit }) {
  16. const props = __props;
  17. const emit = __emit;
  18. const isImage = common_vendor.computed(() => {
  19. return common_vendor.isDef(props.name) && props.name.includes("/");
  20. });
  21. const rootClass = common_vendor.computed(() => {
  22. const prefix = props.classPrefix;
  23. return `${prefix} ${props.customClass} ${isImage.value ? "wd-icon--image" : prefix + "-" + props.name}`;
  24. });
  25. const rootStyle = common_vendor.computed(() => {
  26. const style = {};
  27. if (props.color) {
  28. style["color"] = props.color;
  29. }
  30. if (props.size) {
  31. style["font-size"] = common_vendor.addUnit(props.size);
  32. }
  33. return `${common_vendor.objToStyle(style)} ${props.customStyle}`;
  34. });
  35. function handleClick(event) {
  36. emit("click", event);
  37. }
  38. return (_ctx, _cache) => {
  39. return common_vendor.e({
  40. a: isImage.value
  41. }, isImage.value ? {
  42. b: _ctx.name
  43. } : {}, {
  44. c: common_vendor.o(handleClick),
  45. d: common_vendor.n(rootClass.value),
  46. e: common_vendor.s(rootStyle.value)
  47. });
  48. };
  49. }
  50. });
  51. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d4a8410a"]]);
  52. wx.createComponent(Component);