Skip to content

Commit eacab9a

Browse files
susnuxShGKme
andcommitted
chore: Make the NcAppNavigationSearch a fully separated component
Co-authored-by: Grigorii K. Shartsev <[email protected]> Co-authored-by: Ferdinand Thiessen <[email protected]> Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 02e8cc0 commit eacab9a

File tree

9 files changed

+309
-298
lines changed

9 files changed

+309
-298
lines changed

l10n/messages.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ msgstr ""
332332
msgid "Search for time zone"
333333
msgstr ""
334334

335-
msgid "Search in app…"
335+
msgid "Search results"
336336
msgstr ""
337337

338-
msgid "Search results"
338+
msgid "Search"
339339
msgstr ""
340340

341341
#. FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'

src/components/NcAppNavigation/NcAppNavigation.vue

Lines changed: 15 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -33,117 +33,6 @@ emit('toggle-navigation', {
3333
})
3434
```
3535

36-
#### With in-app search
37-
38-
```vue
39-
<template>
40-
<div class="styleguide-wrapper">
41-
<NcContent app-name="styleguide-app-navigation" class="content-styleguidist">
42-
<NcAppNavigation show-search :search.sync="searchQuery">
43-
<template #search-actions>
44-
<NcActions aria-label="Filters">
45-
<template #icon>
46-
<IconFilter :size="20" />
47-
</template>
48-
<NcActionButton>
49-
<template #icon>
50-
<IconAccount :size="20" />
51-
</template>
52-
Filter by name
53-
</NcActionButton>
54-
<NcActionButton>
55-
<template #icon>
56-
<IconCalendarAccount :size="20" />
57-
</template>
58-
Filter by year
59-
</NcActionButton>
60-
</NcActions>
61-
<NcButton aria-label="Search globally" type="tertiary">
62-
<template #icon>
63-
<IconSearchGlobal :size="20" />
64-
</template>
65-
</NcButton>
66-
</template>
67-
<template #list>
68-
<NcAppNavigationItem name="First navigation entry">
69-
<template #icon>
70-
<IconStar :size="20" />
71-
</template>
72-
</NcAppNavigationItem>
73-
<NcAppNavigationItem name="Second navigation entry">
74-
<template #icon>
75-
<IconStar :size="20" />
76-
</template>
77-
</NcAppNavigationItem>
78-
</template>
79-
</NcAppNavigation>
80-
<NcAppContent>
81-
<ul class="fake-content">
82-
<li>Search query: {{ searchQuery }}</li>
83-
<li v-for="(item, index) in items" :key="index">
84-
{{ item }}
85-
</li>
86-
</ul>
87-
</NcAppContent>
88-
</NcContent>
89-
</div>
90-
</template>
91-
<script>
92-
import IconAccount from 'vue-material-design-icons/Account.vue'
93-
import IconCalendarAccount from 'vue-material-design-icons/CalendarAccount.vue'
94-
import IconFilter from 'vue-material-design-icons/Filter.vue'
95-
import IconSearchGlobal from 'vue-material-design-icons/CloudSearch.vue'
96-
import IconStar from 'vue-material-design-icons/Star.vue'
97-
98-
const exampleItem = ['Mary', 'Patricia', 'James', 'Michael']
99-
100-
export default {
101-
components: {
102-
IconAccount,
103-
IconCalendarAccount,
104-
IconFilter,
105-
IconSearchGlobal,
106-
IconStar,
107-
},
108-
109-
data() {
110-
return {
111-
searchQuery: '',
112-
}
113-
},
114-
115-
computed: {
116-
items() {
117-
return exampleItem.filter((item) => item.toLocaleLowerCase().includes(this.searchQuery.toLocaleLowerCase()))
118-
},
119-
},
120-
}
121-
</script>
122-
<style scoped>
123-
/* This styles just mock NcContent and NcAppContent */
124-
.content-styleguidist {
125-
position: relative !important;
126-
margin: 0 !important;
127-
/* prevent jumping */
128-
min-height: 200px;
129-
}
130-
131-
.content-styleguidist > * {
132-
height: auto;
133-
}
134-
135-
.fake-content {
136-
padding: var(--app-navigation-padding);
137-
padding-top: calc(2 * var(--app-navigation-padding) + var(--default-clickable-area));
138-
}
139-
140-
.styleguide-wrapper {
141-
background-color: var(--color-background-plain);
142-
padding: var(--body-container-margin);
143-
}
144-
</style>
145-
```
146-
14736
</docs>
14837

14938
<template>
@@ -157,28 +46,21 @@ export default {
15746
class="app-navigation__content"
15847
:inert="!open || undefined"
15948
@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>
16053
<div class="app-navigation__body" :class="{ 'app-navigation__body--no-list': !$scopedSlots.list }">
161-
<NcAppNavigationSearch v-if="showSearch"
162-
:label="searchLabel || undefined"
163-
:no-inline-actions="noSearchInlineActions"
164-
:value="search"
165-
@update:value="$emit('update:search', $event)">
166-
<template #actions>
167-
<!-- @slot Optional actions, like NcActions or icon only buttons, to show next to the search input -->
168-
<slot name="search-actions" />
169-
</template>
170-
</NcAppNavigationSearch>
171-
172-
<!-- 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. -->
17355
<slot />
17456
</div>
17557

17658
<NcAppNavigationList v-if="$scopedSlots.list" class="app-navigation__list">
177-
<!-- 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 -->
17860
<slot name="list" />
17961
</NcAppNavigationList>
18062

181-
<!-- Footer for e.g. NcAppNavigationSettings -->
63+
<!-- @slot Footer for e.g. NcAppNavigationSettings -->
18264
<slot name="footer" />
18365
</nav>
18466
<NcAppNavigationToggle :open="open" @update:open="toggleNavigation" />
@@ -192,7 +74,6 @@ import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
19274
import { createFocusTrap } from 'focus-trap'
19375

19476
import NcAppNavigationList from '../NcAppNavigationList/index.js'
195-
import NcAppNavigationSearch from './NcAppNavigationSearch.vue'
19677
import NcAppNavigationToggle from '../NcAppNavigationToggle/index.js'
19778
import Vue from 'vue'
19879

@@ -201,7 +82,6 @@ export default {
20182

20283
components: {
20384
NcAppNavigationList,
204-
NcAppNavigationSearch,
20585
NcAppNavigationToggle,
20686
},
20787

@@ -229,38 +109,6 @@ export default {
229109
type: String,
230110
default: '',
231111
},
232-
233-
/**
234-
* If set an in-app search is shown as the first entry
235-
*/
236-
showSearch: {
237-
type: Boolean,
238-
default: false,
239-
},
240-
241-
/**
242-
* The current search query
243-
*/
244-
search: {
245-
type: String,
246-
default: '',
247-
},
248-
249-
/**
250-
* Label of in-app search input
251-
*/
252-
searchLabel: {
253-
type: String,
254-
default: null,
255-
},
256-
257-
/**
258-
* Force a menu if there is more than one search action
259-
*/
260-
noSearchInlineActions: {
261-
type: Boolean,
262-
default: false,
263-
},
264112
},
265113

266114
setup() {
@@ -399,6 +247,14 @@ export default {
399247
margin-left: calc(-1 * min($navigation-width, var(--app-navigation-max-width)));
400248
}
401249

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

src/components/NcAppNavigation/NcAppNavigationSearch.vue

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)