comand-component-library 3.3.64 → 3.3.66

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,33 @@
1
1
  <template>
2
- <div :class="['cmd-thumbnail-scroller', {'gallery-scroller' : !allowOpenFancyBox, 'full-width' : fullWidth, 'large-icons': largeIcons}]">
2
+ <div :class="['cmd-thumbnail-scroller', {'gallery-scroller' : !allowOpenFancyBox, 'full-width' : fullWidth, 'large-icons': largeIcons}]"
3
+ ref="thumbnail-scroller">
3
4
  <!-- begin CmdSlideButton -->
4
5
  <CmdSlideButton
5
- @click.prevent="showPrevItem"
6
- slideButtonType="prev"
6
+ v-if="showSlidebuttons"
7
+ @click.prevent="showPrevItem"
8
+ slideButtonType="prev"
7
9
  />
8
10
  <!-- end CmdSlideButton -->
9
11
 
10
12
  <!-- begin list of images to slide -->
11
13
  <transition-group name="slide" tag="ul">
12
- <li v-for="(item, index) in items" :key="index" :class="[{'active' : activeItemIndex === index}, item.id ? 'item-' + item.id : '']">
14
+ <li v-for="(item, index) in items" :key="index"
15
+ :class="[{'active' : activeItemIndex === index}, item.id ? 'item-' + item.id : '']">
13
16
  <a :href="executeOnClick === 'url' ? item.url : '#'"
14
17
  @click="executeLink(index, $event)"
15
18
  :title="getTooltip"
16
19
  :target="executeOnClick === 'url' ? '_blank' : null"
17
20
  >
18
21
  <!-- begin CmdImage -->
19
- <CmdImage v-if="contentType === 'image'" :image="item.image" :figcaption="item.figcaption" />
22
+ <CmdImage v-if="contentType === 'image'" :image="item.image" :figcaption="item.figcaption"/>
20
23
  <!-- end CmdImage -->
21
24
 
22
25
  <!-- begin contentType === text -->
23
26
  <template v-else>
24
27
  <!-- begin CmdIcon -->
25
- <CmdIcon v-if="item.iconClass" :iconClass="item.iconClass" :type="item.iconType" />
28
+ <CmdIcon v-if="item.iconClass" :iconClass="item.iconClass" :type="item.iconType"/>
26
29
  <!-- end CmdIcon -->
27
- <span v-if="item.text">{{item.text}}</span>
30
+ <span v-if="item.text">{{ item.text }}</span>
28
31
  </template>
29
32
  <!-- end contentType === text -->
30
33
  </a>
@@ -34,8 +37,9 @@
34
37
 
35
38
  <!-- begin CmdSlideButton -->
36
39
  <CmdSlideButton
37
- @click.prevent="showNextItem"
38
- :slideButtons="cmdSlideButtons.next"
40
+ v-if="showSlidebuttons"
41
+ @click.prevent="showNextItem"
42
+ :slideButtons="cmdSlideButtons.next"
39
43
  />
40
44
  <!-- end CmdSlideButton -->
41
45
  </div>
@@ -58,7 +62,8 @@ export default {
58
62
  ],
59
63
  data() {
60
64
  return {
61
- items: []
65
+ items: [],
66
+ showSlidebuttons: true
62
67
  }
63
68
  },
64
69
  props: {
@@ -86,8 +91,8 @@ export default {
86
91
  * @allowedValues: "image", "text"
87
92
  */
88
93
  contentType: {
89
- type: String,
90
- default: "image"
94
+ type: String,
95
+ default: "image"
91
96
  },
92
97
  /**
93
98
  * set type to define what will be executed on click on a thumbnail-scroller-item
@@ -158,6 +163,14 @@ export default {
158
163
  }
159
164
  }
160
165
  },
166
+ mounted() {
167
+ const thumbnailScrollerWrapper = this.$refs["thumbnail-scroller"]
168
+ const innerListWrapper = thumbnailScrollerWrapper.querySelector(":scope > ul")
169
+
170
+ // watch container-size / -overflow on resize
171
+ const resizeObserver = new ResizeObserver(() => this.toggleSlideButtons(innerListWrapper))
172
+ resizeObserver.observe(thumbnailScrollerWrapper)
173
+ },
161
174
  computed: {
162
175
  getTooltip() {
163
176
  if (this.contentType === "image") {
@@ -170,6 +183,9 @@ export default {
170
183
  }
171
184
  },
172
185
  methods: {
186
+ toggleSlideButtons(innerListWrapper) {
187
+ this.showSlidebuttons = innerListWrapper.scrollWidth > innerListWrapper.clientWidth
188
+ },
173
189
  showNextItem() {
174
190
  const item = this.items.shift(); // remove first element of array
175
191
  if (item) {
@@ -190,18 +206,18 @@ export default {
190
206
  },
191
207
  emitCurrentItemId(index) {
192
208
  // emit id of current/clicked item
193
- if(this.contentType === "image") {
209
+ if (this.contentType === "image") {
194
210
  this.$emit("click", this.items[index].image.id)
195
211
  return
196
212
  }
197
213
  this.$emit("click", this.items[index].id)
198
214
  },
199
215
  executeLink(index, event) {
200
- if(this.executeOnClick === "emit") {
216
+ if (this.executeOnClick === "emit") {
201
217
  event.preventDefault()
202
218
  // emit id of current/clicked item
203
219
  this.emitCurrentItemId(index)
204
- } else if(this.executeOnClick === "fancybox") {
220
+ } else if (this.executeOnClick === "fancybox") {
205
221
  event.preventDefault()
206
222
  // show content in fancybox
207
223
  this.showFancyBox(index)
@@ -214,10 +230,10 @@ export default {
214
230
  // change keys for images to fit CmdImage-properties
215
231
  this.items = this.thumbnailScrollerItems.map((item) => {
216
232
  let newItem
217
- if(this.contentType === "image") {
233
+ if (this.contentType === "image") {
218
234
  newItem = {image: {...item.image}, figcaption: {...item.figcaption}}
219
235
 
220
- if(newItem.image.srcImageSmall) {
236
+ if (newItem.image.srcImageSmall) {
221
237
  newItem.image.src = newItem.image.srcImageSmall
222
238
  }
223
239
  } else {
@@ -237,174 +253,174 @@ export default {
237
253
  @import '../assets/styles/variables';
238
254
 
239
255
  .cmd-thumbnail-scroller {
256
+ border-radius: var(--border-radius);
257
+ padding: var(--default-padding);
258
+ display: inline-flex; /* do not set to table to avoid overflow is not hidden on small devices */
259
+ margin: 0 auto calc(var(--default-margin) * 2) auto;
260
+ border: var(--default-border);
261
+ background: var(--color-scheme-background-color);
262
+
263
+ &.full-width {
264
+ display: flex; /* allows flex-items to stretch equally over full space */
265
+ }
266
+
267
+ > ul {
240
268
  overflow: hidden;
241
- border-radius: var(--border-radius);
242
- padding: var(--default-padding);
243
- display: inline-flex; /* do not set to table to avoid overflow is not hidden on small devices */
244
- margin: 0 auto calc(var(--default-margin) * 2) auto;
245
- border: var(--default-border);
246
- background: var(--color-scheme-background-color);
247
-
248
- &.full-width {
249
- display: flex; /* allows flex-items to stretch equally over full space */
269
+ margin: 0;
270
+ display: flex;
271
+ gap: var(--grid-gap);
272
+ justify-content: space-between;
273
+ width: 100%; /* stretch flex-container */
274
+
275
+ > li {
276
+ align-self: center;
277
+ list-style-type: none;
278
+ margin: 0;
279
+
280
+ a {
281
+ text-align: center;
282
+ }
283
+
284
+ img {
285
+ border-radius: var(--border-radius);
286
+ max-height: 10rem;
287
+ }
288
+
289
+ &.active {
290
+ a {
291
+ figcaption {
292
+ opacity: 1;
293
+ }
294
+ }
295
+ }
250
296
  }
297
+ }
251
298
 
252
- > ul {
253
- overflow: hidden;
254
- margin: 0;
255
- display: flex;
256
- gap: var(--grid-gap);
257
- justify-content: space-between;
258
- width: 100%; /* stretch flex-container */
259
-
260
- > li {
261
- align-self: center;
262
- list-style-type: none;
263
- margin: 0;
264
-
265
- a {
266
- text-align: center;
267
- }
268
-
269
- img {
270
- border-radius: var(--border-radius);
271
- max-height: 10rem;
272
- }
299
+ .vertical {
300
+ display: inline-flex;
301
+ left: 50%;
302
+ height: 75rem; /* remove later !!! */
303
+ transform: translateX(-50%);
273
304
 
274
- &.active {
275
- a {
276
- figcaption {
277
- opacity: 1;
278
- }
279
- }
280
- }
305
+ > ul {
306
+ width: auto;
307
+ display: -webkit-flex; /* Safari 6-8 */
308
+ display: flex;
309
+ flex-direction: column;
310
+
311
+ [class*="switch-button-"] {
312
+ width: 100%;
313
+ height: auto;
314
+
315
+ &::before {
316
+ transform: rotate(90deg);
317
+ display: inline-block;
318
+ margin: 0 auto;
281
319
  }
320
+ }
282
321
  }
283
322
 
284
- .vertical {
285
- display: inline-flex;
286
- left: 50%;
287
- height: 75rem; /* remove later !!! */
288
- transform: translateX(-50%);
289
-
290
- > ul {
291
- width: auto;
292
- display: -webkit-flex; /* Safari 6-8 */
293
- display: flex;
294
- flex-direction: column;
295
-
296
- [class*="switch-button-"] {
297
- width: 100%;
298
- height: auto;
299
-
300
- &::before {
301
- transform: rotate(90deg);
302
- display: inline-block;
303
- margin: 0 auto;
304
- }
305
- }
323
+ .slide-button-next {
324
+ top: auto;
325
+ bottom: 0;
326
+ }
327
+ }
328
+
329
+ &.gallery-scroller {
330
+ max-width: var(--max-width);
331
+ left: 0;
332
+ right: 0;
333
+ position: fixed;
334
+ bottom: var(--default-margin);
335
+ margin: auto;
336
+ display: table;
337
+
338
+ li {
339
+ a {
340
+ color: var(--color-scheme-text-color);
341
+ text-decoration: none;
342
+ }
343
+
344
+ &.active {
345
+ img {
346
+ border-color: var(--primary-color);
306
347
  }
307
348
 
308
- .slide-button-next {
309
- top: auto;
310
- bottom: 0;
349
+ figcaption {
350
+ color: var(--primary-color);
311
351
  }
312
- }
352
+ }
313
353
 
314
- &.gallery-scroller {
315
- max-width: var(--max-width);
316
- left: 0;
317
- right: 0;
318
- position: fixed;
319
- bottom: var(--default-margin);
320
- margin: auto;
321
- display: table;
322
-
323
- li {
324
- a {
325
- color: var(--color-scheme-text-color);
326
- text-decoration: none;
327
- }
354
+ &:not(.active) {
355
+ img {
356
+ border: var(--default-border);
357
+ opacity: var(--reduced-opacity);
358
+ }
328
359
 
329
- &.active {
330
- img {
331
- border-color: var(--primary-color);
332
- }
360
+ figcaption {
361
+ text-decoration: none;
362
+ }
333
363
 
334
- figcaption {
335
- color: var(--primary-color);
336
- }
364
+ a {
365
+ &:hover, &:active, &:focus {
366
+ figcaption {
367
+ color: var(--primary-color);
337
368
  }
338
369
 
339
- &:not(.active) {
340
- img {
341
- border: var(--default-border);
342
- opacity: var(--reduced-opacity);
343
- }
344
-
345
- figcaption {
346
- text-decoration: none;
347
- }
348
-
349
- a {
350
- &:hover, &:active, &:focus {
351
- figcaption {
352
- color: var(--primary-color);
353
- }
354
-
355
- img {
356
- border-color: var(--primary-color);
357
- opacity: 1;
358
- }
359
- }
360
- }
370
+ img {
371
+ border-color: var(--primary-color);
372
+ opacity: 1;
361
373
  }
374
+ }
362
375
  }
376
+ }
363
377
  }
378
+ }
379
+
380
+ &.large-icons {
381
+ li a {
382
+ display: flex;
383
+ flex-direction: column;
384
+ gap: calc(var(--default-gap) / 4);
385
+ text-decoration: none;
386
+ align-items: center;
387
+ justify-content: center;
388
+
389
+ span {
390
+ margin: 0;
391
+ }
364
392
 
365
- &.large-icons {
366
- li a {
367
- display: flex;
368
- flex-direction: column;
369
- gap: calc(var(--default-gap) / 4);
370
- text-decoration: none;
371
- align-items: center;
372
- justify-content: center;
373
-
374
- span {
375
- margin: 0;
376
- }
377
-
378
- [class*="icon-"] {
379
- font-size: 5rem;
380
- }
381
- }
393
+ [class*="icon-"] {
394
+ font-size: 5rem;
395
+ }
382
396
  }
397
+ }
383
398
 
384
- @media only screen and (max-width: $medium-max-width) {
385
- & > ul > li {
386
- flex: none;
387
- }
399
+ @media only screen and (max-width: $medium-max-width) {
400
+ & > ul > li {
401
+ flex: none;
402
+ }
388
403
 
389
- & img {
390
- width: auto;
391
- }
404
+ & img {
405
+ width: auto;
406
+ }
392
407
 
393
- & > ul > li img {
394
- max-height: 7rem;
395
- }
408
+ & > ul > li img {
409
+ max-height: 7rem;
410
+ }
396
411
 
397
- &.gallery-scroller {
398
- max-width: calc(100% - calc(var(--default-margin) * 3));
399
- display: flex;
400
- }
412
+ &.gallery-scroller {
413
+ max-width: calc(100% - calc(var(--default-margin) * 3));
414
+ display: flex;
401
415
  }
416
+ }
402
417
  }
403
418
 
404
419
  @container (width <= #{$small-max-width}) {
405
- .cmd-thumbnail-scroller {
406
- display: block;
407
- }
420
+ .cmd-thumbnail-scroller {
421
+ display: block;
422
+ }
408
423
  }
424
+
409
425
  /* end cmd-thumbnail-scroller ------------------------------------------------------------------------------------------ */
410
426
  </style>