-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathNcAppNavigationSettings.vue
More file actions
149 lines (129 loc) · 2.84 KB
/
NcAppNavigationSettings.vue
File metadata and controls
149 lines (129 loc) · 2.84 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
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div
id="app-settings"
v-click-outside="clickOutsideConfig"
:class="{ open }">
<div id="app-settings__header">
<NcButton
:aria-controls="contentId"
:aria-expanded="open ? 'true' : 'false'"
class="settings-button"
alignment="start"
variant="tertiary"
wide
@click="open = !open">
<template #icon>
<NcIconSvgWrapper class="settings-button__icon" :path="isLegacy32 ? mdiCog : mdiCogOutline" />
</template>
{{ name }}
</NcButton>
</div>
<Transition name="slide-up">
<div v-show="open" :id="contentId">
<slot />
</div>
</Transition>
</div>
</template>
<script>
import { mdiCog, mdiCogOutline } from '@mdi/js'
import { vOnClickOutside as ClickOutside } from '@vueuse/components'
import NcButton from '../NcButton/NcButton.vue'
import NcIconSvgWrapper from '../NcIconSvgWrapper/NcIconSvgWrapper.vue'
import { t } from '../../l10n.js'
import { clickOutsideOptions } from '../../mixins/index.js'
import GenRandomId from '../../utils/GenRandomId.js'
import { isLegacy32 } from '../../utils/legacy.ts'
export default {
directives: {
ClickOutside,
},
components: {
NcButton,
NcIconSvgWrapper,
},
mixins: [
clickOutsideOptions,
],
props: {
/**
* Text of the button
*
* @default 'Settings'
*/
name: {
type: String,
required: false,
default: t('Settings'),
},
},
setup() {
const contentId = GenRandomId()
return {
contentId,
isLegacy32,
mdiCog,
mdiCogOutline,
}
},
data() {
return {
open: false,
}
},
computed: {
clickOutsideConfig() {
return [
this.closeMenu,
this.clickOutsideOptions,
]
},
},
methods: {
closeMenu() {
this.open = false
},
},
}
</script>
<style lang="scss" scoped>
#app-settings {
margin-top: auto;
padding: $app-navigation-settings-margin;
&__header {
box-sizing: border-box;
margin: 0 $app-navigation-settings-margin $app-navigation-settings-margin $app-navigation-settings-margin;
.settings-button {
padding-inline: 0 calc((var(--default-clickable-area) - 16px) / 2) !important;
:deep(.button-vue__text) {
font-weight: var(--font-weight-default, normal) !important;
}
}
}
&__content {
display: block;
padding: 10px;
/* prevent scrolled contents from stopping too early */
margin-bottom: -$app-navigation-settings-margin;
/* restrict height of settings and make scrollable */
max-height: 300px;
overflow-y: auto;
box-sizing: border-box;
}
}
.slide-up-leave-active,
.slide-up-enter-active {
transition-duration: var(--animation-slow);
transition-property: max-height, padding;
overflow-y: hidden !important;
}
.slide-up-enter,
.slide-up-leave-to {
max-height: 0 !important;
padding: 0 10px !important;
}
</style>