71 lines
2.0 KiB
Svelte
71 lines
2.0 KiB
Svelte
<script lang="ts">
|
|
import { getContext, createEventDispatcher } from 'svelte';
|
|
const dispatch = createEventDispatcher();
|
|
|
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
|
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
|
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
import Download from '$lib/components/icons/Download.svelte';
|
|
import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
|
|
|
|
const i18n = getContext('i18n');
|
|
|
|
export let onExport: null | Function = null;
|
|
export let onClose: Function = () => {};
|
|
|
|
let show = false;
|
|
</script>
|
|
|
|
<Dropdown
|
|
bind:show
|
|
align="end"
|
|
onOpenChange={(state) => {
|
|
if (state === false) {
|
|
onClose();
|
|
}
|
|
}}
|
|
>
|
|
<Tooltip content={$i18n.t('More')}>
|
|
<slot
|
|
><button
|
|
class="self-center w-fit text-sm p-1.5 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
|
type="button"
|
|
aria-label={$i18n.t('More Options')}
|
|
on:click={(e) => {
|
|
e.stopPropagation();
|
|
show = true;
|
|
}}
|
|
>
|
|
<EllipsisHorizontal className="size-5" />
|
|
</button>
|
|
</slot>
|
|
</Tooltip>
|
|
|
|
<div slot="content">
|
|
<DropdownMenu className="min-w-[170px]">
|
|
{#if onExport}
|
|
<button
|
|
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[13px] hover:text-gray-900 dark:hover:text-gray-100"
|
|
on:click={() => {
|
|
onExport();
|
|
}}
|
|
>
|
|
<Download className="size-3.5" />
|
|
<div class="flex items-center">{$i18n.t('Export')}</div>
|
|
</button>
|
|
{/if}
|
|
|
|
<button
|
|
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[13px] hover:text-gray-900 dark:hover:text-gray-100"
|
|
on:click={() => {
|
|
dispatch('delete');
|
|
}}
|
|
>
|
|
<GarbageBin className="size-3.5" />
|
|
<div class="flex items-center">{$i18n.t('Delete')}</div>
|
|
</button>
|
|
</DropdownMenu>
|
|
</div>
|
|
</Dropdown>
|