|
|
@ -84,7 +84,6 @@ import { TEXTS } from '~/config/content';
|
|
|
|
import { PATHS , DEFAULT_IMAGES} from '~/config/paths';
|
|
|
|
import { PATHS , DEFAULT_IMAGES} from '~/config/paths';
|
|
|
|
import { projects } from '~/config/projects';
|
|
|
|
import { projects } from '~/config/projects';
|
|
|
|
import type { Project } from '~/types/project';
|
|
|
|
import type { Project } from '~/types/project';
|
|
|
|
|
|
|
|
|
|
|
|
const handleLightboxImageError = (event: Event): void => {
|
|
|
|
const handleLightboxImageError = (event: Event): void => {
|
|
|
|
const target = event.target as HTMLImageElement;
|
|
|
|
const target = event.target as HTMLImageElement;
|
|
|
|
target.src = DEFAULT_IMAGES.PROJECT;
|
|
|
|
target.src = DEFAULT_IMAGES.PROJECT;
|
|
|
@ -100,12 +99,10 @@ const handleIconError = (event: Event): void => {
|
|
|
|
target.src = DEFAULT_IMAGES.ICON;
|
|
|
|
target.src = DEFAULT_IMAGES.ICON;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const useProjectDetail = (id: number) => {
|
|
|
|
const useProjectDetail = (id: number) => {
|
|
|
|
const { $theme } = useNuxtApp();
|
|
|
|
const { $theme } = useNuxtApp();
|
|
|
|
const showLightbox = ref(false);
|
|
|
|
const showLightbox = ref(false);
|
|
|
|
const currentImageIndex = ref(0);
|
|
|
|
const currentImageIndex = ref(0);
|
|
|
|
const processedImages = ref<string[]>([]);
|
|
|
|
|
|
|
|
const currentProject = ref<Project | null>(null);
|
|
|
|
const currentProject = ref<Project | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
currentProject.value = projects.find((project) => project.id === id) || null;
|
|
|
|
currentProject.value = projects.find((project) => project.id === id) || null;
|
|
|
@ -120,13 +117,13 @@ const useProjectDetail = (id: number) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const nextImage = (): void => {
|
|
|
|
const nextImage = (): void => {
|
|
|
|
if (!processedImages.value.length) return;
|
|
|
|
if (!currentProject.value?.gallery?.length) return;
|
|
|
|
currentImageIndex.value = (currentImageIndex.value + 1) % processedImages.value.length;
|
|
|
|
currentImageIndex.value = (currentImageIndex.value + 1) % currentProject.value.gallery.length;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const prevImage = (): void => {
|
|
|
|
const prevImage = (): void => {
|
|
|
|
if (!processedImages.value.length) return;
|
|
|
|
if (!currentProject.value?.gallery?.length) return;
|
|
|
|
currentImageIndex.value = (currentImageIndex.value - 1 + processedImages.value.length) % processedImages.value.length;
|
|
|
|
currentImageIndex.value = (currentImageIndex.value - 1 + currentProject.value.gallery.length) % currentProject.value.gallery.length;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleKeyDown = (event: KeyboardEvent): void => {
|
|
|
|
const handleKeyDown = (event: KeyboardEvent): void => {
|
|
|
@ -145,7 +142,7 @@ const useProjectDetail = (id: number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
onMounted(() => {
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -168,10 +165,10 @@ const useProjectDetail = (id: number) => {
|
|
|
|
icon: getIconPath('DEMO'),
|
|
|
|
icon: getIconPath('DEMO'),
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.DEMO
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.DEMO
|
|
|
|
} : null,
|
|
|
|
} : null,
|
|
|
|
documentation: currentProject.value?.documentation ? {
|
|
|
|
documentation: {
|
|
|
|
icon: getIconPath('DOCUMENTATION'),
|
|
|
|
icon: getIconPath('DOCUMENTATION'),
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.DOCUMENTATION
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.DOCUMENTATION
|
|
|
|
} : null,
|
|
|
|
},
|
|
|
|
youtube: currentProject.value?.youtube ? {
|
|
|
|
youtube: currentProject.value?.youtube ? {
|
|
|
|
icon: getIconPath('YOUTUBE'),
|
|
|
|
icon: getIconPath('YOUTUBE'),
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.YOUTUBE
|
|
|
|
label: TEXTS.PROJECTS.RESOURCES.YOUTUBE
|
|
|
@ -208,8 +205,8 @@ const {
|
|
|
|
prevImage
|
|
|
|
prevImage
|
|
|
|
} = useProjectDetail(projectId);
|
|
|
|
} = useProjectDetail(projectId);
|
|
|
|
|
|
|
|
|
|
|
|
const projectImage = computed(() => {return currentProject.value?.image || DEFAULT_IMAGES.PROJECT;});
|
|
|
|
const projectImage = computed(() => currentProject.value?.image || DEFAULT_IMAGES.PROJECT);
|
|
|
|
const projectGallery = computed(() => {return currentProject.value?.gallery || [];});
|
|
|
|
const projectGallery = computed(() => currentProject.value?.gallery || []);
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|