@mixd-id/web-scaffold 0.1.230406155 → 0.1.230406156
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.
package/package.json
CHANGED
package/src/components/Image.vue
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
<div :class="compClass" @click="onClick" @mousemove="onMouseMove" @mousedown="onMouseDown">
|
|
3
3
|
|
|
4
4
|
<slot v-if="$slots['empty'] && status === 0" name="empty" :instance="this"></slot>
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
<slot v-else-if="$slots['loading'] && status === 1" name="loading" :instance="this"></slot>
|
|
6
7
|
<div v-else-if="!$slots['loading'] && status === 1 && spinnerType === 'spinner'" :class="$style.loading">
|
|
7
8
|
<svg class="animate-spin aspect-square w-[15%] min-w-[14px] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
8
9
|
</div>
|
|
10
|
+
|
|
9
11
|
<slot v-else-if="$slots['error'] && status === 3" name="error" :instance="this"></slot>
|
|
12
|
+
|
|
10
13
|
<img v-else :class="computedItemClass" :src="actualSrc" ref="img" />
|
|
11
14
|
|
|
12
|
-
<slot
|
|
15
|
+
<slot></slot>
|
|
13
16
|
|
|
14
17
|
<input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
|
|
15
18
|
|
|
@@ -67,7 +70,7 @@ export default{
|
|
|
67
70
|
|
|
68
71
|
actualSrc(){
|
|
69
72
|
if(typeof window !== 'undefined'){
|
|
70
|
-
return this.mediaSrc[this.$screenPrefix]
|
|
73
|
+
return this.mediaSrc[this.$screenPrefix.value]
|
|
71
74
|
}
|
|
72
75
|
},
|
|
73
76
|
|
|
@@ -117,6 +120,12 @@ export default{
|
|
|
117
120
|
|
|
118
121
|
methods:{
|
|
119
122
|
|
|
123
|
+
reset(){
|
|
124
|
+
this.$refs.file.value = null
|
|
125
|
+
this.status = 0
|
|
126
|
+
this.$emit('change', null, null)
|
|
127
|
+
},
|
|
128
|
+
|
|
120
129
|
onResize(){
|
|
121
130
|
this.loadSrc()
|
|
122
131
|
},
|
|
@@ -140,19 +149,18 @@ export default{
|
|
|
140
149
|
async loadSrc(){
|
|
141
150
|
|
|
142
151
|
// src: String | Array | File
|
|
143
|
-
|
|
144
152
|
if(!this.visibled){
|
|
145
153
|
return
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
if(this.$screenPrefix in this.mediaSrc){
|
|
156
|
+
if(this.$screenPrefix.value in this.mediaSrc){
|
|
149
157
|
return
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
if(typeof this.src === 'string') {
|
|
153
161
|
|
|
154
162
|
if (this.src.startsWith('data:image')) {
|
|
155
|
-
this.mediaSrc[this.$screenPrefix] = this.src
|
|
163
|
+
this.mediaSrc[this.$screenPrefix.value] = this.src
|
|
156
164
|
this.status = 2
|
|
157
165
|
}
|
|
158
166
|
else{
|
|
@@ -183,12 +191,12 @@ export default{
|
|
|
183
191
|
img.addEventListener('load', () => {
|
|
184
192
|
if(img.getAttribute('data-src') !== this.src) return
|
|
185
193
|
this.status = 2
|
|
186
|
-
this.mediaSrc[this.$screenPrefix] = img.src
|
|
194
|
+
this.mediaSrc[this.$screenPrefix.value] = img.src
|
|
187
195
|
})
|
|
188
196
|
img.addEventListener('error', (err) => {
|
|
189
197
|
if(img.getAttribute('data-src') !== this.src) return
|
|
190
198
|
this.status = 3
|
|
191
|
-
this.mediaSrc[this.$screenPrefix] = this.defaultSrc
|
|
199
|
+
this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
|
|
192
200
|
})
|
|
193
201
|
img.src = imgSrc
|
|
194
202
|
img.setAttribute('data-src', this.src)
|
|
@@ -215,11 +223,11 @@ export default{
|
|
|
215
223
|
var img = new Image()
|
|
216
224
|
img.addEventListener('load', () => {
|
|
217
225
|
this.status = 2
|
|
218
|
-
this.mediaSrc[this.$screenPrefix] = img.src
|
|
226
|
+
this.mediaSrc[this.$screenPrefix.value] = img.src
|
|
219
227
|
})
|
|
220
228
|
img.addEventListener('error', (err) => {
|
|
221
229
|
this.status = 3
|
|
222
|
-
this.mediaSrc[this.$screenPrefix] = this.defaultSrc
|
|
230
|
+
this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
|
|
223
231
|
})
|
|
224
232
|
img.src = imgSrc
|
|
225
233
|
this.status = 1
|
|
@@ -230,12 +238,12 @@ export default{
|
|
|
230
238
|
|
|
231
239
|
reader.addEventListener('load', () => {
|
|
232
240
|
this.status = 2
|
|
233
|
-
this.mediaSrc[this.$screenPrefix] = reader.result
|
|
241
|
+
this.mediaSrc[this.$screenPrefix.value] = reader.result
|
|
234
242
|
}, false)
|
|
235
243
|
|
|
236
244
|
reader.addEventListener('error', () => {
|
|
237
245
|
this.status = 3
|
|
238
|
-
this.mediaSrc[this.$screenPrefix] = this.defaultSrc
|
|
246
|
+
this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
|
|
239
247
|
})
|
|
240
248
|
|
|
241
249
|
reader.readAsDataURL(this.src)
|
|
@@ -3,15 +3,24 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="flex flex-col gap-1">
|
|
5
5
|
<label class="flex-1 text-text-400">Src</label>
|
|
6
|
-
<Image ref="image"
|
|
6
|
+
<Image :ref="`image${index}`"
|
|
7
7
|
v-for="(_viewType, index) in viewTypes"
|
|
8
8
|
v-show="_viewType.value === viewType"
|
|
9
9
|
:src="imageSrc(item.props.src[index])"
|
|
10
|
-
class="w-[120px] bg-text-50 rounded-lg"
|
|
10
|
+
class="w-[120px] min-h-[60px] bg-text-50 rounded-lg"
|
|
11
11
|
:editable="true"
|
|
12
|
-
@click="$refs
|
|
13
|
-
@change="(base64, file) => { item.props.src[index] = file; apply() }"
|
|
14
|
-
|
|
12
|
+
@click="$refs[`image${index}`][0].edit()"
|
|
13
|
+
@change="(base64, file) => { item.props.src[index] = file; apply() }">
|
|
14
|
+
<button type="button" class="absolute top-1 right-1 rounded-full bg-white" v-if="item.props.src[index]"
|
|
15
|
+
@click.stop="$refs[`image${index}`][0].reset()">
|
|
16
|
+
<svg width="19" height="19" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg>
|
|
17
|
+
</button>
|
|
18
|
+
<template #empty>
|
|
19
|
+
<div class="flex items-center justify-center absolute left-0 top-0 right-0 bottom-0">
|
|
20
|
+
<label class="text-text-300">Upload</label>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
</Image>
|
|
15
24
|
</div>
|
|
16
25
|
|
|
17
26
|
<div>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<template #default="{ context }">
|
|
19
19
|
<div class="flex-1">
|
|
20
20
|
|
|
21
|
-
<div v-if="tabIndex === 1" class="p-6 grid grid-cols-3 gap-
|
|
21
|
+
<div v-if="tabIndex === 1" class="p-6 grid grid-cols-3 gap-4">
|
|
22
22
|
<button v-for="component in groupedComponents['Components']"
|
|
23
23
|
type="button"
|
|
24
24
|
@click="apply(component.type)"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</button>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
|
-
<div v-if="tabIndex === 2" class="p-6 grid grid-cols-
|
|
30
|
+
<div v-if="tabIndex === 2" class="p-6 grid grid-cols-3 gap-4">
|
|
31
31
|
<button v-for="component in groupedComponents['Containers']"
|
|
32
32
|
type="button"
|
|
33
33
|
@click="apply(component.type)"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
</button>
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
-
<div v-if="tabIndex === 3" class="p-6 grid gap-
|
|
39
|
+
<div v-if="tabIndex === 3" class="p-6 grid grid-cols-3 gap-4">
|
|
40
40
|
<button v-for="component in groupedComponents['Widgets']"
|
|
41
41
|
type="button"
|
|
42
42
|
@click="apply(component.type)"
|
|
@@ -117,7 +117,7 @@ export default{
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
.compSelectorBtn{
|
|
120
|
-
@apply block w-full rounded-lg p-3 text-left;
|
|
120
|
+
@apply block w-full rounded-lg p-3 text-left border-[1px] border-text-50;
|
|
121
121
|
@apply bg-base-400 hover:bg-base-300 dark:bg-base-400 dark:hover:bg-base-500;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -323,12 +323,14 @@
|
|
|
323
323
|
<div class="px-4 bg-base-300 pt-2 relative">
|
|
324
324
|
<Tabs v-model="store.viewType" :items="viewTypes" variant="minimal">
|
|
325
325
|
<template #tab="{ item }">
|
|
326
|
-
<div v-if="item.value === ''" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md"
|
|
326
|
+
<div v-if="item.value === ''" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md overflow-hidden"
|
|
327
327
|
:class="store.viewType === item.value ? 'bg-base-400 border-text-50' : 'border-transparent'">
|
|
328
|
+
<div v-if="store.viewType === item.value" class="absolute top-0 left-0 right-0 h-[2px] bg-primary"></div>
|
|
328
329
|
Mobile
|
|
329
330
|
</div>
|
|
330
|
-
<div v-else-if="item.value === 'md:'" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md"
|
|
331
|
+
<div v-else-if="item.value === 'md:'" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md overflow-hidden"
|
|
331
332
|
:class="store.viewType === item.value ? 'bg-base-400 border-text-50' : 'border-transparent'">
|
|
333
|
+
<div v-if="store.viewType === item.value" class="absolute top-0 left-0 right-0 h-[2px] bg-primary"></div>
|
|
332
334
|
Tablet
|
|
333
335
|
</div>
|
|
334
336
|
</template>
|