Skip to content

Commit f5e4a81

Browse files
committed
Adds support for custom filter trigger content
Allows custom content to be displayed within the filter trigger, rather than only the default filter icon. This enables more flexibility in representing different filter states or providing additional visual cues.
1 parent 3915cb3 commit f5e4a81

11 files changed

+98
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,14 +9,19 @@
79
810
type Props = AProps & {
911
changed: (filter: BooleanFilter) => void;
12+
children?: Snippet;
1013
term: string;
1114
value?: boolean;
1215
};
13-
let { changed, class: className, term, value, ...props }: Props = $props();
16+
let { changed, children, class: className, term, value, ...props }: Props = $props();
1417
1518
const title = `Search ${term}:${value}`;
1619
</script>
1720

1821
<A class={cn('cursor-pointer', className)} onclick={() => changed(new BooleanFilter(term, value))} {title} {...props}>
19-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
22+
{#if children}
23+
{@render children()}
24+
{:else}
25+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
26+
{/if}
2027
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,14 +9,19 @@
79
810
type Props = AProps & {
911
changed: (filter: DateFilter) => void;
12+
children?: Snippet;
1013
term: string;
1114
value?: Date | string;
1215
};
13-
let { changed, class: className, term, value, ...props }: Props = $props();
16+
let { changed, children, class: className, term, value, ...props }: Props = $props();
1417
1518
const title = `Search ${term}:${value}`;
1619
</script>
1720

1821
<A class={cn('cursor-pointer', className)} onclick={() => changed(new DateFilter(term, value))} {title} {...props}>
19-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
22+
{#if children}
23+
{@render children()}
24+
{:else}
25+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
26+
{/if}
2027
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,13 +9,18 @@
79
810
type Props = AProps & {
911
changed: (filter: LevelFilter) => void;
12+
children?: Snippet;
1013
value: string[];
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
1417
const title = `Search level:${value}`;
1518
</script>
1619

1720
<A class={cn('cursor-pointer', className)} onclick={() => changed(new LevelFilter(value))} {title} {...props}>
18-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
21+
{#if children}
22+
{@render children()}
23+
{:else}
24+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
25+
{/if}
1926
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,14 +9,19 @@
79
810
type Props = AProps & {
911
changed: (filter: NumberFilter) => void;
12+
children?: Snippet;
1013
term: string;
1114
value?: number;
1215
};
13-
let { changed, class: className, term, value, ...props }: Props = $props();
16+
let { changed, children, class: className, term, value, ...props }: Props = $props();
1417
1518
const title = `Search ${term}:${value}`;
1619
</script>
1720

1821
<A class={cn('cursor-pointer', className)} onclick={() => changed(new NumberFilter(term, value))} {title} {...props}>
19-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
22+
{#if children}
23+
{@render children()}
24+
{:else}
25+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
26+
{/if}
2027
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,12 +9,17 @@
79
810
type Props = AProps & {
911
changed: (filter: ProjectFilter) => void;
12+
children?: Snippet;
1013
value: string[];
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
const title = `Search project:${value}`;
1417
</script>
1518

1619
<A class={cn('cursor-pointer', className)} onclick={() => changed(new ProjectFilter(value))} {title} {...props}>
17-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
20+
{#if children}
21+
{@render children()}
22+
{:else}
23+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
24+
{/if}
1825
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,13 +9,18 @@
79
810
type Props = AProps & {
911
changed: (filter: ReferenceFilter) => void;
12+
children?: Snippet;
1013
value: string;
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
1417
const title = `Search reference:${value}`;
1518
</script>
1619

1720
<A class={cn('cursor-pointer', className)} onclick={() => changed(new ReferenceFilter(value))} {title} {...props}>
18-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
21+
{#if children}
22+
{@render children()}
23+
{:else}
24+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
25+
{/if}
1926
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,13 +9,18 @@
79
810
type Props = AProps & {
911
changed: (filter: SessionFilter) => void;
12+
children?: Snippet;
1013
value: string;
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
1417
const title = `Search ref.session:${value}`;
1518
</script>
1619

1720
<A class={cn('cursor-pointer', className)} onclick={() => changed(new SessionFilter(value))} {title} {...props}>
18-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
21+
{#if children}
22+
{@render children()}
23+
{:else}
24+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
25+
{/if}
1926
</A>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import type { StackStatus } from '$features/stacks/models';
3+
import type { Snippet } from 'svelte';
34
45
import { A, type AProps } from '$comp/typography';
56
import { cn } from '$lib/utils';
@@ -9,13 +10,18 @@
910
1011
type Props = AProps & {
1112
changed: (filter: StatusFilter) => void;
13+
children?: Snippet;
1214
value: StackStatus[];
1315
};
14-
let { changed, class: className, value, ...props }: Props = $props();
16+
let { changed, children, class: className, value, ...props }: Props = $props();
1517
1618
const title = `Search status:${value}`;
1719
</script>
1820

1921
<A class={cn('cursor-pointer', className)} onclick={() => changed(new StatusFilter(value))} {title} {...props}>
20-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
22+
{#if children}
23+
{@render children()}
24+
{:else}
25+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
26+
{/if}
2127
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,13 +9,18 @@
79
810
type Props = AProps & {
911
changed: (filter: TagFilter) => void;
12+
children?: Snippet;
1013
value: string[];
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
1417
const title = `Search tag:${value}`;
1518
</script>
1619

1720
<A class={cn('cursor-pointer', className)} onclick={() => changed(new TagFilter(value))} {title} {...props}>
18-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
21+
{#if children}
22+
{@render children()}
23+
{:else}
24+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
25+
{/if}
1926
</A>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import { A, type AProps } from '$comp/typography';
35
import { cn } from '$lib/utils';
46
import Filter from '@lucide/svelte/icons/filter';
@@ -7,13 +9,18 @@
79
810
type Props = AProps & {
911
changed: (filter: TypeFilter) => void;
12+
children?: Snippet;
1013
value: string[];
1114
};
12-
let { changed, class: className, value, ...props }: Props = $props();
15+
let { changed, children, class: className, value, ...props }: Props = $props();
1316
1417
const title = `Search type:${value}`;
1518
</script>
1619

1720
<A class={cn('cursor-pointer', className)} onclick={() => changed(new TypeFilter(value))} {title} {...props}>
18-
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
21+
{#if children}
22+
{@render children()}
23+
{:else}
24+
<Filter class="text-muted-foreground text-opacity-50 hover:text-primary size-5" />
25+
{/if}
1926
</A>

0 commit comments

Comments
 (0)