-
-
Notifications
You must be signed in to change notification settings - Fork 668
Expand file tree
/
Copy pathContentAuth.vue
More file actions
274 lines (235 loc) · 6.45 KB
/
Copy pathContentAuth.vue
File metadata and controls
274 lines (235 loc) · 6.45 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<template>
<div class="content-auth">
<BaseButton
v-show="menuActive"
:aria-label="$t('navigation.closeSidebar')"
class="menu-hide-button d-print-none"
@click="baseStore.setMenuActive(false)"
>
<Icon icon="times" />
</BaseButton>
<div
class="app-container"
:class="{'has-background': background || blurHash}"
:style="{'background-image': blurHash && `url(${blurHash})`}"
>
<div
:class="{'is-visible': background}"
class="app-container-background background-fade-in d-print-none"
:style="{
'background-image': background && `url(${background})`,
'filter': backgroundBrightness && `brightness(${backgroundBrightness}%)`
}"
/>
<Navigation class="d-print-none" />
<main
id="main-content"
class="app-content"
:class="[
{ 'is-menu-enabled': menuActive },
$route.name,
]"
:style="{'--sidebar-width': sidebarWidth}"
>
<BaseButton
v-show="menuActive"
:aria-label="$t('navigation.closeSidebar')"
class="mobile-overlay d-print-none"
@click="baseStore.setMenuActive(false)"
/>
<QuickActions />
<RouterView
v-slot="{ Component }"
:route="routeWithModal"
>
<keep-alive :include="['project.view']">
<component :is="Component" />
</keep-alive>
</RouterView>
<Modal
:enabled="typeof currentModal !== 'undefined'"
variant="scrolling"
class="task-detail-view-modal"
:aria-label="$t('task.detail.title')"
@close="closeModal()"
>
<component
:is="currentModal"
@close="closeModal()"
/>
</Modal>
<BaseButton
v-shortcut="'Shift+Slash'"
class="keyboard-shortcuts-button d-print-none"
@click="showKeyboardShortcuts()"
>
<span class="is-sr-only">{{ $t('keyboardShortcuts.title') }}</span>
<Icon icon="keyboard" />
</BaseButton>
</main>
</div>
</div>
</template>
<script lang="ts" setup>
import {watch, computed, onBeforeUnmount} from 'vue'
import {useRoute, useRouter} from 'vue-router'
import Navigation from '@/components/home/Navigation.vue'
import QuickActions from '@/components/quick-actions/QuickActions.vue'
import BaseButton from '@/components/base/BaseButton.vue'
import {useBaseStore} from '@/stores/base'
import {useLabelStore} from '@/stores/labels'
import {useProjectStore} from '@/stores/projects'
import {useRouteWithModal} from '@/composables/useRouteWithModal'
import {useRenewTokenOnFocus} from '@/composables/useRenewTokenOnFocus'
import {useSidebarResize} from '@/composables/useSidebarResize'
import {useWebSocket} from '@/composables/useWebSocket'
import {useAuthStore} from '@/stores/auth'
const authStore = useAuthStore()
const backgroundBrightness = computed(() =>
authStore.settings?.frontendSettings?.backgroundBrightness,
)
const {sidebarWidth} = useSidebarResize()
const {routeWithModal, currentModal, closeModal} = useRouteWithModal()
const baseStore = useBaseStore()
const background = computed(() => baseStore.background)
const blurHash = computed(() => baseStore.blurHash)
const menuActive = computed(() => baseStore.menuActive)
function showKeyboardShortcuts() {
baseStore.setKeyboardShortcutsActive(true)
}
const route = useRoute()
const router = useRouter()
// FIXME: this is really error prone
// Reset the current project highlight in menu if the current route is not project related.
watch(() => route.name as string, (routeName) => {
if (
routeName &&
(
[
'home',
'teams.index',
'teams.edit',
'tasks.range',
'labels.index',
'migrate.start',
'migrate.wunderlist',
'projects.index',
].includes(routeName) ||
routeName.startsWith('user.settings')
)
) {
baseStore.handleSetCurrentProject({project: null})
}
})
// TODO: Reset the title if the page component does not set one itself
useRenewTokenOnFocus()
const {connect} = useWebSocket()
connect()
const labelStore = useLabelStore()
labelStore.loadAllLabels()
const projectStore = useProjectStore()
projectStore.loadAllProjects()
// Listen for task creation from the quick-entry window
const taskUpdateChannel = new BroadcastChannel('vikunja-task-updates')
taskUpdateChannel.onmessage = (event) => {
if (event.data?.type === 'task-created-open' && event.data?.taskId) {
router.push({name: 'task.detail', params: {id: event.data.taskId}})
}
}
onBeforeUnmount(() => {
taskUpdateChannel.close()
})
</script>
<style lang="scss" scoped>
.menu-hide-button {
position: fixed;
inset-block-start: 0.5rem;
inset-inline-end: 0.5rem;
z-index: 31;
inline-size: 3rem;
block-size: 3rem;
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
color: var(--grey-400);
line-height: 1;
transition: all $transition;
@media screen and (min-width: $tablet) {
display: none;
}
&:hover,
&:focus {
color: var(--grey-600);
}
}
.app-container {
min-block-size: calc(100vh - 65px);
@media screen and (max-width: $tablet) {
padding-block-start: $navbar-height;
}
}
.app-content {
--sidebar-width: #{$navbar-width};
display: flow-root;
z-index: 10;
position: relative;
padding: 1.5rem 0.5rem 0;
// TODO refactor: DRY `transition-timing-function` with `./Navigation.vue`.
transition: margin-inline-start $transition-duration;
@media screen and (max-width: $tablet) {
margin-inline-start: 0;
margin-inline-end: 0;
min-block-size: calc(100vh - 4rem);
}
@media screen and (min-width: $tablet) {
padding: $navbar-height + 1.5rem 1.5rem 0 1.5rem;
}
&.is-menu-enabled {
@media screen and (min-width: $tablet) {
margin-inline-start: var(--sidebar-width);
}
}
// Used to make sure the spinner is always in the middle while loading
> .loader-container {
min-block-size: calc(100vh - #{$navbar-height + 1.5rem + 1rem});
}
// FIXME: This should be somehow defined inside Card.vue
.card {
background: var(--white);
}
}
.mobile-overlay {
display: none;
position: fixed;
inset-block-start: 0;
inset-block-end: 0;
inset-inline-start: 0;
inset-inline-end: 0;
block-size: 100vh;
inline-size: 100vw;
background: hsla(var(--grey-100-hsl), 0.8);
z-index: 5;
opacity: 0;
transition: all $transition;
@media screen and (max-width: $tablet) {
display: block;
opacity: 1;
}
}
.keyboard-shortcuts-button {
position: fixed;
inset-block-end: calc(1rem - 4px);
inset-inline-end: 1rem;
z-index: 4500; // The modal has a z-index of 4000
color: var(--grey-500);
transition: color $transition;
@media screen and (max-width: $tablet) {
display: none;
}
}
.content-auth {
position: relative;
z-index: 1;
}
</style>