Repository navigation
Expand file tree
/
Copy pathDesktopHeader.vue
More file actions
145 lines (123 loc) · 3.4 KB
/
Copy pathDesktopHeader.vue
File metadata and controls
145 lines (123 loc) · 3.4 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
<!--
- SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<script setup>
import { onMounted, onUnmounted } from 'vue'
import MainMenu from './components/MainMenu.vue'
import UserMenu from './components/UserMenu.vue'
import { appData } from '../../app/AppData.js'
import { useUserStatusStore } from './UserStatus/userStatus.store.js'
import { useAppConfigStore } from './Settings/appConfig.store.ts'
import { useUserStatusHeartbeat } from './UserStatus/useUserStatusHeartbeat.js'
useUserStatusStore()
useUserStatusHeartbeat()
useAppConfigStore()
const isPreview = false
const user = appData.userMetadata
const OS = window.systemInfo
/**
* Push to root in Talk app to unselect any chat
*/
function pushToRoot() {
window.OCA.Talk.instance?.$router?.push({ name: 'root' }).catch(() => {})
}
/**
* Logout in Talk Desktop
*/
function logout() {
window.TALK_DESKTOP.logout()
}
/**
* Handle the global escape key to unselect any chat
* @param {KeyboardEvent} event - Keyboard event
*/
function handleGlobalEscape(event) {
if (event.key === 'Escape' && document.activeElement === document.body) {
pushToRoot()
}
}
onMounted(() => {
window.addEventListener('keydown', handleGlobalEscape, { capture: true })
})
onUnmounted(() => {
window.removeEventListener('keydown', handleGlobalEscape, { capture: true })
})
</script>
<template>
<header id="header" class="header">
<div class="header__inner">
<div v-if="!OS.isMac"
class="header__title-wrapper"
role="button"
tabindex="0"
@click="pushToRoot">
<span class="header__title">Nextcloud Talk</span>
<span v-if="isPreview" class="header__preview-badge">Preview</span>
</div>
<div class="spacer" />
<div class="header__item" :data-theme-dark="!OS.isMac ? true : undefined">
<MainMenu />
</div>
<div class="header__item">
<UserMenu :user="user" @logout="logout" />
</div>
</div>
</header>
</template>
<style scoped>
.header {
height: var(--header-height);
margin-bottom: calc(-1 * var(--header-height));
box-sizing: border-box;
color: var(--color-header-contrast);
user-select: none;
}
.header__inner {
padding: 0 calc(var(--body-container-margin) + 4px) 0 var(--body-container-margin);
display: flex;
align-items: center;
height: 100%;
/* Save space for native title bar buttons */
x-margin-inline-start: env(titlebar-area-x, 0);
margin-inline-start: calc(300px - 1px);
background-color: var(--color-main-background-macos);
x-width: env(titlebar-area-width, 100%);
width: calc(100% - 300px + 1);
border-inline-start: 1px solid var(--color-border-macos);
border-block-end: 1px solid var(--color-border-macos);
transition: margin-inline-start var(--animation-quick) ease;
}
body:has(#app-navigation-vue[aria-hidden="true"]) .header__inner {
margin-inline-start: 0;
border-inline-start: none;
}
.header__item {
width: var(--header-height); /* Make it square */
display: flex;
justify-content: center;
}
.header__title-wrapper {
display: flex;
align-items: center;
height: 100%;
margin-inline-start: calc(var(--default-grid-baseline) * 3);
position: relative;
&:focus-visible::after {
bottom: 0;
}
}
.header__title {
font-size: 18px;
font-weight: bold;
}
.header__preview-badge {
margin-inline-start: var(--default-grid-baseline);
}
.spacer {
flex: 1 0 auto;
height: 100%;
/* Allow to drag the window using header */
app-region: drag;
}
</style>