srcdev-nuxt-components 2.1.23 → 2.2.0

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,8 +1,7 @@
1
1
  <template>
2
- <div class="carousel" ref="carouselDom">
3
- <!-- list item -->
4
- <div class="list" ref="SliderDom">
5
- <div v-for="item in galleryData" class="item" ref="SliderItemsDom">
2
+ <div class="slider-gallery" ref="sliderGalleryWrapper">
3
+ <div class="list" ref="sliderGalleryImagesList">
4
+ <div v-for="item in galleryData" class="item">
6
5
  <img :src="item.src" />
7
6
  <div class="content">
8
7
  <div class="author">{{ item.stylist }}</div>
@@ -15,9 +14,9 @@
15
14
  </div>
16
15
  </div>
17
16
  </div>
18
- <!-- list thumnail -->
19
- <div class="thumbnail" ref="thumbnailBorderDom">
20
- <div v-for="item in galleryData" class="item" ref="thumbnailItemsDom">
17
+
18
+ <div class="thumbnail" ref="sliderGalleryThumbnailsList">
19
+ <div v-for="item in galleryData" class="item">
21
20
  <img :src="item.src" />
22
21
  <div class="content">
23
22
  <div class="title">Name Slider</div>
@@ -25,23 +24,18 @@
25
24
  </div>
26
25
  </div>
27
26
  </div>
28
- <!-- next prev -->
29
27
 
30
28
  <div class="arrows">
31
29
  <button id="prev" ref="prevDom" @click.prevent="doPrevious()"><</button>
32
30
  <button id="next" ref="nextDom" @click.prevent="doNext()">></button>
33
31
  </div>
34
- <!-- time running -->
32
+
35
33
  <div class="time" ref="timeDom"></div>
36
34
  </div>
37
35
  </template>
38
36
 
39
37
  <script setup lang="ts">
40
38
  const props = defineProps({
41
- // galleryData: {
42
- // type: Array as PropType<{ src: string; alt: string }[]>,
43
- // default: () => [],
44
- // },
45
39
  styleClassPassthrough: {
46
40
  type: Array as PropType<string[]>,
47
41
  default: () => [],
@@ -60,21 +54,11 @@ interface IGalleryData {
60
54
  const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
61
55
  const galleryData = defineModel<IGalleryData[]>('galleryData');
62
56
 
63
- //step 1: get DOM
64
- const nextDom = useTemplateRef('nextDom');
65
- const prevDom = useTemplateRef('prevDom');
66
-
67
- const carouselDom = useTemplateRef('carouselDom');
68
- const SliderDom = useTemplateRef('SliderDom');
69
- const thumbnailBorderDom = useTemplateRef('thumbnailBorderDom');
70
- // let thumbnailItemsDom = useTemplateRef('thumbnailItemsDom');
57
+ const sliderGalleryWrapper = useTemplateRef('sliderGalleryWrapper');
58
+ const sliderGalleryImagesList = useTemplateRef('sliderGalleryImagesList');
59
+ const sliderGalleryThumbnailsList = useTemplateRef('sliderGalleryThumbnailsList');
71
60
  const timeDom = useTemplateRef('timeDom');
72
61
 
73
- // setup showSlider DOM
74
- const SliderItemsDom = useTemplateRef('SliderItemsDom');
75
- const thumbnailItemsDom = useTemplateRef('thumbnailItemsDom');
76
-
77
- // thumbnailBorderDom.value.appendChild(thumbnailItemsDom.value[0]);
78
62
  const timeRunning = 3000;
79
63
  const timeAutoNext = 7000;
80
64
 
@@ -93,42 +77,42 @@ let runNextAuto = setTimeout(() => {
93
77
 
94
78
  function showSlider(type: string) {
95
79
  // Get fresh references to all items by querying the DOM directly
96
- const currentSliderItems = Array.from(SliderDom.value?.children || []);
97
- const currentThumbnailItems = Array.from(thumbnailBorderDom.value?.children || []);
80
+ const currentSliderItems = Array.from(sliderGalleryImagesList.value?.children || []);
81
+ const currentThumbnailItems = Array.from(sliderGalleryThumbnailsList.value?.children || []);
98
82
 
99
83
  if (type === 'next') {
100
84
  // Move the first item to the end
101
85
  if (currentSliderItems.length) {
102
86
  const firstItem = currentSliderItems[0];
103
- SliderDom.value?.appendChild(firstItem);
87
+ sliderGalleryImagesList.value?.appendChild(firstItem);
104
88
  }
105
89
 
106
90
  if (currentThumbnailItems.length) {
107
91
  const firstThumb = currentThumbnailItems[0];
108
- thumbnailBorderDom.value?.appendChild(firstThumb);
92
+ sliderGalleryThumbnailsList.value?.appendChild(firstThumb);
109
93
  }
110
94
 
111
- carouselDom.value?.classList.add('next');
95
+ sliderGalleryWrapper.value?.classList.add('next');
112
96
  } else {
113
97
  // Move the last item to the beginning
114
98
  if (currentSliderItems.length) {
115
99
  const lastItem = currentSliderItems[currentSliderItems.length - 1];
116
- SliderDom.value?.prepend(lastItem);
100
+ sliderGalleryImagesList.value?.prepend(lastItem);
117
101
  }
118
102
 
119
103
  if (currentThumbnailItems.length) {
120
104
  const lastThumb = currentThumbnailItems[currentThumbnailItems.length - 1];
121
- thumbnailBorderDom.value?.prepend(lastThumb);
105
+ sliderGalleryThumbnailsList.value?.prepend(lastThumb);
122
106
  }
123
107
 
124
- carouselDom.value?.classList.add('prev');
108
+ sliderGalleryWrapper.value?.classList.add('prev');
125
109
  }
126
110
 
127
111
  clearTimeout(runTimeOut);
128
112
  runTimeOut = setTimeout(() => {
129
- if (carouselDom.value) {
130
- carouselDom.value.classList.remove('next');
131
- carouselDom.value.classList.remove('prev');
113
+ if (sliderGalleryWrapper.value) {
114
+ sliderGalleryWrapper.value.classList.remove('next');
115
+ sliderGalleryWrapper.value.classList.remove('prev');
132
116
  }
133
117
  }, timeRunning);
134
118
 
@@ -147,150 +131,276 @@ watch(
147
131
  </script>
148
132
 
149
133
  <style lang="css">
150
- /* carousel */
151
- .carousel {
152
- height: 100vh;
134
+ /* slider-gallery */
135
+ .slider-gallery {
136
+ height: 100svh;
153
137
  /* margin-top: -50px; */
154
138
  width: 100vw;
155
139
  overflow: hidden;
156
140
  position: absolute;
157
141
  inset: 0 0 0 0;
158
- }
159
- .carousel .list .item {
160
- width: 100%;
161
- height: 100%;
162
- position: absolute;
163
- inset: 0 0 0 0;
164
- }
165
- .carousel .list .item img {
166
- width: 100%;
167
- height: 100%;
168
- object-fit: cover;
169
- }
170
- .carousel .list .item .content {
171
- position: absolute;
172
- top: 20%;
173
- width: 1140px;
174
- max-width: 80%;
175
- left: 50%;
176
- transform: translateX(-50%);
177
- padding-right: 30%;
178
- box-sizing: border-box;
179
- color: #fff;
180
- text-shadow: 0 5px 10px #0004;
181
- }
182
- .carousel .list .item .author {
183
- font-weight: bold;
184
- letter-spacing: 10px;
185
- }
186
- .carousel .list .item .title,
187
- .carousel .list .item .topic {
188
- font-size: 5em;
189
- font-weight: bold;
190
- line-height: 1.3em;
191
- }
192
- .carousel .list .item .topic {
193
- color: #f1683a;
194
- }
195
- .carousel .list .item .buttons {
196
- display: grid;
197
- grid-template-columns: repeat(2, 130px);
198
- grid-template-rows: 40px;
199
- gap: 5px;
200
- margin-top: 20px;
201
- }
202
- .carousel .list .item .buttons button {
203
- background-color: #99999975;
204
- border: 1px solid #fff;
205
- color: #fff;
206
- letter-spacing: 3px;
207
- font-weight: 500;
208
- }
209
- /* .carousel .list .item .buttons button:nth-child(2) {
210
- background-color: transparent;
211
- border: 1px solid #fff;
212
- color: #eee;
213
- } */
214
- /* thumbail */
215
- .thumbnail {
216
- position: absolute;
217
- bottom: 50px;
218
- left: 50%;
219
- width: max-content;
220
- z-index: 100;
221
- display: flex;
222
- gap: 20px;
223
- }
224
- .thumbnail .item {
225
- width: 150px;
226
- height: 220px;
227
- flex-shrink: 0;
228
- position: relative;
229
- }
230
- .thumbnail .item img {
231
- width: 100%;
232
- height: 100%;
233
- object-fit: cover;
234
- border-radius: 20px;
235
- }
236
- .thumbnail .item .content {
237
- color: #fff;
238
- position: absolute;
239
- bottom: 10px;
240
- left: 10px;
241
- right: 10px;
242
- }
243
- .thumbnail .item .content .title {
244
- font-weight: 500;
245
- }
246
- .thumbnail .item .content .description {
247
- font-weight: 300;
248
- }
249
- /* arrows */
250
- .arrows {
251
- position: absolute;
252
- top: 80%;
253
- right: 52%;
254
- z-index: 100;
255
- width: 300px;
256
- max-width: 30%;
257
- display: flex;
258
- gap: 10px;
259
- align-items: center;
260
- }
261
- .arrows button {
262
- width: 40px;
263
- height: 40px;
264
- border-radius: 50%;
265
- background-color: #eee4;
266
- border: none;
267
- color: #fff;
268
- font-family: monospace;
269
- font-weight: bold;
270
- transition: 0.5s;
271
- }
272
- .arrows button:hover {
273
- background-color: #fff;
274
- color: #000;
275
- }
276
142
 
277
- /* animation */
278
- .carousel .list .item:nth-child(1) {
279
- z-index: 1;
280
- }
143
+ .list {
144
+ .item {
145
+ width: 100%;
146
+ height: 100%;
147
+ position: absolute;
148
+ inset: 0 0 0 0;
149
+
150
+ &:nth-child(1) {
151
+ z-index: 1;
152
+
153
+ .content {
154
+ .author,
155
+ .title,
156
+ .topic,
157
+ .des,
158
+ .buttons {
159
+ transform: translateY(50px);
160
+ filter: blur(20px);
161
+ opacity: 0;
162
+ animation: showContent 0.5s 1s linear 1 forwards;
163
+ }
164
+
165
+ .title {
166
+ animation-delay: 1.2s !important;
167
+ }
168
+ .topic {
169
+ animation-delay: 1.4s !important;
170
+ }
171
+ .des {
172
+ animation-delay: 1.6s !important;
173
+ }
174
+ .buttons {
175
+ animation-delay: 1.8s !important;
176
+ }
177
+ }
178
+ }
179
+
180
+ img {
181
+ width: 100%;
182
+ height: 100%;
183
+ object-fit: cover;
184
+ }
185
+
186
+ .content {
187
+ position: absolute;
188
+ top: 20%;
189
+ width: 1140px;
190
+ max-width: 80%;
191
+ left: 50%;
192
+ transform: translateX(-50%);
193
+ padding-right: 30%;
194
+ box-sizing: border-box;
195
+ color: #fff;
196
+ text-shadow: 0 5px 10px #0004;
197
+
198
+ .author {
199
+ font-weight: bold;
200
+ letter-spacing: 10px;
201
+ }
202
+
203
+ .title {
204
+ font-size: 5em;
205
+ font-weight: bold;
206
+ line-height: 1.3em;
207
+ }
208
+ .topic {
209
+ font-size: 5em;
210
+ font-weight: bold;
211
+ line-height: 1.3em;
212
+ color: #f1683a;
213
+ }
214
+
215
+ .buttons {
216
+ display: grid;
217
+ grid-template-columns: repeat(2, 130px);
218
+ grid-template-rows: 40px;
219
+ gap: 5px;
220
+ margin-top: 20px;
221
+
222
+ button {
223
+ background-color: #99999975;
224
+ border: 1px solid #fff;
225
+ color: #fff;
226
+ letter-spacing: 3px;
227
+ font-weight: 500;
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }
233
+
234
+ .thumbnail {
235
+ position: absolute;
236
+ bottom: 50px;
237
+ left: 50%;
238
+ width: max-content;
239
+ z-index: 100;
240
+ display: flex;
241
+ gap: 20px;
242
+
243
+ .item {
244
+ width: 150px;
245
+ height: 220px;
246
+ flex-shrink: 0;
247
+ position: relative;
248
+
249
+ img {
250
+ width: 100%;
251
+ height: 100%;
252
+ object-fit: cover;
253
+ border-radius: 20px;
254
+ }
255
+
256
+ .content {
257
+ color: #fff;
258
+ position: absolute;
259
+ bottom: 10px;
260
+ left: 10px;
261
+ right: 10px;
262
+
263
+ .title {
264
+ font-weight: 500;
265
+ }
266
+
267
+ .description {
268
+ font-weight: 300;
269
+ }
270
+ }
271
+ }
272
+ }
273
+
274
+ /* arrows */
275
+ .arrows {
276
+ position: absolute;
277
+ top: 80%;
278
+ right: 52%;
279
+ z-index: 100;
280
+ width: 300px;
281
+ max-width: 30%;
282
+ display: flex;
283
+ gap: 10px;
284
+ align-items: center;
285
+
286
+ button {
287
+ width: 40px;
288
+ height: 40px;
289
+ border-radius: 50%;
290
+ background-color: #eee4;
291
+ border: none;
292
+ color: #fff;
293
+ font-family: monospace;
294
+ font-weight: bold;
295
+ transition: 0.5s;
296
+
297
+ &:hover {
298
+ background-color: #fff;
299
+ color: #000;
300
+ }
301
+ }
302
+ }
303
+
304
+ .time {
305
+ position: absolute;
306
+ z-index: 1000;
307
+ width: 0%;
308
+ height: 3px;
309
+ background-color: #f1683a;
310
+ left: 0;
311
+ top: 0;
312
+ }
313
+
314
+ /* Slider carousel animations */
315
+ &.next {
316
+ .list {
317
+ .item {
318
+ &:nth-child(1) {
319
+ img {
320
+ width: 150px;
321
+ height: 220px;
322
+ position: absolute;
323
+ bottom: 50px;
324
+ left: 50%;
325
+ border-radius: 30px;
326
+ animation: showImage 0.5s linear 1 forwards;
327
+ }
328
+ }
329
+ }
330
+ }
331
+
332
+ .arrows {
333
+ button {
334
+ pointer-events: none;
335
+ }
336
+ }
337
+
338
+ .thumbnail {
339
+ animation: effectNext 0.5s linear 1 forwards;
340
+
341
+ .item {
342
+ &:nth-last-child(1) {
343
+ overflow: hidden;
344
+ animation: showThumbnail 0.5s linear 1 forwards;
345
+ }
346
+ }
347
+ }
348
+
349
+ .time {
350
+ animation: runningTime 3s linear 1 forwards;
351
+ }
352
+ }
353
+
354
+ &.prev {
355
+ .list {
356
+ .item {
357
+ &:nth-child(2) {
358
+ z-index: 2;
359
+
360
+ img {
361
+ animation: outFrame 0.5s linear 1 forwards;
362
+ position: absolute;
363
+ bottom: 0;
364
+ left: 0;
365
+ }
366
+
367
+ .content {
368
+ .author,
369
+ .title,
370
+ .topic,
371
+ .des,
372
+ .buttons {
373
+ animation: contentOut 1.5s linear 1 forwards !important;
374
+ }
375
+ }
376
+ }
377
+ img {
378
+ z-index: 100;
379
+ }
380
+ }
381
+ }
281
382
 
282
- /* animation text in first item */
283
-
284
- .carousel .list .item:nth-child(1) .content .author,
285
- .carousel .list .item:nth-child(1) .content .title,
286
- .carousel .list .item:nth-child(1) .content .topic,
287
- .carousel .list .item:nth-child(1) .content .des,
288
- .carousel .list .item:nth-child(1) .content .buttons {
289
- transform: translateY(50px);
290
- filter: blur(20px);
291
- opacity: 0;
292
- animation: showContent 0.5s 1s linear 1 forwards;
383
+ .arrows {
384
+ button {
385
+ pointer-events: none;
386
+ }
387
+ }
388
+
389
+ .thumbnail {
390
+ .item {
391
+ &:nth-child(1) {
392
+ overflow: hidden;
393
+ opacity: 0;
394
+ animation: showThumbnail 0.5s linear 1 forwards;
395
+ }
396
+ }
397
+ }
398
+ .time {
399
+ animation: runningTime 3s linear 1 forwards;
400
+ }
401
+ }
293
402
  }
403
+
294
404
  @keyframes showContent {
295
405
  to {
296
406
  transform: translateY(0px);
@@ -298,28 +408,7 @@ watch(
298
408
  opacity: 1;
299
409
  }
300
410
  }
301
- .carousel .list .item:nth-child(1) .content .title {
302
- animation-delay: 1.2s !important;
303
- }
304
- .carousel .list .item:nth-child(1) .content .topic {
305
- animation-delay: 1.4s !important;
306
- }
307
- .carousel .list .item:nth-child(1) .content .des {
308
- animation-delay: 1.6s !important;
309
- }
310
- .carousel .list .item:nth-child(1) .content .buttons {
311
- animation-delay: 1.8s !important;
312
- }
313
- /* create animation when next click */
314
- .carousel.next .list .item:nth-child(1) img {
315
- width: 150px;
316
- height: 220px;
317
- position: absolute;
318
- bottom: 50px;
319
- left: 50%;
320
- border-radius: 30px;
321
- animation: showImage 0.5s linear 1 forwards;
322
- }
411
+
323
412
  @keyframes showImage {
324
413
  to {
325
414
  bottom: 0;
@@ -330,22 +419,12 @@ watch(
330
419
  }
331
420
  }
332
421
 
333
- .carousel.next .thumbnail .item:nth-last-child(1) {
334
- overflow: hidden;
335
- animation: showThumbnail 0.5s linear 1 forwards;
336
- }
337
- .carousel.prev .list .item img {
338
- z-index: 100;
339
- }
340
422
  @keyframes showThumbnail {
341
423
  from {
342
424
  width: 0;
343
425
  opacity: 0;
344
426
  }
345
427
  }
346
- .carousel.next .thumbnail {
347
- animation: effectNext 0.5s linear 1 forwards;
348
- }
349
428
 
350
429
  @keyframes effectNext {
351
430
  from {
@@ -353,22 +432,6 @@ watch(
353
432
  }
354
433
  }
355
434
 
356
- /* running time */
357
-
358
- .carousel .time {
359
- position: absolute;
360
- z-index: 1000;
361
- width: 0%;
362
- height: 3px;
363
- background-color: #f1683a;
364
- left: 0;
365
- top: 0;
366
- }
367
-
368
- .carousel.next .time,
369
- .carousel.prev .time {
370
- animation: runningTime 3s linear 1 forwards;
371
- }
372
435
  @keyframes runningTime {
373
436
  from {
374
437
  width: 100%;
@@ -378,18 +441,6 @@ watch(
378
441
  }
379
442
  }
380
443
 
381
- /* prev click */
382
-
383
- .carousel.prev .list .item:nth-child(2) {
384
- z-index: 2;
385
- }
386
-
387
- .carousel.prev .list .item:nth-child(2) img {
388
- animation: outFrame 0.5s linear 1 forwards;
389
- position: absolute;
390
- bottom: 0;
391
- left: 0;
392
- }
393
444
  @keyframes outFrame {
394
445
  to {
395
446
  width: 150px;
@@ -400,23 +451,6 @@ watch(
400
451
  }
401
452
  }
402
453
 
403
- .carousel.prev .thumbnail .item:nth-child(1) {
404
- overflow: hidden;
405
- opacity: 0;
406
- animation: showThumbnail 0.5s linear 1 forwards;
407
- }
408
- .carousel.next .arrows button,
409
- .carousel.prev .arrows button {
410
- pointer-events: none;
411
- }
412
- .carousel.prev .list .item:nth-child(2) .content .author,
413
- .carousel.prev .list .item:nth-child(2) .content .title,
414
- .carousel.prev .list .item:nth-child(2) .content .topic,
415
- .carousel.prev .list .item:nth-child(2) .content .des,
416
- .carousel.prev .list .item:nth-child(2) .content .buttons {
417
- animation: contentOut 1.5s linear 1 forwards !important;
418
- }
419
-
420
454
  @keyframes contentOut {
421
455
  to {
422
456
  transform: translateY(-150px);
@@ -425,10 +459,10 @@ watch(
425
459
  }
426
460
  }
427
461
  @media screen and (max-width: 678px) {
428
- .carousel .list .item .content {
462
+ .slider-gallery .list .item .content {
429
463
  padding-right: 0;
430
464
  }
431
- .carousel .list .item .content .title {
465
+ .slider-gallery .list .item .content .title {
432
466
  font-size: 30px;
433
467
  }
434
468
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-components",
3
3
  "type": "module",
4
- "version": "2.1.23",
4
+ "version": "2.2.0",
5
5
  "main": "nuxt.config.ts",
6
6
  "scripts": {
7
7
  "clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",