11<script setup lang="ts">
2- import { ref } from ' vue' ;
3- import { galleryList } from ' ../lists/GalleryData.js' ;
42const props = defineProps ({
53 index: {
64 type: Number ,
@@ -16,66 +14,22 @@ const props = defineProps({
1614 },
1715});
1816
19- const isOverlayOpen = ref (false );
20- const currentImageIndex = ref (props .index );
21- const images = ref (galleryList );
17+ const emit = defineEmits ([' open-overlay' ]);
2218
23- const toggleOverlay = () => {
24- isOverlayOpen .value = ! isOverlayOpen .value ;
25- setupScrollLock ();
26- currentImageIndex .value = props .index ;
27- };
28-
29- const setupScrollLock = () => {
30- document .body .style .overflow = isOverlayOpen .value ? ' hidden' : ' ' ;
31- };
32-
33- const showNextImage = () => {
34- if (currentImageIndex .value < images .value .length ) {
35- currentImageIndex .value ++ ;
36- }
37- };
38-
39- const showPreviousImage = () => {
40- if (currentImageIndex .value > 0 ) {
41- currentImageIndex .value -- ;
42- }
19+ const handleClick = () => {
20+ emit (' open-overlay' , props .index );
4321};
4422 </script >
4523
4624<template >
47- <button @click.prevent =" toggleOverlay"
48- class =" w-32 xl:w-64 sm:w-32 aspect-video flex-col justify-center items-start gap-4 inline-flex" >
49- <img class =" w-32 xl:w-64 sm:w-32 aspect-video object-cover object-center relative" :src =" imageSrc"
50- :alt =" cardName" />
25+ <button @click =" handleClick"
26+ class =" w-full h-full max-h-56 flex-col justify-center items-center flex relative shadow-card" >
27+ <img class =" w-full h-full aspect-video object-cover" :src =" imageSrc" :alt =" cardName" />
5128 </button >
52- <div v-if =" isOverlayOpen"
53- class =" fixed inset-0 px-8 xl:px-32 py-16 bg-dark bg-opacity-95 z-[1] flex flex-col items-center justify-center gap-8" >
54- <img class =" w-auto h-1/3 xl:h-3/4 lg:h-1/2 md:h-2/5 sm:h-1/3 aspect-auto relative"
55- :src =" galleryList[currentImageIndex].src" :alt =" galleryList[currentImageIndex].name" />
56-
57- <h3 class =" text-light" >{{ galleryList[currentImageIndex].name }}</h3 >
58-
59- <button @click.prevent =" toggleOverlay" class =" p-2 absolute top-20 right-4 xl:top-24 xl:right-6 z-[2]" >
60- <svg class =" w-8 xl:w-16 h-8 xl:h-16" viewBox =" 0 0 32 32" xmlns =" http://www.w3.org/2000/svg" >
61- <g fill =" none" stroke =" #E9F2FF" stroke-width =" 4" >
62- <line x1 =" 5" y1 =" 5" x2 =" 27" y2 =" 27" />
63- <line x1 =" 5" y1 =" 27" x2 =" 27" y2 =" 5" />
64- </g >
65- </svg >
66- </button >
29+ </template >
6730
68- <button v-if =" currentImageIndex > 0" @click.prevent =" showPreviousImage" class =" p-2 absolute left-4 xl:left-6 z-[2]" >
69- <svg class =" w-8 xl:w-16 h-8 xl:h-16" viewBox =" 0 0 32 32" fill =" none" xmlns =" http://www.w3.org/2000/svg" >
70- <path d =" M21 5L10 16L21 27" stroke =" #E9F2FF" stroke-width =" 4" />
71- </svg >
72- </button >
73-
74- <button v-if =" currentImageIndex < galleryList.length - 1" @click.prevent =" showNextImage"
75- class =" p-2 absolute right-4 xl:right-6 z-[2]" >
76- <svg class =" w-8 xl:w-16 h-8 xl:h-16" viewBox =" 0 0 32 32" fill =" none" xmlns =" http://www.w3.org/2000/svg" >
77- <path d =" M10 27L21 16L10 5" stroke =" #E9F2FF" stroke-width =" 4" />
78- </svg >
79- </button >
80- </div >
81- </template >
31+ <script lang="ts">
32+ export default {
33+ name: ' GalleryCard'
34+ };
35+ </script >
0 commit comments