-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathNcAppNavigationIconCollapsible.vue
More file actions
96 lines (83 loc) Ā· 1.79 KB
/
NcAppNavigationIconCollapsible.vue
File metadata and controls
96 lines (83 loc) Ā· 1.79 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
<!--
- SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<!-- Button to expand or collapse children -->
<NcButton
class="icon-collapse"
:class="{
'icon-collapse--active': active,
'icon-collapse--open': open,
}"
:aria-label="labelButton"
:variant="(active && isLegacy34) ? 'tertiary-on-primary' : 'tertiary'"
@click="onClick">
<template #icon>
<ChevronUp
v-if="open"
:size="20" />
<ChevronDown
v-else
:size="20" />
</template>
</NcButton>
</template>
<script>
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
import ChevronUp from 'vue-material-design-icons/ChevronUp.vue'
import { t } from '../../l10n.ts'
import { isLegacy34 } from '../../utils/legacy.ts'
import NcButton from '../NcButton/index.ts'
export default {
name: 'NcAppNavigationIconCollapsible',
components: {
NcButton,
ChevronDown,
ChevronUp,
},
setup() {
return { isLegacy34 }
},
props: {
/**
* Is the list currently open (or collapsed)
*/
open: {
type: Boolean,
required: true,
},
/**
* Is the navigation item currently active.
*/
active: {
type: Boolean,
required: true,
},
},
emits: ['click'],
computed: {
labelButton() {
return this.open ? t('Collapse menu') : t('Open menu')
},
},
methods: {
onClick(e) {
this.$emit('click', e)
},
},
}
</script>
<style lang="scss" scoped>
.icon-collapse {
position: relative;
inset-inline-end: 0;
// the whole navigation item is hovered thus will have the hover color - to distinguish we need to set a different color here.
&:hover {
background-color: var(--color-background-dark) !important;
}
&--active:hover {
background-color: var(--color-primary-element) !important;
}
}
</style>