designtopack/src/components/project/ProjectStep.vue

98 lines
2.4 KiB
Vue
Raw Normal View History

<template>
2024-11-21 11:27:14 +01:00
<section
class="flex-1"
:aria-labelledby="step.id"
2024-11-21 11:47:36 +01:00
:data-status="setStatus(page.steps, page.content.currentstep, step)"
2024-11-21 11:27:14 +01:00
>
2024-11-18 16:21:07 +01:00
<h2 :id="step.id">
<span :data-icon="step.id">{{ step.label }}</span>
</h2>
2025-02-19 09:38:01 +01:00
<div
ref="cards-node"
class="cards | flow"
:class="{ new: hasUnreadNotifications }"
>
<component :is="cardsMap[step.id]" :step="step" />
2024-11-18 16:21:07 +01:00
</div>
</section>
</template>
2024-09-26 19:14:20 +02:00
<script setup>
2025-02-19 09:38:01 +01:00
import dayjs from 'dayjs';
import 'dayjs/locale/fr';
import { usePageStore } from '../../stores/page';
import { computed, onMounted, useTemplateRef } from 'vue';
import { useProjectStore } from '../../stores/project';
import ClientBrief from './cards/ClientBrief.vue';
import MultipleDocuments from './cards/MultipleDocuments.vue';
import SimpleDocument from './cards/SimpleDocument.vue';
import VirtualSample from './cards/VirtualSample.vue';
import PhysicalSample from './cards/PhysicalSample.vue';
import { useUserStore } from '../../stores/user';
2024-09-26 19:14:20 +02:00
const { step } = defineProps({
step: Object,
});
2024-10-16 15:32:24 +02:00
2024-12-20 07:19:46 +01:00
const cardsMap = {
clientBrief: ClientBrief,
2024-12-20 08:05:55 +01:00
proposal: MultipleDocuments,
extendedBrief: SimpleDocument,
industrialIdeation: SimpleDocument,
virtualSample: VirtualSample,
physicalSample: PhysicalSample,
2024-12-20 07:19:46 +01:00
};
2025-02-19 09:38:01 +01:00
dayjs.locale('fr');
2024-10-16 15:32:24 +02:00
const { page } = usePageStore();
2024-11-21 11:27:14 +01:00
const { setStatus } = useProjectStore();
2025-02-19 09:38:01 +01:00
const cardsNode = useTemplateRef('cards-node');
const { user } = useUserStore();
2024-10-16 15:32:24 +02:00
2025-01-07 17:31:05 +01:00
// Hooks
onMounted(() => {
if (step.id === page.content.currentstep) {
2025-01-09 09:41:58 +01:00
cardsNode.value.scrollIntoView({
2025-02-19 09:38:01 +01:00
behavior: 'smooth',
inline: 'center',
2025-01-07 17:31:05 +01:00
});
}
});
2025-02-19 09:38:01 +01:00
const correspondingNotifications = computed(() => {
return page.notifications.filter((notification) =>
notification.location.page.uri.includes(step.slug)
);
});
const hasUnreadNotifications = computed(() => {
return correspondingNotifications.value.some(
(notification) =>
!notification.readby.includes(user.uuid) &&
notification.author.uuid !== user.uuid
);
});
2024-09-26 19:14:20 +02:00
</script>
<style scoped>
.physical-sample header {
color: var(--color-white);
2024-12-16 17:52:49 +01:00
background: linear-gradient(
90deg,
hsla(0, 0%, 10%, 0.5) 0%,
hsla(0, 0%, 10%, 0.9) 50%,
hsla(0, 0%, 10%, 0.9) 100%
),
var(--cover), var(--color-black);
background-repeat: no-repeat;
background-size: cover;
}
.physical-sample header > * {
padding-inline: var(--space-16);
}
.physical-sample header h3 {
position: initial;
}
</style>