Skip to content

Commit 03347d6

Browse files
authored
Use derived state and not store for isActive (#2802)
1 parent 31b3298 commit 03347d6

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/lib/holocene/pill-container/pill.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import type { HTMLButtonAttributes } from 'svelte/elements';
3-
import { derived } from 'svelte/store'; // ✅ ADD THIS
43
54
import { getContext, type Snippet } from 'svelte';
65
import { twMerge as merge } from 'tailwind-merge';
@@ -41,9 +40,7 @@
4140
4241
registerPill(id, disabled);
4342
44-
const isActive = derived(activePill, ($activePill) =>
45-
isNull(active) ? $activePill === id : active,
46-
);
43+
let isActive = $derived(isNull(active) ? $activePill === id : active);
4744
4845
const handleClick = () => {
4946
if (disabled) return;
@@ -60,7 +57,7 @@
6057
class={merge(
6158
'surface-subtle flex items-center justify-center gap-2 rounded-full px-3 py-1 text-sm',
6259
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/70',
63-
$isActive ? 'bg-interactive text-white' : '',
60+
isActive && 'bg-interactive text-white',
6461
className,
6562
)}
6663
{disabled}

0 commit comments

Comments
 (0)