-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTop.vue
219 lines (214 loc) · 5.75 KB
/
Top.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<template>
<div>
<header class="main__header">
<div class="container">
<button
class="hamburger"
type="button"
aria-label="Menú"
:aria-expanded="menu.activo.toString()"
:aria-controls="menuId"
@click="toggleMenu"
@keyup.enter="toggleMenu"
>
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</button>
<h1 v-if="title">{{ title }}</h1>
<nuxt-link
:to="{ name: 'buscar' }"
:tag="$route.name === 'buscar' ? 'span' : 'a'"
class="rounded__btn--medium buscar"
>
Buscar
</nuxt-link>
<form
class="form__buscar"
aria-controls="resultado-busqueda"
@submit.prevent="$router.push({ query: { busqueda } })"
>
<label for="buscar" class="form__buscar--icon"></label>
<input
id="buscar"
v-model="busqueda"
type="text"
name="buscar"
aria-label="Buscar en FucerNet"
placeholder="Buscar en FucerNet"
/>
</form>
</div>
</header>
<nav
:id="menuId"
aria-label="Navegación principal"
:class="'main__nav--container' + (menu.activo ? ' active' : '')"
>
<div class="overlay" @click="closeMenu" @keyup.enter="closeMenu"></div>
<focus-trap
:active="menu.activo"
:initial-focus="() => $refs.mainMenuInitialFocus.$el"
:return-focus-on-deactivate="false"
@activate="openMenu"
@deactivate="closeMenu"
>
<div class="main__nav">
<div v-if="$auth.loggedIn" class="user__info">
<span>{{ $auth.user.nombre }}</span>
<small>{{ $auth.user.email }}</small>
</div>
<ul>
<li>
<nuxt-link
ref="mainMenuInitialFocus"
:tag="$route.name === 'inicio' ? 'span' : 'a'"
:to="{ name: 'inicio' }"
>
Inicio
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'buscar' ? 'span' : 'a'"
:to="{ name: 'buscar' }"
>
Buscar
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'favoritas' ? 'span' : 'a'"
:to="{ name: 'favoritas' }"
>
Favoritas
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'suplemento' ? 'span' : 'a'"
:to="{ name: 'suplemento' }"
>
Suplemento Registral
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'dictamenes' ? 'span' : 'a'"
:to="{ name: 'dictamenes' }"
>
Dictámenes AAERPA
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'separata' ? 'span' : 'a'"
:to="{ name: 'separata' }"
>
Separata Anual de Normas
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'configuracion' ? 'span' : 'a'"
:to="{ name: 'configuracion' }"
>
Configuración
</nuxt-link>
</li>
<li>
<nuxt-link
:tag="$route.name === 'ayuda' ? 'span' : 'a'"
:to="{ name: 'ayuda' }"
>
Ayuda
</nuxt-link>
</li>
<li>
<a href="https://www.dnrpa.gov.ar/nuevodigesto/" target="_blank">
Digesto
</a>
</li>
<li v-if="$auth.loggedIn">
<a href="#" @click="logout()" @keyup.enter="logout()"
>Cerrar Sesión</a
>
</li>
</ul>
<button
class="main__nav--cerrar"
@click="closeMenu"
@keyup.enter="closeMenu"
>
Cerrar menú
</button>
<span class="logo">
<img src="~/assets/img/logo-fucernet.svg" alt="" width="100" />
</span>
</div>
</focus-trap>
</nav>
</div>
</template>
<script>
import { mapActions, mapState } from "vuex";
export default {
props: {
title: {
type: String,
default: "",
},
},
data() {
return {
menuId: "menu-principal",
busqueda: "",
};
},
computed: {
...mapState(["menu"]),
},
watch: {
"$route.query.busqueda": {
handler: async function (newBusqueda) {
this.busqueda = newBusqueda;
},
immediate: true,
},
},
methods: {
...mapActions(["setMenuActivo"]),
toggleMenu() {
if (this.menu.activo) {
this.closeMenu();
} else {
this.openMenu();
}
},
openMenu() {
this.setMenuActivo(true);
this.$refs.mainMenuInitialFocus.$el.focus();
},
closeMenu() {
this.setMenuActivo(false);
if ("#menu-principal" === this.$route.hash) {
this.$router.push({ hash: "" });
}
},
async logout() {
if (
!window.navigator.onLine &&
!confirm(
"Está sin conexión a internet y no va a poder volver a acceder hasta que vuelva la conexión ¿quiere cerrar la sesión igualmente?"
)
)
return;
await this.$auth.logout();
this.$router.push("/");
},
},
};
</script>
<style lang="sass">
@import 'sass/components/top.sass'
</style>