2024-07-04 13:53:28 +00:00
|
|
|
<script lang="ts">
|
2024-10-15 07:35:14 +00:00
|
|
|
import { getContext, createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
$: dispatch('change', open);
|
|
|
|
|
|
2024-07-06 04:37:29 +00:00
|
|
|
import { slide } from 'svelte/transition';
|
|
|
|
|
import { quintOut } from 'svelte/easing';
|
2024-07-28 22:17:49 +00:00
|
|
|
|
|
|
|
|
import ChevronUp from '../icons/ChevronUp.svelte';
|
|
|
|
|
import ChevronDown from '../icons/ChevronDown.svelte';
|
2025-01-22 08:13:24 +00:00
|
|
|
import Spinner from './Spinner.svelte';
|
2024-07-28 22:17:49 +00:00
|
|
|
|
2024-07-04 13:53:28 +00:00
|
|
|
export let open = false;
|
2024-07-04 14:02:26 +00:00
|
|
|
export let className = '';
|
2024-10-22 04:32:45 +00:00
|
|
|
export let buttonClassName =
|
|
|
|
|
'w-fit text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition';
|
2024-07-28 22:17:49 +00:00
|
|
|
export let title = null;
|
2025-01-22 08:13:24 +00:00
|
|
|
export let isLoading = false;
|
2024-10-07 19:22:36 +00:00
|
|
|
|
2024-10-21 22:24:59 +00:00
|
|
|
export let grow = false;
|
|
|
|
|
|
2024-10-17 07:17:50 +00:00
|
|
|
export let disabled = false;
|
2024-10-17 07:33:53 +00:00
|
|
|
export let hide = false;
|
2024-07-04 13:53:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
2024-07-04 14:02:26 +00:00
|
|
|
<div class={className}>
|
2024-07-28 22:17:49 +00:00
|
|
|
{#if title !== null}
|
2024-10-17 05:36:44 +00:00
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2024-10-17 07:33:53 +00:00
|
|
|
<div
|
2024-10-19 07:41:58 +00:00
|
|
|
class="{buttonClassName} cursor-pointer"
|
2024-10-17 07:33:53 +00:00
|
|
|
on:pointerup={() => {
|
|
|
|
|
if (!disabled) {
|
|
|
|
|
open = !open;
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-01-22 08:13:24 +00:00
|
|
|
<div
|
|
|
|
|
class=" w-full font-medium flex items-center justify-between gap-2 {isLoading === true
|
|
|
|
|
? 'shimmer'
|
|
|
|
|
: ''}
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
{#if isLoading}
|
|
|
|
|
<div>
|
|
|
|
|
<Spinner className="size-4" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-10-22 04:32:45 +00:00
|
|
|
<div class="">
|
2024-07-28 22:17:49 +00:00
|
|
|
{title}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-01-22 08:13:24 +00:00
|
|
|
<div class="flex self-center translate-y-[1px]">
|
2024-07-28 22:17:49 +00:00
|
|
|
{#if open}
|
2024-10-07 19:22:36 +00:00
|
|
|
<ChevronUp strokeWidth="3.5" className="size-3.5" />
|
2024-07-28 22:17:49 +00:00
|
|
|
{:else}
|
2024-10-07 19:22:36 +00:00
|
|
|
<ChevronDown strokeWidth="3.5" className="size-3.5" />
|
2024-07-28 22:17:49 +00:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-10-17 05:36:44 +00:00
|
|
|
</div>
|
2024-07-28 22:17:49 +00:00
|
|
|
{:else}
|
2024-10-17 05:36:44 +00:00
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2024-10-17 07:33:53 +00:00
|
|
|
<div
|
2024-10-19 07:41:58 +00:00
|
|
|
class="{buttonClassName} cursor-pointer"
|
2024-10-17 07:33:53 +00:00
|
|
|
on:pointerup={() => {
|
|
|
|
|
if (!disabled) {
|
|
|
|
|
open = !open;
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-10-07 19:22:36 +00:00
|
|
|
>
|
2024-10-21 10:17:30 +00:00
|
|
|
<div>
|
2024-07-28 22:17:49 +00:00
|
|
|
<slot />
|
2024-10-21 22:24:59 +00:00
|
|
|
|
|
|
|
|
{#if grow}
|
|
|
|
|
{#if open && !hide}
|
|
|
|
|
<div
|
|
|
|
|
transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}
|
|
|
|
|
on:pointerup={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<slot name="content" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
2024-07-28 22:17:49 +00:00
|
|
|
</div>
|
2024-10-17 05:36:44 +00:00
|
|
|
</div>
|
2024-07-28 22:17:49 +00:00
|
|
|
{/if}
|
2024-07-04 14:02:26 +00:00
|
|
|
|
2024-10-21 22:24:59 +00:00
|
|
|
{#if !grow}
|
|
|
|
|
{#if open && !hide}
|
|
|
|
|
<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
|
|
|
|
|
<slot name="content" />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-10-17 20:30:21 +00:00
|
|
|
{/if}
|
2024-07-06 04:37:29 +00:00
|
|
|
</div>
|