Skip to content

Commit a283920

Browse files
committed
Add text to carousel
1 parent 2b824e1 commit a283920

File tree

4 files changed

+54
-25
lines changed

4 files changed

+54
-25
lines changed

public/css/app.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,11 @@ video {
12761276
object-fit: contain;
12771277
}
12781278

1279+
.object-cover {
1280+
-o-object-fit: cover;
1281+
object-fit: cover;
1282+
}
1283+
12791284
.p-1 {
12801285
padding: 0.25rem;
12811286
}

public/js/app.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23352,7 +23352,16 @@ __webpack_require__.r(__webpack_exports__);
2335223352
setup: function setup(__props, _ref) {
2335323353
var __expose = _ref.expose;
2335423354
__expose();
23355-
var carouselImages = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)(['/images/Hero.jpg', '/images/Hero.jpg', '/images/Hero.jpg']);
23355+
var carouselImages = (0,vue__WEBPACK_IMPORTED_MODULE_0__.ref)([{
23356+
src: '/images/Hero.jpg',
23357+
text: 'MacBook Air 12 In Store now!'
23358+
}, {
23359+
src: '/images/Hero.jpg',
23360+
text: 'MacBook Air 13 In Store now!'
23361+
}, {
23362+
src: '/images/Hero.jpg',
23363+
text: 'MacBook Air 14 In Store now!'
23364+
}]);
2335623365
var __returned__ = {
2335723366
carouselImages: carouselImages,
2335823367
ref: vue__WEBPACK_IMPORTED_MODULE_0__.ref
@@ -24170,7 +24179,13 @@ __webpack_require__.r(__webpack_exports__);
2417024179
/* harmony export */ });
2417124180
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
2417224181

24173-
var _hoisted_1 = ["src", "alt"];
24182+
var _hoisted_1 = {
24183+
"class": "relative"
24184+
};
24185+
var _hoisted_2 = ["src", "alt"];
24186+
var _hoisted_3 = {
24187+
"class": "z-40 absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 text-2xl text-black bg-white rounded-lg mt-4 hidden md:block"
24188+
};
2417424189
function render(_ctx, _cache, $props, $setup, $data, $options) {
2417524190
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)($setup["Swiper"], {
2417624191
navigation: true,
@@ -24183,11 +24198,13 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2418324198
key: index
2418424199
}, {
2418524200
"default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
24186-
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("img", {
24187-
src: image,
24188-
alt: 'Image ' + (index + 1)
24189-
}, null, 8 /* PROPS */, _hoisted_1)];
24201+
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("img", {
24202+
src: image.src,
24203+
alt: 'Image ' + (index + 1),
24204+
"class": "w-full object-cover"
24205+
}, null, 8 /* PROPS */, _hoisted_2), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("span", _hoisted_3, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(image.text), 1 /* TEXT */)])];
2419024206
}),
24207+
2419124208
_: 2 /* DYNAMIC */
2419224209
}, 1024 /* DYNAMIC_SLOTS */);
2419324210
}), 128 /* KEYED_FRAGMENT */))];

resources/js/components/Index/Carousel.vue

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
<template>
22
<swiper :navigation="true" :modules="[Navigation]" class="mySwiper">
3-
<swiper-slide v-for="(image, index) in images" :key="index">
4-
<img :src="image" :alt="'Image ' + (index + 1)" />
5-
</swiper-slide>
3+
<swiper-slide v-for="(image, index) in images" :key="index">
4+
<div class="relative">
5+
<img :src="image.src" :alt="'Image ' + (index + 1)" class="w-full object-cover" />
6+
<span
7+
class="z-40 absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 p-4 text-2xl text-black bg-white rounded-lg mt-4 hidden md:block"
8+
>
9+
{{ image.text }}
10+
</span>
11+
</div>
12+
</swiper-slide>
613
</swiper>
7-
</template>
14+
</template>
815

9-
<script setup>
10-
import { Swiper, SwiperSlide } from 'swiper/vue';
11-
import 'swiper/css';
12-
import 'swiper/css/navigation';
13-
import { Navigation } from 'swiper';
14-
15-
const props = defineProps({
16+
<script setup>
17+
import { Swiper, SwiperSlide } from 'swiper/vue';
18+
import 'swiper/css';
19+
import 'swiper/css/navigation';
20+
import { Navigation } from 'swiper';
21+
22+
const props = defineProps({
1623
images: Array,
17-
});
18-
19-
defineExpose({
24+
});
25+
26+
defineExpose({
2027
Swiper,
2128
SwiperSlide,
22-
});
23-
</script>
29+
});
30+
</script>
2431

2532
<style>
2633
.mySwiper {

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-
'/images/Hero.jpg',
12-
'/images/Hero.jpg',
13-
'/images/Hero.jpg',
11+
{ src: '/images/Hero.jpg', text: 'MacBook Air 12 In Store now!' },
12+
{ src: '/images/Hero.jpg', text: 'MacBook Air 13 In Store now!' },
13+
{ src: '/images/Hero.jpg', text: 'MacBook Air 14 In Store now!' },
1414
]);
1515
</script>

0 commit comments

Comments
 (0)