designtopack/src/components/Projects.vue

94 lines
2.1 KiB
Vue
Raw Normal View History

2024-09-04 11:28:12 +02:00
<template>
<header class="flex">
<h2 id="tabslist" class="sr-only">Projets</h2>
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
</header>
2024-11-21 16:58:19 +01:00
<section
v-if="currentTab === 'currentProjects'"
id="projets-en-cours"
role="tabpanel"
tabindex="0"
aria-labelledby="projets-en-cours-label"
class="flow"
>
<Project
v-for="project in currentProjects"
:key="project.id"
:project="project"
/>
</section>
<section
v-else
id="projets-archives"
role="tabpanel"
tabindex="0"
aria-labelledby="projet-archives-label"
>
<Project
v-for="project in archivedProjects"
:key="project.id"
:project="project"
/>
</section>
2024-09-04 11:28:12 +02:00
</template>
<script setup>
import Tabs from "./Tabs.vue";
import Project from "./project/Project.vue";
2024-09-10 08:49:09 +02:00
import { useProjectsStore } from "../stores/projects";
2024-09-10 10:50:51 +02:00
import { ref, computed } from "vue";
2024-09-10 08:49:09 +02:00
import { storeToRefs } from "pinia";
2024-09-04 11:28:12 +02:00
2024-09-10 09:12:52 +02:00
const { projects, currentProjects, archivedProjects } = storeToRefs(
useProjectsStore()
);
2024-09-04 11:28:12 +02:00
2024-09-10 09:12:52 +02:00
const currentTab = ref("currentProjects");
2024-09-10 10:50:51 +02:00
const tabs = computed(() => {
return [
{
label: "Projets en cours",
id: "currentProjects",
count: currentProjects.value.length,
isActive: currentTab.value === "currentProjects",
2024-09-10 10:50:51 +02:00
},
{
label: "Projets archivés",
id: "archivedProjects",
count: archivedProjects.value.length,
isActive: currentTab.value === "archivedProjects",
2024-09-10 10:50:51 +02:00
},
];
});
2024-09-04 11:28:12 +02:00
function changeTab(newValue) {
currentTab.value = newValue;
}
</script>
<style scoped>
section {
--flow-space: var(--space-16);
2024-11-21 19:33:14 +01:00
min-height: calc(100vh - 8.5rem);
}
section > * {
display: block;
}
2024-11-21 19:33:14 +01:00
section:empty::after {
content: "Aucun projet pour le moment.";
position: absolute;
inset: 0;
display: grid;
place-items: center;
text-align: center;
max-width: 24ch;
height: 8rem;
margin: auto;
font-size: var(--text-sm);
color: var(--color-grey-700);
background-image: var(--icon-document-thin);
background-position: top center;
background-repeat: no-repeat;
background-size: var(--space-40);
}
</style>