designtopack/src/components/Projects.vue

76 lines
1.7 KiB
Vue
Raw Normal View History

2024-09-04 11:28:12 +02:00
<template>
<h2 id="tabslist" class="sr-only">Projets</h2>
2024-11-21 16:58:19 +01:00
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
<section
v-if="currentTab === 'currentProjects'"
id="projets-en-cours"
role="tabpanel"
tabindex="0"
aria-labelledby="projets-en-cours-label"
class="flow"
:class="{ empty: currentProjects.length === 0 }"
>
<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"
:class="{ empty: archivedProjects.length === 0 }"
>
<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);
}
section > * {
display: block;
}
</style>