From b9773f443ed1660048133c14957558b48bfc756e Mon Sep 17 00:00:00 2001 From: Zh3nyaZh3nya Date: Wed, 11 Dec 2024 14:02:43 +0500 Subject: [PATCH 1/2] replaced props Array with Object in gallery view --- src/runtime/components/Parts/Gallery/View.vue | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/runtime/components/Parts/Gallery/View.vue b/src/runtime/components/Parts/Gallery/View.vue index 0ed1632..a6c6ba6 100644 --- a/src/runtime/components/Parts/Gallery/View.vue +++ b/src/runtime/components/Parts/Gallery/View.vue @@ -88,9 +88,9 @@ const { mdAndUp } = useDisplay() const props = defineProps({ gallery: { - type: Array, + type: Object, required: true, - default: () => [], + default: () => ({}), }, previewImage: { type: Object, @@ -106,19 +106,7 @@ const emit = defineEmits(["update:modelValue"]); const mainSwiperRef = ref(); const thumbsSwiperRef = ref(); -const localGallery = ref([...props.gallery]); - -function mainPrev() { - const swiper = mainSwiperRef.value.swiper; - swiper.slidePrev(); - updateActiveImage(swiper.activeIndex); -} - -function mainNext() { - const swiper = mainSwiperRef.value.swiper; - swiper.slideNext(); - updateActiveImage(swiper.activeIndex); -} +const localGallery = ref(Object.values(props.gallery)); function setActiveImage(index) { updateActiveImage(index); @@ -133,8 +121,9 @@ function setActiveImage(index) { } function updateActiveImage(index) { - localGallery.value.forEach((img, idx) => { - img.active = idx === index; + const keys = Object.keys(props.gallery); + keys.forEach((key, idx) => { + props.gallery[key].active = idx === index; }); if (thumbsSwiperRef.value?.swiper) { @@ -143,6 +132,18 @@ function updateActiveImage(index) { } } +function mainPrev() { + const swiper = mainSwiperRef.value.swiper; + swiper.slidePrev(); + updateActiveImage(swiper.activeIndex); +} + +function mainNext() { + const swiper = mainSwiperRef.value.swiper; + swiper.slideNext(); + updateActiveImage(swiper.activeIndex); +} + function onMainSlideChange() { const activeIndex = mainSwiperRef.value.swiper.activeIndex; updateActiveImage(activeIndex); @@ -162,8 +163,10 @@ const localModelValue = computed({ }); onMounted(() => { - if(mdAndUp.value) { - localGallery.value.push({id: localGallery.value.length, image: '', active: false}) + localGallery.value = Object.values(props.gallery); + + if (mdAndUp.value) { + localGallery.value.push({ id: localGallery.value.length, image: '', active: false }); } if (props.previewImage) { From 2c25158d7f76ec43270dc1bf54f350408ba4c850 Mon Sep 17 00:00:00 2001 From: Zh3nya!__ <129783207+Zh3nyaZh3nya@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:03:12 +0500 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea34687..0b00973 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ibecsystems/nuxt3-ui-kit", - "version": "1.0.58", + "version": "1.0.59", "description": "Ibec Nuxt3 UI components", "repository": { "type": "git",