fix: do not toggle collapsible if you click on a citation

This commit is contained in:
Jannik Streidl
2024-10-07 21:22:36 +02:00
parent 209948af6f
commit 73c291193b
2 changed files with 19 additions and 13 deletions
+16 -10
View File
@@ -8,32 +8,38 @@
export let open = false;
export let className = '';
export let title = null;
function handleClick(event) {
if (!event.target.closest('.no-toggle')) {
open = !open;
}
}
</script>
<div class={className}>
{#if title !== null}
<button class="w-full" on:click={() => (open = !open)}>
<div class=" w-full font-medium transition flex items-center justify-between gap-2">
<button class="w-full" on:click={handleClick}>
<div class="w-full font-medium transition flex items-center justify-between gap-2">
<div>
{title}
</div>
<div>
{#if open}
<ChevronUp strokeWidth="3.5" className="size-3.5 " />
<ChevronUp strokeWidth="3.5" className="size-3.5" />
{:else}
<ChevronDown strokeWidth="3.5" className="size-3.5 " />
<ChevronDown strokeWidth="3.5" className="size-3.5" />
{/if}
</div>
</div>
</button>
{:else}
<button on:click={() => (open = !open)}>
<div
class="flex items-center gap-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition"
>
<slot />
</div>
<button
type="button"
on:click={handleClick}
class="flex w-full items-center gap-2 text-left text-gray-500 transition hover:text-gray-700 dark:hover:text-gray-300"
>
<slot />
</button>
{/if}