Add interactive ISAC registry filters
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
|
||||
type Item = { value: string; label: string; count: string | number; description: string };
|
||||
let { items, active = '', className = '' }: { items: Item[]; active?: string; className?: string } = $props();
|
||||
|
||||
function href(value: string) {
|
||||
const params = new URLSearchParams(page.url.searchParams);
|
||||
if (value) params.set('filter', value);
|
||||
else params.delete('filter');
|
||||
params.delete('page');
|
||||
const query = params.toString();
|
||||
return `${page.url.pathname}${query ? `?${query}` : ''}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<nav class={`module-kpis kpi-filters ${className}`} aria-label="Registry filters">
|
||||
{#each items as item}
|
||||
<a href={href(item.value)} class:active={active === item.value} aria-current={active === item.value ? 'true' : undefined}>
|
||||
<span>{item.label}</span><strong>{item.count}</strong><small>{item.description}</small>
|
||||
</a>
|
||||
{/each}
|
||||
</nav>
|
||||
Reference in New Issue
Block a user