dynamize notifications view
This commit is contained in:
parent
8ed7331b61
commit
c099e0d5ac
6 changed files with 127 additions and 132 deletions
|
|
@ -2,67 +2,110 @@
|
|||
<main class="wrapper">
|
||||
<h2 id="tabslist" class="sr-only">Status</h2>
|
||||
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
|
||||
<button class="btn | absolute top-0 right-gutter" disabled>Marquer tout come lu</button>
|
||||
<!-- IF pas de nouvelles notifications -->
|
||||
<div class="flex flex-col justify-center | text-grey-700 | absolute inset-0 -z-1">
|
||||
<svg aria-hidden="true" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M23.7 28.925C23.4895 30.6616 22.625 32.2526 21.2825 33.3741C19.94 34.4955 18.2205 35.0631 16.4742 34.9611C14.7279 34.8591 13.0861 34.0953 11.8832 32.8252C10.6804 31.5551 10.0069 29.8743 10 28.125V24.15M34.6 32.675L5.425 22.5C4.94896 22.3339 4.53427 22.0278 4.23534 21.6218C3.93642 21.2158 3.76724 20.7289 3.75 20.225V17.5C3.75206 16.9832 3.91423 16.4798 4.21418 16.0589C4.51414 15.6381 4.93715 15.3205 5.425 15.15L34.6 5.00001C34.7873 4.93673 34.987 4.91879 35.1825 4.94766C35.3781 4.97653 35.5641 5.05137 35.7251 5.16606C35.8862 5.28074 36.0177 5.43199 36.109 5.60738C36.2002 5.78277 36.2485 5.9773 36.25 6.17501V31.5C36.2485 31.6977 36.2002 31.8922 36.109 32.0676C36.0177 32.243 35.8862 32.3943 35.7251 32.5089C35.5641 32.6236 35.3781 32.6985 35.1825 32.7273C34.987 32.7562 34.7873 32.7383 34.6 32.675Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<button class="btn | absolute top-0 right-gutter" disabled>
|
||||
Marquer tout come lu
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="comments.length === 0"
|
||||
class="flex flex-col justify-center | text-grey-700 | absolute inset-0 -z-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M23.7 28.925C23.4895 30.6616 22.625 32.2526 21.2825 33.3741C19.94 34.4955 18.2205 35.0631 16.4742 34.9611C14.7279 34.8591 13.0861 34.0953 11.8832 32.8252C10.6804 31.5551 10.0069 29.8743 10 28.125V24.15M34.6 32.675L5.425 22.5C4.94896 22.3339 4.53427 22.0278 4.23534 21.6218C3.93642 21.2158 3.76724 20.7289 3.75 20.225V17.5C3.75206 16.9832 3.91423 16.4798 4.21418 16.0589C4.51414 15.6381 4.93715 15.3205 5.425 15.15L34.6 5.00001C34.7873 4.93673 34.987 4.91879 35.1825 4.94766C35.3781 4.97653 35.5641 5.05137 35.7251 5.16606C35.8862 5.28074 36.0177 5.43199 36.109 5.60738C36.2002 5.78277 36.2485 5.9773 36.25 6.17501V31.5C36.2485 31.6977 36.2002 31.8922 36.109 32.0676C36.0177 32.243 35.8862 32.3943 35.7251 32.5089C35.5641 32.6236 35.3781 32.6985 35.1825 32.7273C34.987 32.7562 34.7873 32.7383 34.6 32.675Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.25"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<p>Vous n’avez pas de nouvelles notifications</p>
|
||||
</div>
|
||||
<!-- ELSE -->
|
||||
<section class="notifications | flow">
|
||||
<!--
|
||||
TODO: à dynamiser
|
||||
data-status = unread | read
|
||||
data-type = comment | content | event
|
||||
data-icon = comment | content | event
|
||||
-->
|
||||
<article
|
||||
class="notification | bg-white rounded-lg | p-16 | flow"
|
||||
data-status="unread"
|
||||
data-type="comment"
|
||||
>
|
||||
<header>
|
||||
<p class="flex">
|
||||
<strong class="notification__type | font-medium text-primary" data-icon="comment">Nouveau commentaire</strong>
|
||||
<span class="notification__client | text-grey-700">Miss Dior Blooming Bouquet</span>
|
||||
<time datetime="" class="notification__date | text-grey-700 | ml-auto">17:06</time>
|
||||
</p>
|
||||
</header>
|
||||
<p class="notification__body | text-md font-medium | line-clamp">
|
||||
Clément Dubois : Lectus adipiscing nulla quis odio in aliquam. Adipiscing libero in consequat porta mauris hendrerit malesuada viverra turpis. Lectus adipiscing nulla quis odio in aliquam. Adipiscing libero in consequat porta mauris hendrerit malesuada viverra turpis.
|
||||
</p>
|
||||
</article>
|
||||
<article
|
||||
<section v-else class="notifications | flow">
|
||||
<template v-for="notification in notifications" :key="notification.id">
|
||||
<router-link
|
||||
:to="notification.page.uri + '?fileUuid=' + notification.file.uuid"
|
||||
>
|
||||
<article
|
||||
class="notification | bg-white rounded-lg | p-16 | flow"
|
||||
:data-status="notification.isRead ? 'read' : 'unread'"
|
||||
:data-type="notification.type"
|
||||
>
|
||||
<header>
|
||||
<p class="flex">
|
||||
<strong
|
||||
class="notification__type | font-medium text-primary"
|
||||
:data-icon="notification.type"
|
||||
>Nouveau
|
||||
{{
|
||||
notification.type === "comment" ? "commentaire" : "contenu"
|
||||
}}</strong
|
||||
>
|
||||
<span class="notification__client | text-grey-700">{{
|
||||
notification.page.title
|
||||
}}</span>
|
||||
<time
|
||||
datetime=""
|
||||
class="notification__date | text-grey-700 | ml-auto"
|
||||
>17:06</time
|
||||
>
|
||||
</p>
|
||||
</header>
|
||||
<p
|
||||
v-if="notification.type === 'comment'"
|
||||
class="notification__body | text-md font-medium | line-clamp"
|
||||
>
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
</article>
|
||||
</router-link>
|
||||
</template>
|
||||
<!-- <article
|
||||
class="notification | bg-white rounded-lg | p-16 | flow"
|
||||
data-status="read"
|
||||
data-type="content"
|
||||
>
|
||||
<header>
|
||||
<p class="flex">
|
||||
<strong class="notification__type | font-medium text-primary" data-icon="content">Nouveau contenu</strong>
|
||||
<span class="notification__client | text-grey-700">Miss Dior Blooming Bouquet</span>
|
||||
<time datetime="" class="notification__date | text-grey-700 | ml-auto">Hier</time>
|
||||
<strong
|
||||
class="notification__type | font-medium text-primary"
|
||||
data-icon="content"
|
||||
>Nouveau contenu</strong
|
||||
>
|
||||
<span class="notification__client | text-grey-700"></span>
|
||||
<time
|
||||
datetime=""
|
||||
class="notification__date | text-grey-700 | ml-auto"
|
||||
>Hier</time
|
||||
>
|
||||
</p>
|
||||
</header>
|
||||
<p class="notification__body | text-md font-medium | line-clamp">
|
||||
Proposition 2
|
||||
</p>
|
||||
</article>
|
||||
</article> -->
|
||||
</section>
|
||||
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from "dayjs";
|
||||
import "dayjs/locale/fr";
|
||||
import Tabs from "../components/Tabs.vue";
|
||||
|
||||
import { usePageStore } from "../stores/page"
|
||||
import { usePageStore } from "../stores/page";
|
||||
import { useUserStore } from "../stores/user";
|
||||
import { ref, computed } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
dayjs.locale("fr");
|
||||
|
||||
const { page } = storeToRefs(usePageStore());
|
||||
const user = useUserStore().user;
|
||||
const currentTab = ref("all");
|
||||
|
|
@ -85,9 +128,17 @@ const tabs = computed(() => {
|
|||
];
|
||||
});
|
||||
|
||||
const comments = Object.values(user.notifications.comments);
|
||||
|
||||
const notifications = [...comments];
|
||||
|
||||
function changeTab(newValue) {
|
||||
currentTab.value = newValue;
|
||||
}
|
||||
|
||||
const isEmpty = computed(() => {
|
||||
return comments.length === 0;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
@ -103,10 +154,10 @@ function changeTab(newValue) {
|
|||
position: relative;
|
||||
}
|
||||
.notification[data-status="unread"]::after {
|
||||
content: '';
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: .5rem;
|
||||
height: .5rem;
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
outline: 2px solid var(--color-white);
|
||||
background: var(--color-primary);
|
||||
border-radius: 50%;
|
||||
|
|
@ -130,13 +181,13 @@ function changeTab(newValue) {
|
|||
display: inline-block;
|
||||
}
|
||||
.notification__client::before {
|
||||
content: '';
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 3px;
|
||||
height: 3px;
|
||||
background: var(--color-grey-700);
|
||||
border-radius: 50%;
|
||||
margin: .2em .5em;
|
||||
margin: 0.2em 0.5em;
|
||||
}
|
||||
.notification__body {
|
||||
--line-clamp: 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue