Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Added close button to abort search in jina searchbar #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added close button to abort search in jina searchbar
  • Loading branch information
pdaryamane committed Mar 13, 2021
commit cb60ae9fa857784bbe238a81edc7b3dbba99493e
1 change: 1 addition & 0 deletions src/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SearchBar extends SearchComponent{
this.contentContainer = this.getElement('jina-search-expander');
this.searchInput = this.getElement('jina-search-input');
this.searchIcon = this.getElement('jina-search-icon');
this.closeIcon = this.getElement('jina-close-icon');
this.init();
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/SearchComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,12 @@ class JinaBoxSearchComponent extends HTMLElement {
if (this.contentContainer) {
this.contentContainer.addEventListener('drop', this.handleDrop);
}
if (this.searchIcon)
if (this.searchIcon) {
this.searchIcon.addEventListener('click', this.showInputOptions);
}
if (this.closeIcon) {
this.closeIcon.addEventListener('click', this.clearExpander);
}

this.resultsView = localStorage.getItem('jina-results-view') || 'list';

Expand Down Expand Up @@ -969,6 +973,7 @@ class JinaBoxSearchComponent extends HTMLElement {
<div class="jina-search-container">
<img src="${this.defaultSearchIcon}" class="jina-search-icon" onerror="this.src='${this.defaultSearchIcon}'" />
<input placeholder="type or drop to search" class="jina-search-input jina-contained" autocomplete="off">
<img src="${_icons.close}" class="jina-close-icon" onerror="this.src='${_icons.close}'"/>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/SearchBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ describe('SearchBar test', () => {
it('should show search bar with icon and placeholder on input element', function () {
expect(container.querySelector(".jina-search-input").getAttribute("placeholder")).toEqual('type or drop to search');
expect(container.querySelector(".jina-search-icon").getAttribute("src")).toEqual(icons.color);
expect(container.querySelector(".jina-close-icon").getAttribute("src")).toEqual(icons.close);
});
});
6 changes: 6 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
z-index: 1;
}
.jina-search-container {
display: flex;
position: relative;
}
.jina-persian {
Expand Down Expand Up @@ -884,6 +885,11 @@
/* text-align: right; */
}

.jina-close-icon {
height: 30px;
cursor: pointer;
}

.jina-jumping-dots {
position:relative;
text-align:center;
Expand Down