Skip to content

Commit

Permalink
WIP: New UI global search
Browse files Browse the repository at this point in the history
Resolves: #39162

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Oct 16, 2023
1 parent 356c221 commit 2c653fe
Show file tree
Hide file tree
Showing 7 changed files with 417 additions and 0 deletions.
68 changes: 68 additions & 0 deletions core/src/components/GlobalSearch/SearchResultItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!--
- @copyright Copyright (c) 2020 Fon E. Noel NFEBE <[email protected]>
-
- @author Fon E. Noel NFEBE <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div class="result-item">

Check failure on line 23 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
<slot name="icon"></slot>

Check failure on line 24 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
<div class="details">

Check failure on line 25 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
<span>Result Title</span>

Check failure on line 26 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
<small>More details about result</small>

Check failure on line 27 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
</div>

Check failure on line 28 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
</div>

Check failure on line 29 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected "\t" character, but found " " character
</template>

<script>
export default {
name: 'SearchResultItem',

Check failure on line 35 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected indentation of 1 tab but found 2 spaces
components: {

Check failure on line 36 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected indentation of 1 tab but found 2 spaces
},

Check failure on line 37 in core/src/components/GlobalSearch/SearchResultItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected indentation of 1 tab but found 2 spaces
data() {
return {
}
},
methods: {
},
}
</script>

<style lang="scss" scoped>
.result-item {
display: flex;
padding: 5px; /* Add padding for the border effect */
border: 1px solid #f0f0f0; /* Faint border */
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); /* Light shadow */
transition: background-color 0.3s ease; /* Smooth hover transition */
& .details {
display: flex;
flex-direction: column;
}
&:hover {
background-color: var(--color-placeholder-light);
}
}
</style>
55 changes: 55 additions & 0 deletions core/src/global-search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @copyright Copyright (c) 2020 Fon E. Noel NFEBE <[email protected]>
*
* @author Fon E. Noel NFEBE <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { getLoggerBuilder } from '@nextcloud/logger'
import { getRequestToken } from '@nextcloud/auth'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import Vue from 'vue'

import GlobalSearch from './views/GlobalSearch.vue'

// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())

const logger = getLoggerBuilder()
.setApp('global-search')
.detectUser()
.build()

Vue.mixin({
data() {
return {
logger,
}
},
methods: {
t,
n,
},
})

export default new Vue({
el: '#global-search',
// eslint-disable-next-line vue/match-component-file-name
name: 'GlobalSearchRoot',
render: h => h(GlobalSearch),
})
61 changes: 61 additions & 0 deletions core/src/views/GlobalSearch.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!--
- @copyright Copyright (c) 2020 Fon E. Noel NFEBE <[email protected]>
-
- @author Fon E. Noel NFEBE <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<div>
<NcButton aria-label="Global search" @click="toggleGlobalSearch">
<template #icon>
<Magnify class="unified-search__trigger" :size="22" />
</template>
</NcButton>
<GlobalSearchModal :isVisible="showGlobalSearch" />
</div>
</template>

<script>
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import Magnify from 'vue-material-design-icons/Magnify.vue'
import GlobalSearchModal from './GlobalSearchModal.vue';
export default {
name: 'GlobalSearch',
components: {
NcButton,
Magnify,
GlobalSearchModal,
},
data() {
return {
showGlobalSearch: false,
};
},
mounted() {
console.debug("Global search initialized!")
},
methods: {
toggleGlobalSearch() {
this.showGlobalSearch = !this.showGlobalSearch
}
}
};
</script>

<style lang="scss" scoped></style>
Loading

0 comments on commit 2c653fe

Please sign in to comment.