@elmethis/vue 0.2.2 → 0.2.4
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,
|
|
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
|
-
|
|
50
|
-
key: 0,
|
|
55
|
+
withDirectives(createElementVNode("div", {
|
|
51
56
|
class: normalizeClass(_ctx.$style.error)
|
|
52
57
|
}, [
|
|
53
58
|
createVNode(ElmInlineText, {
|
|
@@ -55,31 +60,70 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
55
60
|
color: "#c56565",
|
|
56
61
|
size: "1.5rem"
|
|
57
62
|
})
|
|
58
|
-
], 2)
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
})
|
|
74
|
+
}, [
|
|
75
|
+
createVNode(Transition, {
|
|
76
|
+
"enter-from-class": unref(fadeStyle)["fade-enter-from"],
|
|
77
|
+
"enter-active-class": unref(fadeStyle)["fade-enter-active"],
|
|
78
|
+
"enter-to-class": unref(fadeStyle)["fade-fast-enter-to"],
|
|
79
|
+
"leave-from-class": unref(fadeStyle)["fade-fast-leave-from"],
|
|
80
|
+
"leave-active-class": unref(fadeStyle)["fade-fast-leave-active"],
|
|
81
|
+
"leave-to-class": unref(fadeStyle)["fade-fast-leave-to"]
|
|
82
|
+
}, {
|
|
83
|
+
default: withCtx(() => [
|
|
84
|
+
withDirectives(createElementVNode("div", {
|
|
85
|
+
class: normalizeClass(_ctx.$style.fallback)
|
|
86
|
+
}, [
|
|
87
|
+
createVNode(ElmRectangleWave),
|
|
88
|
+
createElementVNode("div", null, [
|
|
89
|
+
createVNode(ElmDotLoadingIcon)
|
|
90
|
+
])
|
|
91
|
+
], 2), [
|
|
92
|
+
[vShow, unref(isLoading)]
|
|
93
|
+
])
|
|
94
|
+
]),
|
|
95
|
+
_: 1
|
|
96
|
+
}, 8, ["enter-from-class", "enter-active-class", "enter-to-class", "leave-from-class", "leave-active-class", "leave-to-class"]),
|
|
97
|
+
createVNode(Transition, {
|
|
98
|
+
"enter-from-class": unref(fadeStyle)["fade-enter-from"],
|
|
99
|
+
"enter-active-class": unref(fadeStyle)["fade-enter-active"],
|
|
100
|
+
"enter-to-class": unref(fadeStyle)["fade-fast-enter-to"],
|
|
101
|
+
"leave-from-class": unref(fadeStyle)["fade-fast-leave-from"],
|
|
102
|
+
"leave-active-class": unref(fadeStyle)["fade-fast-leave-active"],
|
|
103
|
+
"leave-to-class": unref(fadeStyle)["fade-fast-leave-to"]
|
|
104
|
+
}, {
|
|
105
|
+
default: withCtx(() => [
|
|
106
|
+
createElementVNode("img", {
|
|
107
|
+
class: normalizeClass(__props.block ? _ctx.$style["image-block"] : _ctx.$style.image),
|
|
108
|
+
src: __props.src,
|
|
109
|
+
alt: __props.alt,
|
|
110
|
+
onClick: _cache[0] || (_cache[0] = ($event) => {
|
|
111
|
+
if (__props.enableModal) isModalOpen.value = true;
|
|
112
|
+
}),
|
|
113
|
+
onLoad: _cache[1] || (_cache[1] = ($event) => isLoaded.value = true),
|
|
114
|
+
onError: _cache[2] || (_cache[2] = ($event) => isLoaded.value = false),
|
|
115
|
+
style: normalizeStyle({
|
|
116
|
+
cursor: __props.enableModal ? "zoom-in" : void 0,
|
|
117
|
+
"--margin-block": __props.margin,
|
|
118
|
+
opacity: isLoaded.value && !unref(error) ? 1 : 0,
|
|
119
|
+
transition: "opacity 220ms ease",
|
|
120
|
+
pointerEvents: isLoaded.value && !unref(error) ? void 0 : "none"
|
|
121
|
+
})
|
|
122
|
+
}, null, 46, _hoisted_1)
|
|
123
|
+
]),
|
|
124
|
+
_: 1
|
|
125
|
+
}, 8, ["enter-from-class", "enter-active-class", "enter-to-class", "leave-from-class", "leave-active-class", "leave-to-class"])
|
|
126
|
+
], 6),
|
|
83
127
|
createVNode(Transition, {
|
|
84
128
|
"enter-from-class": unref(fadeStyle)["fade-enter-from"],
|
|
85
129
|
"enter-active-class": unref(fadeStyle)["fade-enter-active"],
|
|
@@ -122,7 +166,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
122
166
|
isModalOpen.value ? (openBlock(), createElementBlock("div", {
|
|
123
167
|
key: 0,
|
|
124
168
|
class: normalizeClass(_ctx.$style.modal),
|
|
125
|
-
onClick: _cache[
|
|
169
|
+
onClick: _cache[3] || (_cache[3] = ($event) => isModalOpen.value = false)
|
|
126
170
|
}, [
|
|
127
171
|
createElementVNode("img", {
|
|
128
172
|
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(".
|
|
6
|
+
elementStyle.appendChild(document.createTextNode("._wrapper_yva5m_1{width:100%;display:flex;flex-direction:column;align-items:center;opacity:var(--opacity);transition:opacity .4s}._error_yva5m_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_yva5m_22{position:relative;width:100%;aspect-ratio:1200/630}._fallback_yva5m_28{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_yva5m_22{display:block;margin-block:var(--margin-block);max-width:100%;max-height:100vh;transition:opacity .22s ease;z-index:0}._image-block_yva5m_50{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_yva5m_63{max-width:80%;margin:1rem;display:flex;justify-content:center;align-items:center;gap:1rem;color:#6987b8;opacity:.8}._modal_yva5m_74{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_yva5m_88{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 = "
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const modal = "
|
|
13
|
+
const wrapper = "_wrapper_yva5m_1";
|
|
14
|
+
const error = "_error_yva5m_10";
|
|
15
|
+
const fallback = "_fallback_yva5m_28";
|
|
16
|
+
const image = "_image_yva5m_22";
|
|
17
|
+
const modal = "_modal_yva5m_74";
|
|
18
18
|
const style0 = {
|
|
19
19
|
wrapper,
|
|
20
|
-
image,
|
|
21
20
|
error,
|
|
21
|
+
"image-frame": "_image-frame_yva5m_22",
|
|
22
22
|
fallback,
|
|
23
|
-
|
|
24
|
-
"
|
|
23
|
+
image,
|
|
24
|
+
"image-block": "_image-block_yva5m_50",
|
|
25
|
+
"alt-container": "_alt-container_yva5m_63",
|
|
25
26
|
modal,
|
|
26
|
-
"modal-image": "_modal-
|
|
27
|
+
"modal-image": "_modal-image_yva5m_88"
|
|
27
28
|
};
|
|
28
29
|
export {
|
|
29
30
|
style0 as default,
|