fuzzy search and icon

pull/526/head
Cory LaViska 2021-09-08 12:05:28 -04:00
rodzic f6ccd119e8
commit ca098eb171
2 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -153,7 +153,7 @@ body.site-search-visible {
border-top: solid 1px rgb(var(--sl-color-neutral-200)); border-top: solid 1px rgb(var(--sl-color-neutral-200));
border-bottom-left-radius: inherit; border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit; border-bottom-right-radius: inherit;
padding: var(--sl-spacing-small); padding: var(--sl-spacing-x-small);
} }
.site-search__footer small { .site-search__footer small {

Wyświetl plik

@ -59,7 +59,9 @@
placeholder="Search this site" placeholder="Search this site"
size="large" size="large"
clearable clearable
></sl-input> >
<sl-icon slot="prefix" name="search"></sl-icon>
</sl-input>
</header> </header>
<div class="site-search__body"> <div class="site-search__body">
<ul class="site-search__results"></ul> <ul class="site-search__results"></ul>
@ -219,7 +221,7 @@
await searchIndex; await searchIndex;
const hasQuery = query.length > 0; const hasQuery = query.length > 0;
const matches = hasQuery ? searchIndex.search(query) : []; const matches = hasQuery ? searchIndex.search(`${query}~2`) : [];
let hasResults = hasQuery && matches.length > 0; let hasResults = hasQuery && matches.length > 0;
siteSearch.classList.toggle('site-search--has-results', hasQuery && hasResults); siteSearch.classList.toggle('site-search--has-results', hasQuery && hasResults);