Skip to content

Commit

Permalink
re-simplify slots
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed May 22, 2024
1 parent b72a808 commit a22641e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
{/if}
<ul>
{#each limitedItems as item}
<li><slot name="item" {item}><SectionItem {item} {onFilterSelect} /></slot></li>
<li>
<slot name="item" {item}>
<SectionItem {item} {onFilterSelect}>
<slot name="label" slot="label" let:label let:value {label} {value} />
</SectionItem>
</slot>
</li>
{/each}
</ul>
{#if filteredItems.length === 0}
Expand Down
46 changes: 15 additions & 31 deletions client/web-sveltekit/src/lib/search/dynamicFilters/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@

{#if !queryHasTypeFilter(searchQuery)}
<Section items={typeFilters} title="By type" showAll onFilterSelect={handleFilterSelect}>
<svelte:fragment slot="item" let:item>
<SectionItem {item}>
<svelte:fragment slot="label" let:label>
<Icon svgPath={typeFilterIcons[label]} inline aria-hidden="true" />&nbsp;
{label}
</svelte:fragment>
</SectionItem>
<svelte:fragment slot="label" let:label>
<Icon svgPath={typeFilterIcons[label]} inline aria-hidden="true" />&nbsp;
{label}
</svelte:fragment>
</Section>
{/if}
Expand Down Expand Up @@ -154,13 +150,9 @@
filterPlaceholder="Filter languages"
onFilterSelect={handleFilterSelect}
>
<svelte:fragment slot="item" let:item>
<SectionItem {item}>
<svelte:fragment slot="label" let:label>
<LanguageIcon class="icon" language={label} inline />&nbsp;
{label}
</svelte:fragment>
</SectionItem>
<svelte:fragment slot="label" let:label>
<LanguageIcon class="icon" language={label} inline />&nbsp;
{label}
</svelte:fragment>
</Section>
<Section
Expand All @@ -169,15 +161,11 @@
filterPlaceholder="Filter symbol types"
onFilterSelect={handleFilterSelect}
>
<svelte:fragment slot="item" let:item>
<SectionItem {item}>
<svelte:fragment slot="label" let:label>
<div class="symbol-label">
<SymbolKindIcon symbolKind={label.toUpperCase()} />
{label}
</div>
</svelte:fragment>
</SectionItem>
<svelte:fragment slot="label" let:label>
<div class="symbol-label">
<SymbolKindIcon symbolKind={label.toUpperCase()} />
{label}
</div>
</svelte:fragment>
</Section>
<Section
Expand All @@ -187,14 +175,10 @@
onFilterSelect={handleFilterSelect}
/>
<Section items={groupedFilters['commit date']} title="By commit date" onFilterSelect={handleFilterSelect}>
<svelte:fragment slot="item" let:item>
<SectionItem {item}>
<span class="commit-date-label" slot="label" let:label let:value>
{label}
<small><pre>{value}</pre></small>
</span>
</SectionItem>
</svelte:fragment>
<span class="commit-date-label" slot="label" let:label let:value>
{label}
<small><pre>{value}</pre></small>
</span>
</Section>
<Section items={groupedFilters.file} title="By file" showAll onFilterSelect={handleFilterSelect} />
<Section items={groupedFilters.utility} title="Utility" showAll onFilterSelect={handleFilterSelect} />
Expand Down

0 comments on commit a22641e

Please sign in to comment.