11<template >
2- <PageBlock data-dimensions = " large " >
3- < router-link
4- v-if = " user "
5- to = " /new "
6- >
2+ <PageBlock
3+ data-dimensions = " large "
4+ >
5+ <!-- Unauthorized users -->
6+ < template v-if = " ! user " >
77 <Container >
8- <div :class =" $style['container__create-new-note']" >
9- <Row
10- :title =" t('home.createNewNote.title')"
11- :subtitle =" t('home.createNewNote.caption')"
12- >
13- <template #left >
14- <Hammer />
15- </template >
16- <template #right >
17- <Button
18- secondary
19- trailing-icon =" ChevronRight"
20- >
21- {{ t('home.createNewNote.button') }}
22- </Button >
23- </template >
24- </Row >
25- </div >
26- </Container >
27- </router-link >
28- <Heading
29- v-if =" user"
30- :level =" 1"
31- :class =" $style['page-header']"
32- >
33- {{ $t('home.title') }}
34- </Heading >
35-
36- <div v-if =" user === null" >
37- <Container data-dimensions =" large" >
388 <Row :title =" t('home.authText')" >
399 <template #right >
4010 <Button
4515 </template >
4616 </Row >
4717 </Container >
48- </div >
49- <NoteList
50- v-else-if =" user !== undefined"
51- />
18+ </template >
19+
20+ <!-- Authorized users - menu -->
21+ <template
22+ v-if =" user "
23+ #left
24+ >
25+ <VerticalMenu
26+ class =" menu"
27+ :items =" [verticalMenuItems]"
28+ />
29+ </template >
30+
31+ <!-- Authorized users - content -->
32+ <template v-if =" user " >
33+ <router-link
34+ to =" /new"
35+ >
36+ <Container >
37+ <div :class =" $style['container__create-new-note']" >
38+ <Row
39+ :title =" t('home.createNewNote.title')"
40+ :subtitle =" t('home.createNewNote.caption')"
41+ >
42+ <template #left >
43+ <Hammer />
44+ </template >
45+ <template #right >
46+ <Button
47+ secondary
48+ trailing-icon =" ChevronRight"
49+ >
50+ {{ t('home.createNewNote.button') }}
51+ </Button >
52+ </template >
53+ </Row >
54+ </div >
55+ </Container >
56+ </router-link >
57+
58+ <Heading
59+ :level =" 1"
60+ :class =" $style['page-header']"
61+ >
62+ {{ sectionTitle }}
63+ </Heading >
64+ <NoteList
65+ :key =" activeMenuItem"
66+ :only-created-by-user =" tabs[activeMenuItem].onlyCreatedByUser"
67+ />
68+ </template >
5269 </PageBlock >
5370</template >
5471
5572<script setup lang="ts">
5673import { useHead } from ' unhead' ;
5774import { useI18n } from ' vue-i18n' ;
5875import { useAppState } from ' @/application/services/useAppState' ;
59- import { Container , Row , Button , Heading , PageBlock } from ' @codexteam/ui/vue' ;
76+ import { Container , Row , Button , Heading , PageBlock , VerticalMenu , type VerticalMenuItem } from ' @codexteam/ui/vue' ;
6077import Hammer from ' ../components/pictures/Hammer.vue' ;
6178import NoteList from ' @/presentation/components/note-list/NoteList.vue' ;
6279import useAuth from ' @/application/services/useAuth' ;
80+ import { computed , ref } from ' vue' ;
6381
6482const { user } = useAppState ();
6583const { t } = useI18n ();
6684const { showGoogleAuthPopup } = useAuth ();
6785
86+ const tabs = {
87+ recents: {
88+ titleKey: ' home.sections.recents.title' ,
89+ onlyCreatedByUser: false ,
90+ },
91+ myNotes: {
92+ titleKey: ' home.sections.myNotes.title' ,
93+ onlyCreatedByUser: true ,
94+ },
95+ };
96+
97+ type TabId = keyof typeof tabs ;
98+
99+ const activeMenuItem = ref <TabId >(' recents' );
100+ const sectionTitle = computed (() => t (tabs [activeMenuItem .value ].titleKey ));
101+
102+ const verticalMenuItems = computed <VerticalMenuItem >(() => ({
103+ title: t (' home.navigation' ),
104+ isActive: false ,
105+ items: (Object .keys (tabs ) as TabId []).map (tabId => ({
106+ title: t (tabs [tabId ].titleKey ),
107+ isActive: activeMenuItem .value === tabId ,
108+ onActivate : () => {
109+ activeMenuItem .value = tabId ;
110+ },
111+ })),
112+ }));
113+
68114/**
69115 * Changing the title in the browser
70116 */
@@ -85,6 +131,6 @@ useHead({
85131}
86132
87133.page-header {
88- padding : var (--spacing-xxl ) var ( --h-padding ) 0 ;
134+ padding-top : var (--spacing-xxl );
89135}
90136 </style >
0 commit comments