2024-11-21 10:08:37 +01:00
|
|
|
<template>
|
|
|
|
|
<div class="dialog__inner">
|
2025-02-12 10:50:42 +01:00
|
|
|
<header class="tracks-header | flex">
|
|
|
|
|
<div class="tracks">
|
2025-05-27 15:29:57 +02:00
|
|
|
<Selector
|
2024-11-21 10:08:37 +01:00
|
|
|
v-for="(track, index) in tracks"
|
2025-06-05 18:41:01 +02:00
|
|
|
:key="track.slug"
|
|
|
|
|
:label="track.title"
|
|
|
|
|
:items="track.variations"
|
|
|
|
|
:isCompareModeEnabled="isCompareModeEnabled"
|
2025-06-11 14:45:11 +02:00
|
|
|
:index="index"
|
2025-05-28 15:27:41 +02:00
|
|
|
@update:selectedItems="selectTrack"
|
|
|
|
|
/>
|
2024-11-21 10:08:37 +01:00
|
|
|
</div>
|
2024-12-17 15:08:03 +01:00
|
|
|
<button
|
|
|
|
|
class="btn | ml-auto"
|
2024-12-17 15:26:04 +01:00
|
|
|
:class="{ 'btn--secondary': isCompareModeEnabled }"
|
2024-12-17 15:08:03 +01:00
|
|
|
@click="isCompareModeEnabled = !isCompareModeEnabled"
|
|
|
|
|
>
|
2024-12-17 15:29:26 +01:00
|
|
|
<span>{{
|
|
|
|
|
isCompareModeEnabled
|
2025-02-05 11:31:43 +01:00
|
|
|
? 'Quitter le mode comparer'
|
|
|
|
|
: 'Comparer les pistes'
|
2024-12-17 15:29:26 +01:00
|
|
|
}}</span>
|
2024-11-21 10:08:37 +01:00
|
|
|
</button>
|
|
|
|
|
</header>
|
|
|
|
|
|
2024-11-22 10:02:39 +01:00
|
|
|
<div class="track">
|
2024-12-17 15:08:03 +01:00
|
|
|
<template v-for="activeTrack in activeTracks" :key="activeTrack.title">
|
|
|
|
|
<Interactive360
|
|
|
|
|
v-if="activeTrack.files.length > 1"
|
|
|
|
|
:activeTrack="activeTrack"
|
|
|
|
|
/>
|
2025-06-06 12:22:59 +02:00
|
|
|
<SingleImage
|
|
|
|
|
v-else
|
|
|
|
|
:file="activeTrack.files[0]"
|
|
|
|
|
:backgroundColor="activeTrack.backgroundColor"
|
|
|
|
|
/>
|
2024-12-17 15:08:03 +01:00
|
|
|
</template>
|
2024-12-17 15:29:26 +01:00
|
|
|
<div
|
|
|
|
|
v-if="isCompareModeEnabled && activeTracks.length < 2"
|
|
|
|
|
class="track-empty | bg-white rounded-xl w-full p-32"
|
|
|
|
|
>
|
2025-05-28 16:08:01 +02:00
|
|
|
<p>Sélectionnez sur la piste que vous souhaitez comparer</p>
|
2024-12-17 15:26:04 +01:00
|
|
|
</div>
|
2024-11-21 10:08:37 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2025-06-05 18:41:01 +02:00
|
|
|
import { computed, watch, onMounted, onBeforeMount } from 'vue';
|
2025-02-05 11:31:43 +01:00
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
import { usePageStore } from '../../../stores/page';
|
|
|
|
|
import { useDialogStore } from '../../../stores/dialog';
|
|
|
|
|
import { useVirtualSampleStore } from '../../../stores/virtualSample';
|
2025-02-19 17:36:51 +01:00
|
|
|
import { useRoute } from 'vue-router';
|
2025-02-26 15:12:15 +01:00
|
|
|
import Interactive360 from './Interactive360.vue';
|
|
|
|
|
import SingleImage from './SingleImage.vue';
|
2025-05-27 15:29:57 +02:00
|
|
|
import Selector from '../../Selector.vue';
|
2025-06-05 18:41:01 +02:00
|
|
|
import slugify from 'slugify';
|
2025-02-19 17:36:51 +01:00
|
|
|
|
|
|
|
|
const route = useRoute();
|
2024-11-21 10:08:37 +01:00
|
|
|
|
|
|
|
|
const { page } = storeToRefs(usePageStore());
|
2025-02-07 17:34:23 +01:00
|
|
|
const { isCommentsOpen, isCommentPanelEnabled, activeTracks, openedFile } =
|
|
|
|
|
storeToRefs(useDialogStore());
|
2024-11-21 10:08:37 +01:00
|
|
|
|
2024-12-20 15:52:42 +01:00
|
|
|
const { isCompareModeEnabled } = storeToRefs(useVirtualSampleStore());
|
|
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
const rawTracks = page.value.steps.find(
|
|
|
|
|
(step) => step.slug === 'virtual-sample'
|
|
|
|
|
).files.dynamic;
|
|
|
|
|
|
2025-02-19 17:36:51 +01:00
|
|
|
onBeforeMount(() => {
|
2025-06-11 14:45:11 +02:00
|
|
|
const firstTrack = rawTracks[Object.keys(rawTracks)[0]];
|
|
|
|
|
const firstVariation = firstTrack[0];
|
|
|
|
|
activeTracks.value = [firstVariation];
|
2025-06-05 18:41:01 +02:00
|
|
|
|
2025-06-11 14:45:11 +02:00
|
|
|
// TO RE-ENABLE
|
2025-06-05 18:41:01 +02:00
|
|
|
// if (route.hash.length > 0) {
|
|
|
|
|
// const trackToOpen = tracks.value.find(
|
|
|
|
|
// (track) => track.slug === route.hash.substring(1)
|
|
|
|
|
// );
|
|
|
|
|
// activeTracks.value = [trackToOpen];
|
|
|
|
|
// } else {
|
|
|
|
|
// activeTracks.value = [tracks.value[0]];
|
|
|
|
|
// }
|
2025-02-19 17:36:51 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2025-06-05 16:12:26 +02:00
|
|
|
if (route.hash.length === 0) return;
|
|
|
|
|
|
2025-06-02 10:37:27 +02:00
|
|
|
const selector = route.hash.replace('#', '#track--');
|
|
|
|
|
const targetBtn = document.querySelector(selector);
|
2025-06-02 10:32:13 +02:00
|
|
|
if (targetBtn) {
|
2025-02-19 17:36:51 +01:00
|
|
|
targetBtn.scrollIntoView();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
const tracks = computed(() => {
|
|
|
|
|
const rawTracks = page.value.steps.find(
|
|
|
|
|
(step) => step.slug === 'virtual-sample'
|
|
|
|
|
).files.dynamic;
|
|
|
|
|
|
|
|
|
|
const tracks = [];
|
|
|
|
|
|
|
|
|
|
for (const key in rawTracks) {
|
|
|
|
|
tracks.push({
|
|
|
|
|
title: key,
|
|
|
|
|
slug: slugify(key),
|
|
|
|
|
variations: rawTracks[key],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tracks;
|
|
|
|
|
});
|
2024-11-21 10:08:37 +01:00
|
|
|
|
2025-02-07 17:34:23 +01:00
|
|
|
const isSingleImage = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
activeTracks.value?.length === 1 &&
|
2025-06-05 18:41:01 +02:00
|
|
|
activeTracks.value[0]?.files?.length === 1
|
2025-02-07 17:34:23 +01:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const singleFile = computed(() => {
|
|
|
|
|
return isSingleImage.value && activeTracks.value[0].files[0];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
singleFile,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
if (newValue) {
|
2025-02-07 17:39:34 +01:00
|
|
|
openedFile.value = newValue;
|
2025-02-07 17:34:23 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
);
|
|
|
|
|
|
2024-12-17 15:13:34 +01:00
|
|
|
watch(isCompareModeEnabled, (newValue) => {
|
2024-12-19 17:18:26 +01:00
|
|
|
if (newValue) {
|
|
|
|
|
isCommentsOpen.value = false;
|
|
|
|
|
isCommentPanelEnabled.value = false;
|
|
|
|
|
} else {
|
|
|
|
|
isCommentPanelEnabled.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-17 15:29:26 +01:00
|
|
|
if (!newValue && activeTracks.value.length === 2) {
|
2024-12-17 15:13:34 +01:00
|
|
|
activeTracks.value.pop();
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-12-17 15:08:03 +01:00
|
|
|
|
2025-02-11 17:49:34 +01:00
|
|
|
function getCommentsCount(track) {
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (const file of track.files) {
|
|
|
|
|
count += file?.comments?.length || 0;
|
|
|
|
|
}
|
|
|
|
|
return count > 0 ? count : undefined;
|
|
|
|
|
}
|
2024-11-21 10:08:37 +01:00
|
|
|
</script>
|
2024-12-16 15:29:54 +01:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.track figure {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.track .drag-zone {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
z-index: 2;
|
|
|
|
|
}
|
|
|
|
|
</style>
|