Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

chore(frontend): improve search UI

johaven9aa8c9c14e0f
diff --git a/frontend/src/app/applications/search/components/search.component.html b/frontend/src/app/applications/search/components/search.component.html
index e740e6d0..452fd939 100644
--- a/frontend/src/app/applications/search/components/search.component.html
+++ b/frontend/src/app/applications/search/components/search.component.html
@@ -9,63 +9,68 @@
[placeholder]="(this.store.currentSearch().fullText ? 'Search for content' : 'Search for files')|translate:locale.language"
(keyup.enter)="doSearch()"
(keyup.escape)="clearSearch()"
- class="flex-fill form-control form-control-sm"
+ class="search-input flex-fill form-control form-control-sm"
name="search"
type="text"
- style="padding-right: 2rem"
appAutofocus
autocomplete>
@if (searchContent()) {
- <span class="cursor-pointer" style="position: absolute; right: 40px; top: 3px; z-index: 1001; font-size: 1rem">
+ <span class="search-clear-btn">
<fa-icon (click)="clearSearch()" [icon]="icons.faTimes" role="button"></fa-icon>
</span>
}
<button [ngModel]="this.store.currentSearch().fullText"
(ngModelChange)="toggleFullText()"
[tooltip]="'Search for content'|translate:locale.language"
+ container="body"
placement="bottom"
- class="btn btn-sm btn-outline-secondary-alt fs-2xs"
+ class="btn btn-sm btn-custom"
role="button"
type="button"
btnCheckbox>
<fa-icon [icon]="icons.faFont"></fa-icon>
</button>
</div>
+
</div>
+ <button (click)="goTo(null, selectedId)"
+ [disabled]="selectedId === null"
+ class="search-go-to-btn d-none d-md-block btn btn-sm btn-default"
+ [tooltip]="'Go to' | translate:locale.language"
+ container="body"
+ type="button">
+ <fa-icon [icon]="icons.faMapMarkerAlt"></fa-icon>
+ </button>
<!--Start Filter Button-->
- <app-input-filter class="d-none d-sm-none d-md-block d-lg-block ms-auto"></app-input-filter>
+ <app-input-filter class="d-none d-md-block ms-auto"></app-input-filter>
<!--End Filter Button-->
</div>
-<div appAutoResize class="fs-xs">
+<div appAutoResize class="search-results-list" role="list">
@if (errorMessage) {
<div class="p-3 text-danger fw-500" l10nTranslate>{{ errorMessage }}</div>
}
@for (f of this.store.filesSearch() | searchFilter:inputFilter.search(); track $index) {
- <div class="app-div-striped py-2" (click)="selectedId = $index" (appTap)="goTo(f)" [class.selected]="$index === selectedId">
- <div class="d-flex align-items-center text-truncate px-2 py-1">
- <img [src]="f.mimeUrl" (error)="f.fallBackMimeUrl()" alt="" draggable="false" height="28">
- <div class="d-flex flex-column text-truncate ms-2" style="height: 34px">
- <span class="fs-2xs text-truncate">{{ f.name }}</span>
- <div class="d-flex align-items-center text-{{f.iconClass}}">
- <fa-icon [icon]="f.icon" class="me-1"></fa-icon>
- <span class="fs-3xs text-truncate">
- <span>{{ f.showedPath }}</span>
- </span>
+ <article class="app-div-striped search-result-item"
+ (click)="selectedId = $index"
+ (appTap)="goTo(f)"
+ [class.selected]="$index === selectedId">
+ <div class="search-result-header d-flex align-items-start">
+ <img [src]="f.mimeUrl" (error)="f.fallBackMimeUrl()" alt="" draggable="false" class="search-result-mime">
+ <div class="search-result-meta d-flex flex-column">
+ <span class="search-result-name text-truncate">{{ f.name }}</span>
+ <div class="search-result-path d-flex align-items-center text-{{f.iconClass}}">
+ <fa-icon [icon]="f.icon" class="search-result-path-icon"></fa-icon>
+ <span class="text-truncate search-result-path-text">{{ f.showedPath }}</span>
</div>
</div>
</div>
@if (f.matches?.length) {
- <hr class="m-0">
- <div class="d-flex flex-column px-2 py-1">
+ <div class="search-result-matches">
@for (match of f.matches; track $index) {
- <div>
- <span>...</span>
- <span class="fs-3xs" [innerHTML]="match"></span>
- <span>...</span>
- </div>
+ <p class="search-result-match" [innerHTML]="match"></p>
}
</div>
}
- </div>
+ </article>
}
</div>
diff --git a/frontend/src/app/applications/search/components/search.component.ts b/frontend/src/app/applications/search/components/search.component.ts
index cf40f17c..204e7cd6 100644
--- a/frontend/src/app/applications/search/components/search.component.ts
+++ b/frontend/src/app/applications/search/components/search.component.ts
@@ -3,7 +3,7 @@ import { Component, computed, inject, Signal, ViewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { Router } from '@angular/router'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
-import { faFont, faSpinner, faTimes, faTrashCan } from '@fortawesome/free-solid-svg-icons'
+import { faFont, faMapMarkerAlt, faSpinner, faTimes, faTrashCan } from '@fortawesome/free-solid-svg-icons'
import { minCharsToSearch } from '@sync-in-server/backend/src/applications/files/constants/indexing'
import type { SearchFilesDto } from '@sync-in-server/backend/src/applications/files/dto/file-operations.dto'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'
@@ -14,6 +14,7 @@ import { AutofocusDirective } from '../../../common/directives/auto-focus.direct
import { AutoResizeDirective } from '../../../common/directives/auto-resize.directive'
import { TapDirective } from '../../../common/directives/tap.directive'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
+import { filterArray } from '../../../common/utils/functions'
import { LayoutService } from '../../../layout/layout.service'
import { StoreService } from '../../../store/store.service'
import { FileContentModel } from '../../files/models/file-content.model'
@@ -33,8 +34,8 @@ import { SEARCH_ICON, SEARCH_PATH } from '../search.constants'
AutoResizeDirective,
TooltipDirective,
SearchFilterPipe,
- TapDirective,
- L10nTranslateDirective
+ L10nTranslateDirective,
+ TapDirective
],
templateUrl: './search.component.html'
})
@@ -43,7 +44,7 @@ export class SearchComponent {
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected readonly store = inject(StoreService)
public searchContent: Signal<string> = computed(() => this.store.currentSearch().content)
- protected readonly icons = { SEARCH_ICON, faSpinner, faTrashCan, faTimes, faFont }
+ protected readonly icons = { SEARCH_ICON, faSpinner, faTrashCan, faTimes, faFont, faMapMarkerAlt }
protected minCharsToSearch = minCharsToSearch
protected loading = false
protected errorMessage: string = null
@@ -90,7 +91,16 @@ export class SearchComponent {
this.store.filesSearch.set([])
}
- goTo(f: FileContentModel) {
+ goTo(f?: FileContentModel, index?: number) {
+ if (!f) {
+ const files = this.store.filesSearch()
+ const query = this.inputFilter?.search?.() ?? ''
+ const visibleFiles = query ? filterArray(query, files) : files
+ f = visibleFiles.find((_, i) => i === index)
+ }
+ if (!f) {
+ return
+ }
this.router.navigate([SPACES_PATH.SPACES, ...f.path.split('/')], { queryParams: { select: f.name } }).catch(console.error)
}
}
diff --git a/frontend/src/styles/components/_search.scss b/frontend/src/styles/components/_search.scss
new file mode 100644
index 00000000..7e6e8cb5
--- /dev/null
+++ b/frontend/src/styles/components/_search.scss
@@ -0,0 +1,95 @@
+.search-results-list {
+ padding: 0.2rem 0.25rem 0.4rem;
+}
+
+.search-input {
+ padding-right: 2rem;
+}
+
+.search-clear-btn {
+ position: absolute;
+ top: 0.25rem;
+ right: 2.8125rem;
+ z-index: 1001;
+ font-size: 1rem;
+ cursor: pointer;
+}
+
+.search-go-to-btn {
+ margin-left: 0.3rem;
+}
+
+.search-result-item {
+ margin: 0.3rem 0.15rem;
+ padding: 0.25rem 0;
+ border-radius: 0.35rem;
+ border: 1px solid transparent;
+ overflow: hidden;
+ background: transparent;
+}
+
+.search-result-header {
+ padding: 0.4rem;
+ min-height: 2.2rem;
+}
+
+.search-result-mime {
+ width: 1.75rem;
+ height: 1.75rem;
+ flex: 0 0 auto;
+ margin-top: 0.1rem;
+}
+
+.search-result-meta {
+ min-width: 0;
+ margin-left: 0.3rem;
+ line-height: 1.2;
+}
+
+.search-result-name {
+ font-size: $font-size-xs;
+ font-weight: 500;
+ line-height: 1.2;
+}
+
+.search-result-path {
+ min-width: 0;
+ line-height: 1.15;
+}
+
+.search-result-path-icon {
+ font-size: $font-size-2xs;
+ flex: 0 0 auto;
+ margin-right: 0.25rem;
+}
+
+.search-result-path-text {
+ font-size: $font-size-2xs;
+ min-width: 0;
+ user-select: none;
+}
+
+.search-result-matches {
+ margin-top: 0.1rem;
+ padding: 0.3rem 0.5rem 0.5rem;
+ border-top: 0.5px solid transparent;
+ display: flex;
+ flex-direction: column;
+ gap: 0.18rem;
+}
+
+.search-result-match {
+ margin: 0;
+ padding: 0 0.42rem;
+ border-radius: 0.2rem;
+ line-height: 1.32;
+ overflow-wrap: anywhere;
+ font-family: inherit;
+ font-size: $font-size-3xs;
+ background: transparent;
+}
+
+.search-result-match mark {
+ padding: 0 0.22rem;
+ border-radius: 0.14rem;
+}
diff --git a/frontend/src/styles/components/_theme_dark.scss b/frontend/src/styles/components/_theme_dark.scss
index e8c29afd..1598bd59 100755
--- a/frontend/src/styles/components/_theme_dark.scss
+++ b/frontend/src/styles/components/_theme_dark.scss
@@ -386,7 +386,49 @@
}
&:nth-of-type(even) {
- background-color: lighten($sidebar-dark-apps-menu-title-bg, 4%);
+ background-color: lighten($sidebar-dark-apps-menu-title-bg, 8%);
+ }
+ }
+ .search-results-list {
+ .search-result-item {
+ background-color: $sidebar-dark-icons-menu-bg;
+ border-color: lighten($sidebar-dark-icons-menu-border-color, 8%);
+ }
+
+ .search-result-item.app-div-striped:nth-of-type(odd) {
+ background-color: darken($sidebar-dark-icons-menu-bg, 2%);
+ }
+
+ .search-result-item.app-div-striped:nth-of-type(even) {
+ background-color: $dark-surface-bg;
+ }
+
+ .search-result-item:hover,
+ .search-result-item.app-div-striped:hover {
+ background-color: $sidebar-dark-apps-menu-title-bg;
+ border-color: $primary;
+ }
+
+ .search-result-item.selected {
+ background-color: $dark-tree-node-selected-bg !important;
+ border-color: $primary;
+ }
+
+ .search-result-name {
+ color: $gray-lightest;
+ }
+
+ .search-result-matches {
+ border-top-color: $dark-control-sidebar-separator-color;
+ }
+
+ .search-result-match {
+ color: $dark-item-hover-color;
+ }
+
+ .search-result-match mark {
+ color: $white;
+ background: $success;
}
}
.app-thumbs {
@@ -606,7 +648,7 @@
.form-control, .form-select, .input-group-text {
background-color: $sidebar-dark-apps-menu-title-bg;
color: $white;
- border-color: $dark-field-border;
+ border-color: $dark-surface-border;
&:focus {
border-color: $primary;
diff --git a/frontend/src/styles/components/_theme_light.scss b/frontend/src/styles/components/_theme_light.scss
index d622b11c..4de4aed8 100755
--- a/frontend/src/styles/components/_theme_light.scss
+++ b/frontend/src/styles/components/_theme_light.scss
@@ -444,13 +444,55 @@
}
.app-div-striped {
&:nth-of-type(even) {
- background-color: lighten($gray-lighter, 2%);
+ background-color: $light-table-row-hover-bg;
}
&.selected {
background-color: $light-row-selected-bg !important;
}
}
+ .search-results-list {
+ .search-result-item {
+ background-color: $white;
+ border-color: $gray-light;
+ }
+
+ .search-result-item.app-div-striped:nth-of-type(odd) {
+ background-color: $white;
+ }
+
+ .search-result-item.app-div-striped:nth-of-type(even) {
+ background-color: lighten($light-table-row-hover-bg, 2%);
+ }
+
+ .search-result-item:hover,
+ .search-result-item.app-div-striped:hover {
+ background-color: lighten($light-table-row-hover-bg, 2%);
+ border-color: $light-surface-border;
+ }
+
+ .search-result-item.selected {
+ background-color: $light-row-selected-bg !important;
+ border-color: $primary;
+ }
+
+ .search-result-name {
+ color: $custom-dark-color;
+ }
+
+ .search-result-matches {
+ border-top-color: $gray-mid;
+ }
+
+ .search-result-match {
+ color: $custom-dark-color;
+ }
+
+ .search-result-match mark {
+ color: $custom-dark-color;
+ background: $light-green;
+ }
+ }
.list-group-item {
background-color: lighten($gray-light, 10%);
color: $custom-color;
diff --git a/frontend/src/styles/components/index.scss b/frontend/src/styles/components/index.scss
index 5f37abf9..46779694 100644
--- a/frontend/src/styles/components/index.scss
+++ b/frontend/src/styles/components/index.scss
@@ -18,6 +18,7 @@
@import 'profile';
@import 'products';
@import 'recents';
+@import 'search';
@import 'tasks';
@import 'circles';
@import 'miscellaneous';