diff --git a/src/lib/sidebar/searchbox/SearchList.svelte b/src/lib/sidebar/searchbox/SearchList.svelte index 00d92b4..b503e25 100644 --- a/src/lib/sidebar/searchbox/SearchList.svelte +++ b/src/lib/sidebar/searchbox/SearchList.svelte @@ -12,6 +12,7 @@ let fzf: [string | null, Fzf][]; export let featureGroup: FeatureGroupList[] | undefined = $allFeatures; + export let selectedGroup: string; export let showSearch = false; export let set: | ((v: SimpleHS) => void) @@ -22,7 +23,7 @@ const dispatch = createEventDispatcher(); let cl = - 'bg-neutral-800/95 backdrop-blur-lg absolute top-12 z-40 flex w-full flex-col gap-y-1 rounded-lg px-2 pt-2 pb-4 shadow-lg shadow-neutral-600/50'; + 'bg-neutral-800/95 backdrop-blur-lg absolute top-12 z-40 flex w-[90%] flex-col gap-y-1 rounded-lg px-2 pt-2 mt-4 pb-2 shadow-lg shadow-neutral-600/50 border border-neutral-200/30'; export { cl as class }; let candidates: { @@ -36,19 +37,21 @@ } $: if (featureGroup) { - fzf = featureGroup.map((f) => { - const config: ConstructorParameters[1] = { - limit: 100, - casing: 'case-insensitive' - }; - if (f.weights) { - config.tiebreakers = [ - (a: FzfResultItem, b: FzfResultItem) => - f.weights![f.names[a.item] - f.weights![f.names[b.item]]] - ]; - } - return [f.group, new Fzf(f.features, config)]; - }); + fzf = featureGroup + .filter((f) => f.group === selectedGroup) + .map((f) => { + const config: ConstructorParameters[1] = { + limit: 100, + casing: 'case-insensitive' + }; + if (f.weights) { + config.tiebreakers = [ + (a: FzfResultItem, b: FzfResultItem) => + f.weights![f.names[a.item] - f.weights![f.names[b.item]]] + ]; + } + return [f.group, new Fzf(f.features, config)]; + }); } $: if (fzf) { @@ -90,9 +93,9 @@ {#each candidates as { group, values }, i} {#if values.length > 0 && (limit < 0 || i < limit)}
- + {#each values as v} + import { + Listbox, + ListboxButton, + ListboxOption, + ListboxOptions + } from '@rgossiaux/svelte-headlessui'; import { oneLRU } from '../../lru'; - import { hoverSelect, overlaysFeature, setHoverSelect, sOverlay } from '../../store'; + import { hoverSelect, overlaysFeature, sOverlay, setHoverSelect } from '../../store'; import type { FeatureGroupList } from '../searchBox'; import SearchList from './SearchList.svelte'; + import { ChevronDown } from '@steeze-ui/heroicons'; + import { Icon } from '@steeze-ui/svelte-icon'; + export let featureGroup: FeatureGroupList[] | undefined; export let displaySelection = false; // Start with empty search box. @@ -21,9 +30,51 @@ sOverlay.subscribe((ov) => { if (ov) search = $overlaysFeature[ov]?.feature ?? ''; }); + + let groups: string[] | undefined = []; + let selectedGroup = groups[0]; + $: { + groups = featureGroup?.map((f) => f.group ?? 'Misc.'); + if (!selectedGroup && groups && groups.length) selectedGroup = groups[0]; + } -
+
+ {#if featureGroup && featureGroup.length > 1} + + + + {selectedGroup} + + + + + + +
+ +
+ {#each groups as group} + + {group} + + {/each} +
+
+
+
+ {/if} + (showSearch = true)} placeholder={noFeature ? 'No feature' : 'Search features'} disabled={noFeature} /> - +