Skip to content

Commit 2205602

Browse files
committed
Deploy Vue project to GitHub Pages
1 parent 4f66297 commit 2205602

File tree

3 files changed

+49
-44
lines changed

3 files changed

+49
-44
lines changed

src/components/cards/GalleryCard.vue

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { ref, computed } from 'vue'
3+
24
const props = defineProps({
35
index: {
46
type: Number,
@@ -12,24 +14,31 @@ const props = defineProps({
1214
type: String,
1315
required: true,
1416
},
15-
});
17+
})
18+
19+
const emit = defineEmits(['open-overlay'])
20+
const imageLoadingError = ref(false)
1621
17-
const emit = defineEmits(['open-overlay']);
22+
const computedImageSrc = computed(() => {
23+
if (imageLoadingError.value || !props.imageSrc.trim()) {
24+
return '/something_wrong.png'
25+
}
26+
return props.imageSrc
27+
})
1828
1929
const handleClick = () => {
20-
emit('open-overlay', props.index);
21-
};
30+
emit('open-overlay', props.index)
31+
}
32+
33+
const handleImageError = () => {
34+
imageLoadingError.value = true
35+
}
2236
</script>
2337

2438
<template>
2539
<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" />
40+
class="shadow-card relative flex h-full max-h-56 w-full flex-col items-center justify-center">
41+
<img class="aspect-video h-full w-full object-cover" :src="computedImageSrc" :alt="cardName"
42+
@error="handleImageError" />
2843
</button>
2944
</template>
30-
31-
<script lang="ts">
32-
export default {
33-
name: 'GalleryCard'
34-
};
35-
</script>

src/components/cards/GalleryOverlay.vue

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2-
import { onMounted, onUnmounted } from 'vue';
2+
import { onMounted, onUnmounted } from 'vue'
33
44
interface Photo {
5-
src: string;
6-
name: string;
5+
src: string
6+
name: string
77
}
88
99
const props = defineProps({
@@ -19,54 +19,53 @@ const props = defineProps({
1919
type: Boolean,
2020
required: true,
2121
},
22-
});
22+
})
2323
24-
const emit = defineEmits(['close-overlay', 'update-index']);
24+
const emit = defineEmits(['close-overlay', 'update-index'])
2525
2626
const handleClose = () => {
27-
emit('close-overlay');
28-
};
27+
emit('close-overlay')
28+
}
2929
3030
const showNextImage = () => {
3131
if (props.currentIndex < props.photos.length - 1) {
32-
emit('update-index', props.currentIndex + 1);
32+
emit('update-index', props.currentIndex + 1)
3333
}
34-
};
34+
}
3535
3636
const showPreviousImage = () => {
3737
if (props.currentIndex > 0) {
38-
emit('update-index', props.currentIndex - 1);
38+
emit('update-index', props.currentIndex - 1)
3939
}
40-
};
40+
}
4141
4242
// Handle Keydown Events
4343
const handleKeyDown = (event: KeyboardEvent) => {
4444
switch (event.key) {
4545
case 'Escape':
46-
handleClose();
46+
handleClose()
4747
// console.log('Escape');
48-
break;
48+
break
4949
case 'ArrowRight':
50-
showNextImage();
50+
showNextImage()
5151
// console.log('ArrowRight');
52-
break;
52+
break
5353
case 'ArrowLeft':
54-
showPreviousImage();
54+
showPreviousImage()
5555
// console.log('ArrowLeft');
56-
break;
56+
break
5757
}
58-
};
58+
}
5959
6060
onMounted(() => {
61-
window.addEventListener('keydown', handleKeyDown);
62-
});
61+
window.addEventListener('keydown', handleKeyDown)
62+
})
6363
6464
onUnmounted(() => {
65-
window.removeEventListener('keydown', handleKeyDown);
66-
});
65+
window.removeEventListener('keydown', handleKeyDown)
66+
})
6767
</script>
6868

69-
7069
<template>
7170
<div v-if="isOpen"
7271
class="p-0 2xl:py-24 2xl:px-8 fixed inset-0 bg-dark/90 z-20 flex flex-row items-center justify-center">

src/views/Home.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import LinkedIn from '@/components/icons/LinkedIn.vue';
1111
import YouTube from '@/components/icons/YouTube.vue';
1212
1313
const galleries = {
14-
mainGallery: galleryList,
14+
mainGallery: galleryList,
1515
};
1616
1717
const galleryStates = ref<Record<string, { isOpen: boolean; currentIndex: number }>>(
@@ -98,16 +98,13 @@ const updateIndex = (galleryKey: string, index: number) => {
9898
</div>
9999
<div id="gallery" class="w-full px-8 xl:px-32 py-24 bg-dark flex-col justify-center items-center gap-8 inline-flex">
100100
<h2 class="text-center">Memories</h2>
101-
<div class="grid grid-cols-2 xl:grid-cols-4 sm:grid-cols-4 gap-4 place-items-center">
102-
<GalleryCard v-for="(image, index) in galleries.mainGallery" :key="`mainGallery-${index}`"
103-
:index="index" :image-src="image.src" :card-name="image.name"
104-
@open-overlay="() => openOverlay('mainGallery', index)" />
101+
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4 place-items-center">
102+
<GalleryCard v-for="(image, index) in galleries.mainGallery" :key="`mainGallery-${index}`" :index="index"
103+
:image-src="image.src" :card-name="image.name" @open-overlay="() => openOverlay('mainGallery', index)" />
105104
</div>
106105
<GalleryOverlay v-if="galleryStates['mainGallery'].isOpen" :photos="galleries.mainGallery"
107-
:currentIndex="galleryStates['mainGallery'].currentIndex"
108-
:isOpen="galleryStates['mainGallery'].isOpen"
109-
@close-overlay="() => closeOverlay('mainGallery')"
110-
@update-index="(index) => updateIndex('mainGallery', index)" />
106+
:currentIndex="galleryStates['mainGallery'].currentIndex" :isOpen="galleryStates['mainGallery'].isOpen"
107+
@close-overlay="() => closeOverlay('mainGallery')" @update-index="(index) => updateIndex('mainGallery', index)" />
111108
</div>
112109
<div id="contact"
113110
class="w-full px-8 xl:px-32 py-24 bg-[url('/images/footer_bg.png')] bg-cover bg-center flex-col justify-between gap-4 items-center flex">

0 commit comments

Comments
 (0)