@elmethis/vue 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, createElementBlock, openBlock, normalizeClass, createVNode, Transition, unref, withCtx, normalizeStyle, createElementVNode, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, watch, createElementBlock, openBlock, normalizeClass, createVNode, createElementVNode, Transition, unref, withCtx, withDirectives, vShow, normalizeStyle, createCommentVNode } from "vue";
2
2
  import ElmRectangleWave from "../fallback/ElmRectangleWave.vue.mjs";
3
3
  import ElmDotLoadingIcon from "../icon/ElmDotLoadingIcon.vue.mjs";
4
4
  import { useImage, onKeyStroke, useIntersectionObserver } from "@vueuse/core";
@@ -20,6 +20,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
20
20
  setup(__props) {
21
21
  const props = __props;
22
22
  const { isLoading, error } = useImage({ src: props.src });
23
+ const isLoaded = ref(false);
24
+ watch(
25
+ () => props.src,
26
+ () => {
27
+ isLoaded.value = false;
28
+ }
29
+ );
23
30
  const isModalOpen = ref(false);
24
31
  onKeyStroke("Escape", (e) => {
25
32
  e.preventDefault();
@@ -37,7 +44,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
37
44
  ref: target
38
45
  }, [
39
46
  createVNode(Transition, {
40
- mode: "out-in",
41
47
  "enter-from-class": unref(fadeStyle)["fade-enter-from"],
42
48
  "enter-active-class": unref(fadeStyle)["fade-enter-active"],
43
49
  "enter-to-class": unref(fadeStyle)["fade-fast-enter-to"],
@@ -46,8 +52,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
46
52
  "leave-to-class": unref(fadeStyle)["fade-fast-leave-to"]
47
53
  }, {
48
54
  default: withCtx(() => [
49
- unref(error) ? (openBlock(), createElementBlock("div", {
50
- key: 0,
55
+ withDirectives(createElementVNode("div", {
51
56
  class: normalizeClass(_ctx.$style.error)
52
57
  }, [
53
58
  createVNode(ElmInlineText, {
@@ -55,31 +60,71 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
55
60
  color: "#c56565",
56
61
  size: "1.5rem"
57
62
  })
58
- ], 2)) : unref(isLoading) ? (openBlock(), createElementBlock("div", {
59
- key: 1,
60
- class: normalizeClass(_ctx.$style.fallback),
61
- style: normalizeStyle({ "--margin-block": __props.margin })
62
- }, [
63
- createVNode(ElmRectangleWave),
64
- createElementVNode("div", null, [
65
- createVNode(ElmDotLoadingIcon)
66
- ])
67
- ], 6)) : (openBlock(), createElementBlock("img", {
68
- key: 2,
69
- class: normalizeClass(__props.block ? _ctx.$style["image-block"] : _ctx.$style.image),
70
- src: __props.src,
71
- alt: __props.alt,
72
- onClick: _cache[0] || (_cache[0] = ($event) => {
73
- if (__props.enableModal) isModalOpen.value = true;
74
- }),
75
- style: normalizeStyle({
76
- "--cursor": __props.enableModal ? "zoom-in" : void 0,
77
- "--margin-block": __props.margin
78
- })
79
- }, null, 14, _hoisted_1))
63
+ ], 2), [
64
+ [vShow, unref(error)]
65
+ ])
80
66
  ]),
81
67
  _: 1
82
68
  }, 8, ["enter-from-class", "enter-active-class", "enter-to-class", "leave-from-class", "leave-active-class", "leave-to-class"]),
69
+ createElementVNode("div", {
70
+ class: normalizeClass(_ctx.$style["image-frame"]),
71
+ style: normalizeStyle({
72
+ "--margin-block": __props.margin,
73
+ aspectRatio: __props.block ? "1200 / 630" : void 0
74
+ })
75
+ }, [
76
+ createVNode(Transition, {
77
+ "enter-from-class": unref(fadeStyle)["fade-enter-from"],
78
+ "enter-active-class": unref(fadeStyle)["fade-enter-active"],
79
+ "enter-to-class": unref(fadeStyle)["fade-fast-enter-to"],
80
+ "leave-from-class": unref(fadeStyle)["fade-fast-leave-from"],
81
+ "leave-active-class": unref(fadeStyle)["fade-fast-leave-active"],
82
+ "leave-to-class": unref(fadeStyle)["fade-fast-leave-to"]
83
+ }, {
84
+ default: withCtx(() => [
85
+ withDirectives(createElementVNode("div", {
86
+ class: normalizeClass(_ctx.$style.fallback)
87
+ }, [
88
+ createVNode(ElmRectangleWave),
89
+ createElementVNode("div", null, [
90
+ createVNode(ElmDotLoadingIcon)
91
+ ])
92
+ ], 2), [
93
+ [vShow, unref(isLoading)]
94
+ ])
95
+ ]),
96
+ _: 1
97
+ }, 8, ["enter-from-class", "enter-active-class", "enter-to-class", "leave-from-class", "leave-active-class", "leave-to-class"]),
98
+ createVNode(Transition, {
99
+ "enter-from-class": unref(fadeStyle)["fade-enter-from"],
100
+ "enter-active-class": unref(fadeStyle)["fade-enter-active"],
101
+ "enter-to-class": unref(fadeStyle)["fade-fast-enter-to"],
102
+ "leave-from-class": unref(fadeStyle)["fade-fast-leave-from"],
103
+ "leave-active-class": unref(fadeStyle)["fade-fast-leave-active"],
104
+ "leave-to-class": unref(fadeStyle)["fade-fast-leave-to"]
105
+ }, {
106
+ default: withCtx(() => [
107
+ createElementVNode("img", {
108
+ class: normalizeClass(__props.block ? _ctx.$style["image-block"] : _ctx.$style.image),
109
+ src: __props.src,
110
+ alt: __props.alt,
111
+ onClick: _cache[0] || (_cache[0] = ($event) => {
112
+ if (__props.enableModal) isModalOpen.value = true;
113
+ }),
114
+ onLoad: _cache[1] || (_cache[1] = ($event) => isLoaded.value = true),
115
+ onError: _cache[2] || (_cache[2] = ($event) => isLoaded.value = false),
116
+ style: normalizeStyle({
117
+ cursor: __props.enableModal ? "zoom-in" : void 0,
118
+ "--margin-block": __props.margin,
119
+ opacity: isLoaded.value && !unref(error) ? 1 : 0,
120
+ transition: "opacity 220ms ease",
121
+ pointerEvents: isLoaded.value && !unref(error) ? void 0 : "none"
122
+ })
123
+ }, null, 46, _hoisted_1)
124
+ ]),
125
+ _: 1
126
+ }, 8, ["enter-from-class", "enter-active-class", "enter-to-class", "leave-from-class", "leave-active-class", "leave-to-class"])
127
+ ], 6),
83
128
  createVNode(Transition, {
84
129
  "enter-from-class": unref(fadeStyle)["fade-enter-from"],
85
130
  "enter-active-class": unref(fadeStyle)["fade-enter-active"],
@@ -122,7 +167,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
122
167
  isModalOpen.value ? (openBlock(), createElementBlock("div", {
123
168
  key: 0,
124
169
  class: normalizeClass(_ctx.$style.modal),
125
- onClick: _cache[1] || (_cache[1] = ($event) => isModalOpen.value = false)
170
+ onClick: _cache[3] || (_cache[3] = ($event) => isModalOpen.value = false)
126
171
  }, [
127
172
  createElementVNode("img", {
128
173
  class: normalizeClass(_ctx.$style["modal-image"]),
@@ -3,27 +3,28 @@
3
3
  try {
4
4
  if (typeof document != "undefined") {
5
5
  var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode("._wrapper_5m5jq_1{width:100%;display:flex;flex-direction:column;align-items:center;opacity:var(--opacity);transition:opacity .4s}._image_5m5jq_10{display:block;margin-block:var(--margin-block);max-width:100%;max-height:100vh;cursor:var(--cursor)}._error_5m5jq_18{display:flex;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;min-height:10rem;line-height:1.5rem;color:#c56565}._fallback_5m5jq_30{margin-block:var(--margin-block);margin:0;padding:0;position:relative;width:100%;z-index:1;display:flex;justify-content:center;align-items:center;aspect-ratio:1200/630}._image-block_5m5jq_43{overflow:hidden;border-radius:.25rem;box-shadow:0 0 .125rem #0000004d;display:block;max-width:100%;max-height:100vh;cursor:var(--cursor)}._alt-container_5m5jq_53{max-width:80%;margin:1rem;display:flex;justify-content:center;align-items:center;gap:1rem;color:#6987b8;opacity:.8}._modal_5m5jq_64{position:fixed;z-index:10;top:0;left:0;width:100%;height:100vh;display:flex;justify-content:center;align-items:center;background-color:#23262acc;cursor:zoom-out}._modal-image_5m5jq_78{display:block;max-width:100%;cursor:zoom-out}"));
6
+ elementStyle.appendChild(document.createTextNode("._wrapper_i5hlt_1{width:100%;display:flex;flex-direction:column;align-items:center;opacity:var(--opacity);transition:opacity .4s}._error_i5hlt_10{display:flex;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;min-height:10rem;line-height:1.5rem;color:#c56565}._image-frame_i5hlt_22{position:relative;width:100%}._fallback_i5hlt_27{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2;display:flex;justify-content:center;align-items:center;aspect-ratio:1200/630}._image_i5hlt_22{display:block;margin-block:var(--margin-block);max-width:100%;max-height:100vh;transition:opacity .22s ease;z-index:0}._image-block_i5hlt_49{position:absolute;inset:0;width:100%;height:100%;-o-object-fit:cover;object-fit:cover;overflow:hidden;border-radius:.25rem;box-shadow:0 0 .125rem #0000004d;z-index:0;transition:opacity .22s ease}._alt-container_i5hlt_62{max-width:80%;margin:1rem;display:flex;justify-content:center;align-items:center;gap:1rem;color:#6987b8;opacity:.8}._modal_i5hlt_73{position:fixed;z-index:10;top:0;left:0;width:100%;height:100vh;display:flex;justify-content:center;align-items:center;background-color:#23262acc;cursor:zoom-out}._modal-image_i5hlt_87{display:block;max-width:100%;cursor:zoom-out}"));
7
7
  document.head.appendChild(elementStyle);
8
8
  }
9
9
  } catch (e) {
10
10
  console.error("vite-plugin-css-injected-by-js", e);
11
11
  }
12
12
  })();
13
- const wrapper = "_wrapper_5m5jq_1";
14
- const image = "_image_5m5jq_10";
15
- const error = "_error_5m5jq_18";
16
- const fallback = "_fallback_5m5jq_30";
17
- const modal = "_modal_5m5jq_64";
13
+ const wrapper = "_wrapper_i5hlt_1";
14
+ const error = "_error_i5hlt_10";
15
+ const fallback = "_fallback_i5hlt_27";
16
+ const image = "_image_i5hlt_22";
17
+ const modal = "_modal_i5hlt_73";
18
18
  const style0 = {
19
19
  wrapper,
20
- image,
21
20
  error,
21
+ "image-frame": "_image-frame_i5hlt_22",
22
22
  fallback,
23
- "image-block": "_image-block_5m5jq_43",
24
- "alt-container": "_alt-container_5m5jq_53",
23
+ image,
24
+ "image-block": "_image-block_i5hlt_49",
25
+ "alt-container": "_alt-container_i5hlt_62",
25
26
  modal,
26
- "modal-image": "_modal-image_5m5jq_78"
27
+ "modal-image": "_modal-image_i5hlt_87"
27
28
  };
28
29
  export {
29
30
  style0 as default,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/vue",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },