kopia lustrzana https://github.com/shoelace-style/shoelace
fuzzy search and icon
rodzic
f6ccd119e8
commit
ca098eb171
|
@ -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 {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Ładowanie…
Reference in New Issue