Skip to content

Commit 7afe655

Browse files
authored
Merge pull request #5831 from nextcloud-libraries/feat/app-navigation-search
feat(NcAppNavigation): Provide consistent in-app search
2 parents f57e30d + eacab9a commit 7afe655

File tree

7 files changed

+313
-19
lines changed

7 files changed

+313
-19
lines changed

l10n/messages.pot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ msgstr ""
335335
msgid "Search results"
336336
msgstr ""
337337

338+
msgid "Search…"
339+
msgstr ""
340+
338341
#. FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'
339342
msgid "sec. ago"
340343
msgstr ""

src/components/NcAppNavigation/NcAppNavigation.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,21 @@ emit('toggle-navigation', {
4646
class="app-navigation__content"
4747
:inert="!open || undefined"
4848
@keydown.esc="handleEsc">
49+
<div class="app-navigation__search">
50+
<!-- @slot For in-app search you can pass a `NcAppNavigationSearch` component as the slot content. -->
51+
<slot name="search" />
52+
</div>
4953
<div class="app-navigation__body" :class="{ 'app-navigation__body--no-list': !$scopedSlots.list }">
50-
<!-- The main content of the navigation. If no list is passed to the #list slot, stretched vertically. -->
54+
<!-- @slot The main content of the navigation. If no list is passed to the #list slot, stretched vertically. -->
5155
<slot />
5256
</div>
5357

5458
<NcAppNavigationList v-if="$scopedSlots.list" class="app-navigation__list">
55-
<!-- List for Navigation list items. Stretched between the main content and the footer -->
59+
<!-- @slot List for Navigation list items. Stretched between the main content and the footer -->
5660
<slot name="list" />
5761
</NcAppNavigationList>
5862

59-
<!-- Footer for e.g. NcAppNavigationSettings -->
63+
<!-- @slot Footer for e.g. NcAppNavigationSettings -->
6064
<slot name="footer" />
6165
</nav>
6266
<NcAppNavigationToggle :open="open" @update:open="toggleNavigation" />
@@ -69,8 +73,8 @@ import { getTrapStack } from '../../utils/focusTrap.js'
6973
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
7074
import { createFocusTrap } from 'focus-trap'
7175

72-
import NcAppNavigationToggle from '../NcAppNavigationToggle/index.js'
7376
import NcAppNavigationList from '../NcAppNavigationList/index.js'
77+
import NcAppNavigationToggle from '../NcAppNavigationToggle/index.js'
7478
import Vue from 'vue'
7579

7680
export default {
@@ -159,7 +163,7 @@ export default {
159163
* @param {boolean} [state] set the state instead of inverting the current one
160164
*/
161165
toggleNavigation(state) {
162-
// Early return if alreay in that state
166+
// Early return if already in that state
163167
if (this.open === state) {
164168
emit('navigation-toggled', {
165169
open: this.open,
@@ -206,7 +210,7 @@ export default {
206210
<style lang="scss">
207211
.app-navigation,
208212
.app-content {
209-
/** Distance of the app naviation toggle and the first navigation item to the top edge of the app content container */
213+
/** Distance of the app navigation toggle and the first navigation item to the top edge of the app content container */
210214
--app-navigation-padding: #{$app-navigation-padding};
211215
}
212216
</style>
@@ -243,6 +247,14 @@ export default {
243247
margin-left: calc(-1 * min($navigation-width, var(--app-navigation-max-width)));
244248
}
245249

250+
&__search {
251+
width: 100%;
252+
}
253+
254+
&__body {
255+
overflow-y: scroll;
256+
}
257+
246258
// For legacy purposes support passing a bare list to the content in #default slot and including #footer slot
247259
// Same styles as NcAppNavigationList
248260
&__content > ul {

src/components/NcAppNavigationItem/NcAppNavigationItem.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
<docs>
77

8-
# Usage
8+
### Usage
99

10-
### Simple element
10+
#### Simple element
1111

1212
* With an icon:
1313

@@ -46,7 +46,7 @@
4646
</ul>
4747
```
4848

49-
### Element with actions
49+
#### Element with actions
5050
Wrap the children in a template. If you have more than 2 actions, a popover menu and a menu
5151
button will be automatically created.
5252

@@ -98,7 +98,7 @@ button will be automatically created.
9898
</script>
9999
```
100100

101-
### Element with counter
101+
#### Element with counter
102102
Just nest the counter in a template within `<NcAppNavigationItem>` and add `#counter` to it.
103103

104104
```vue
@@ -127,7 +127,7 @@ Just nest the counter in a template within `<NcAppNavigationItem>` and add `#cou
127127
</script>
128128
```
129129

130-
### Element with children
130+
#### Element with children
131131

132132
Wrap the children in a template with the `slot` property and use the prop `allowCollapse` to choose wether to allow or
133133
prevent the user from collapsing the items.
@@ -189,7 +189,7 @@ prevent the user from collapsing the items.
189189
</script>
190190
```
191191

192-
### Editable element
192+
#### Editable element
193193
Add the prop `:editable=true` and an edit placeholder if you need it. By default
194194
the placeholder is the previous name of the element.
195195

@@ -215,7 +215,7 @@ the placeholder is the previous name of the element.
215215
</script>
216216
```
217217

218-
### Undo element
218+
#### Undo element
219219
Just set the `undo` and `name` props. When clicking the undo button, an `undo` event is emitted.
220220

221221
```
@@ -224,7 +224,7 @@ Just set the `undo` and `name` props. When clicking the undo button, an `undo` e
224224
</ul>
225225
```
226226

227-
### Link element
227+
#### Link element
228228
Href that start by http will be treated as external and opened in a new tab
229229
```
230230
<div>
@@ -235,14 +235,14 @@ Href that start by http will be treated as external and opened in a new tab
235235
</div>
236236
```
237237

238-
### Custom title
238+
#### Custom title
239239
```
240240
<ul>
241241
<NcAppNavigationItem name="Nextcloud" title="Open the Nextcloud website" href="https://nextcloud.com" />
242242
</ul>
243243
```
244244

245-
### Pinned element
245+
#### Pinned element
246246
Just set the `pinned` prop.
247247
```
248248
<ul>

src/components/NcAppNavigationNewItem/NcAppNavigationNewItem.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
-->
55

66
<docs>
7-
# Usage
7+
### Usage
88

9-
### New Item element
9+
#### New Item element
1010
```vue
1111
<template>
1212
<NcAppNavigationNewItem name="New Item" @new-item="function(value){alert(value)}">
@@ -26,7 +26,7 @@
2626
</script>
2727
```
2828

29-
### New Item element with a loading animation instead of the icon
29+
#### New Item element with a loading animation instead of the icon
3030
```vue
3131
<template>
3232
<NcAppNavigationNewItem name="New Item" :loading="true">

0 commit comments

Comments
 (0)