2024-06-18 03:52:38 +00:00
|
|
|
<script lang="ts">
|
2024-03-21 19:39:33 +01:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2024-06-18 03:52:38 +00:00
|
|
|
import { generateId } from '$lib/utils/generate-id';
|
|
|
|
|
import { optionClickCallbackStore, selectedIdStore } from '$lib/stores/context-menu.store';
|
2024-03-21 19:39:33 +01:00
|
|
|
|
2024-06-20 21:15:36 +00:00
|
|
|
export let text: string;
|
2023-09-23 11:50:21 +07:00
|
|
|
export let subtitle = '';
|
2024-03-21 19:39:33 +01:00
|
|
|
export let icon = '';
|
2024-06-20 21:15:36 +00:00
|
|
|
export let activeColor = 'bg-slate-300';
|
|
|
|
|
export let textColor = 'text-immich-fg dark:text-immich-dark-bg';
|
|
|
|
|
export let onClick: () => void;
|
2024-06-18 03:52:38 +00:00
|
|
|
|
|
|
|
|
let id: string = generateId();
|
|
|
|
|
|
|
|
|
|
$: isActive = $selectedIdStore === id;
|
|
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
$optionClickCallbackStore?.();
|
2024-06-20 21:15:36 +00:00
|
|
|
onClick();
|
2024-06-18 03:52:38 +00:00
|
|
|
};
|
2022-07-23 13:08:49 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-06-18 03:52:38 +00:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
|
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
|
|
|
|
<li
|
|
|
|
|
{id}
|
|
|
|
|
on:click={handleClick}
|
|
|
|
|
on:mouseover={() => ($selectedIdStore = id)}
|
|
|
|
|
on:mouseleave={() => ($selectedIdStore = undefined)}
|
2024-06-20 21:15:36 +00:00
|
|
|
class="w-full p-4 text-left text-sm font-medium {textColor} focus:outline-none focus:ring-2 focus:ring-inset cursor-pointer border-gray-200 flex gap-2 items-center {isActive
|
|
|
|
|
? activeColor
|
|
|
|
|
: 'bg-slate-100'}"
|
2023-07-01 00:50:47 -04:00
|
|
|
role="menuitem"
|
2022-07-23 13:08:49 -05:00
|
|
|
>
|
2024-06-20 21:15:36 +00:00
|
|
|
{#if icon}
|
|
|
|
|
<Icon path={icon} ariaHidden={true} size="18" />
|
|
|
|
|
{/if}
|
|
|
|
|
<div>
|
|
|
|
|
{text}
|
|
|
|
|
{#if subtitle}
|
|
|
|
|
<p class="text-xs text-gray-500">
|
|
|
|
|
{subtitle}
|
2024-03-21 19:39:33 +01:00
|
|
|
</p>
|
|
|
|
|
{/if}
|
2024-06-20 21:15:36 +00:00
|
|
|
</div>
|
2024-06-18 03:52:38 +00:00
|
|
|
</li>
|