Skip to content

Commit 50eab96

Browse files
committed
Carousel Swiper navigation
1 parent b5b9d3b commit 50eab96

File tree

4 files changed

+1278
-519
lines changed

4 files changed

+1278
-519
lines changed

public/css/app.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,18 @@ video {
863863
max-height: 100%;
864864
}
865865

866+
.max-h-\[384px\] {
867+
max-height: 384px;
868+
}
869+
870+
.max-h-\[500px\] {
871+
max-height: 500px;
872+
}
873+
874+
.max-h-\[600px\] {
875+
max-height: 600px;
876+
}
877+
866878
.w-1\/2 {
867879
width: 50%;
868880
}
@@ -927,6 +939,10 @@ video {
927939
max-width: 768px;
928940
}
929941

942+
.max-w-\[1504px\] {
943+
max-width: 1504px;
944+
}
945+
930946
.flex-1 {
931947
flex: 1 1 0%;
932948
}

public/js/app.js

Lines changed: 1229 additions & 505 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
<template>
2-
<swiper-container ref="swiperRef" class="swiper-container" slides-per-view="1" pagination-el=".swiper-pagination">
3-
<swiper-slide v-for="(image, index) in images" :key="index" class="swiper-slide">
2+
<swiper :navigation="true" :modules="[Navigation]" class="mySwiper">
3+
<swiper-slide v-for="(image, index) in images" :key="index">
44
<img :src="image" :alt="'Image ' + (index + 1)" />
55
</swiper-slide>
6-
<div class="swiper-pagination"></div>
7-
</swiper-container>
6+
</swiper>
87
</template>
98

109
<script setup>
11-
import { register } from 'swiper/element/bundle';
12-
import 'swiper/swiper-bundle.css';
13-
import { ref } from 'vue';
10+
import { Swiper, SwiperSlide } from 'swiper/vue';
11+
import 'swiper/css';
12+
import 'swiper/css/navigation';
13+
import { Navigation } from 'swiper';
1414
1515
const props = defineProps({
1616
images: Array,
1717
});
1818
19-
register();
20-
21-
const swiperRef = ref(null);
19+
defineExpose({
20+
Swiper,
21+
SwiperSlide,
22+
});
2223
</script>
2324

2425
<style>
26+
.mySwiper {
27+
width: 100%;
28+
height: 300px;
29+
}
30+
31+
.swiper-slide {
32+
text-align: center;
33+
font-size: 18px;
34+
background: #fff;
35+
36+
/* Center slide images vertically */
37+
display: flex;
38+
justify-content: center;
39+
align-items: center;
40+
}
41+
2542
.swiper-slide img {
43+
display: block;
2644
width: 100%;
27-
height: auto;
45+
height: 100%;
46+
object-fit: cover;
2847
}
2948
</style>

resources/js/pages/Index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import { ref } from 'vue';
99
1010
const carouselImages = ref([
11-
'https://via.placeholder.com/800x300?text=Image+1',
12-
'https://via.placeholder.com/800x300?text=Image+2',
13-
'https://via.placeholder.com/800x300?text=Image+3',
11+
'/images/Hero.jpg',
12+
'/images/Hero.jpg',
13+
'/images/Hero.jpg',
1414
]);
1515
</script>

0 commit comments

Comments
 (0)