-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFilePickerNavigation.vue
More file actions
158 lines (141 loc) · 3.75 KB
/
Copy pathFilePickerNavigation.vue
File metadata and controls
158 lines (141 loc) · 3.75 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
<!--
- SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<Fragment>
<!-- Filter for the file list -->
<NcTextField class="file-picker__filter-input"
:model-value="filterString"
:label="t('Filter file list')"
:show-trailing-button="!!filterString"
@update:model-value="updateFilterValue"
@trailing-button-click="updateFilterValue('')">
<IconMagnify :size="16" />
<template #trailing-button-icon>
<IconClose :size="16" />
</template>
</NcTextField>
<template v-if="availableViews.length > 1 && !disabledNavigation">
<!-- On non collapsed dialogs show the tablist, otherwise a dropdown is shown -->
<ul v-if="!isCollapsed"
class="file-picker__side">
<li v-for="view in availableViews" :key="view.id">
<NcButton :type="currentView === view.id ? 'primary' : 'tertiary'"
:wide="true"
@click="$emit('update:currentView', view.id)">
<template #icon>
<NcIconSvgWrapper :path="view.icon" :size="20" />
</template>
{{ view.label }}
</NcButton>
</li>
</ul>
<NcSelect v-else
:aria-label="t('Current view selector')"
:clearable="false"
:searchable="false"
:options="availableViews"
:value="currentViewObject"
@update:model-value="v => emit('update:currentView', v.id)" />
</template>
</Fragment>
</template>
<script setup lang="ts">
import IconClose from 'vue-material-design-icons/Close.vue'
import IconMagnify from 'vue-material-design-icons/Magnify.vue'
import { getCurrentUser } from '@nextcloud/auth'
import { NcButton, NcIconSvgWrapper, NcSelect, NcTextField } from '@nextcloud/vue'
import { computed, ref, Fragment } from 'vue'
import { t } from '../../utils/l10n'
import { useViews } from '../../composables/views'
const props = defineProps<{
currentView: 'files' | 'recent' | 'favorites',
filterString: string,
isCollapsed: boolean,
disabledNavigation: boolean,
}>()
interface INavigationEvents {
(e: 'update:currentView', v: typeof props.currentView): void
(e: 'update:filterString', v: string): void
}
const emit = defineEmits<INavigationEvents>()
const { availableViews } = useViews(ref(getCurrentUser() === null))
/**
* The currently active view object
*/
const currentViewObject = computed(() => availableViews.filter(v => v.id === props.currentView)[0] ?? availableViews[0])
/**
* Propagate current filter value to paren
*
* @param value The new filter value
*/
const updateFilterValue = (value: string) => emit('update:filterString', value)
</script>
<style scoped lang="scss">
.file-picker {
&__side {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 0.5rem;
min-width: 200px;
// ensure focus outline is visible
padding: 2px;
// align with input
margin-block-start: 7px;
// make only the navigation scroll
overflow: auto;
:deep(.button-vue__wrapper) {
justify-content: start;
}
}
&__filter-input {
// Align with view title and breadcrumbs
margin-block: 7px; // 36px height + 2x 7px => 50px
max-width: 260px;
}
}
// Ensure filepicker works on mobile
@media (max-width: 736px) {
.file-picker {
&__side {
flex-direction: row;
min-width: unset;
}
}
}
@media (max-width: 512px) {
.file-picker {
&__side {
flex-direction: row;
min-width: unset;
}
&__filter-input {
max-width: unset;
}
}
}
</style>
<style lang="scss">
/* Ensure focus outline is visible */
.file-picker__navigation {
padding-inline: 8px 2px;
&, * {
box-sizing: border-box;
}
.v-select.select {
min-width: 220px;
}
}
@media (min-width: 513px) and (max-width: 736px) {
.file-picker__navigation {
gap: 11px;
}
}
@media (max-width: 512px) {
.file-picker__navigation {
flex-direction: column-reverse!important;
}
}
</style>