Files
immich/web/src/lib/components/shared-components/context-menu/context-menu.svelte
Daniel Dietzler a17390a422
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker / pre-job (push) Waiting to run
Docker / Re-Tag ML () (push) Blocked by required conditions
Docker / Re-Tag ML (-armnn) (push) Blocked by required conditions
Docker / Re-Tag ML (-cuda) (push) Blocked by required conditions
Docker / Re-Tag ML (-openvino) (push) Blocked by required conditions
Docker / Re-Tag ML (-rknn) (push) Blocked by required conditions
Docker / Re-Tag ML (-rocm) (push) Blocked by required conditions
Docker / Re-Tag Server () (push) Blocked by required conditions
Docker / Build and Push ML (armnn, linux/arm64, ubuntu-24.04-arm, -armnn) (push) Blocked by required conditions
Docker / Build and Push ML (cpu, linux/amd64, ubuntu-latest) (push) Blocked by required conditions
Docker / Build and Push ML (cpu, linux/arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
Docker / Build and Push ML (cuda, linux/amd64, ubuntu-latest, -cuda) (push) Blocked by required conditions
Docker / Build and Push ML (openvino, linux/amd64, ubuntu-latest, -openvino) (push) Blocked by required conditions
Docker / Build and Push ML (rknn, linux/arm64, ubuntu-24.04-arm, -rknn) (push) Blocked by required conditions
Docker / Build and Push ML (rocm, linux/amd64, mich, -rocm) (push) Blocked by required conditions
Docker / Merge & Push ML (armnn, -armnn) (push) Blocked by required conditions
Docker / Merge & Push ML (cpu) (push) Blocked by required conditions
Docker / Merge & Push ML (cuda, -cuda) (push) Blocked by required conditions
Docker / Merge & Push ML (openvino, -openvino) (push) Blocked by required conditions
Docker / Merge & Push ML (rknn, -rknn) (push) Blocked by required conditions
Docker / Merge & Push ML (rocm, -rocm) (push) Blocked by required conditions
Docker / Build and Push Server (linux/amd64, ubuntu-latest) (push) Blocked by required conditions
Docker / Build and Push Server (linux/arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
Docker / Merge & Push Server (push) Blocked by required conditions
Docker / Docker Build & Push Server Success (push) Blocked by required conditions
Docker / Docker Build & Push ML Success (push) Blocked by required conditions
Docs build / pre-job (push) Waiting to run
Docs build / Docs Build (push) Blocked by required conditions
Static Code Analysis / pre-job (push) Waiting to run
Static Code Analysis / Run Dart Code Analysis (push) Blocked by required conditions
Static Code Analysis / zizmor (push) Waiting to run
Test / pre-job (push) Waiting to run
Test / Test & Lint Server (push) Blocked by required conditions
Test / Unit Test CLI (push) Blocked by required conditions
Test / Unit Test CLI (Windows) (push) Blocked by required conditions
Test / Lint Web (push) Blocked by required conditions
Test / Test Web (push) Blocked by required conditions
Test / End-to-End Lint (push) Blocked by required conditions
Test / Medium Tests (Server) (push) Blocked by required conditions
Test / End-to-End Tests (Server & CLI) (push) Blocked by required conditions
Test / End-to-End Tests (Web) (push) Blocked by required conditions
Test / Unit Test Mobile (push) Blocked by required conditions
Test / Unit Test ML (push) Blocked by required conditions
Test / .github Files Formatting (push) Blocked by required conditions
Test / ShellCheck (push) Waiting to run
Test / OpenAPI Clients (push) Waiting to run
Test / TypeORM Checks (push) Waiting to run
refactor: move managers to new folder (#17929)
2025-04-28 16:56:04 +02:00

83 lines
2.4 KiB
Svelte

<script lang="ts">
import { clickOutside } from '$lib/actions/click-outside';
import { languageManager } from '$lib/managers/language-manager.svelte';
import type { Snippet } from 'svelte';
import { quintOut } from 'svelte/easing';
import { slide } from 'svelte/transition';
interface Props {
isVisible?: boolean;
direction?: 'left' | 'right';
x?: number;
y?: number;
id?: string | undefined;
ariaLabel?: string | undefined;
ariaLabelledBy?: string | undefined;
ariaActiveDescendant?: string | undefined;
menuElement?: HTMLUListElement | undefined;
onClose?: (() => void) | undefined;
children?: Snippet;
}
let {
isVisible = false,
direction = 'right',
x = 0,
y = 0,
id = undefined,
ariaLabel = undefined,
ariaLabelledBy = undefined,
ariaActiveDescendant = undefined,
menuElement = $bindable(),
onClose = undefined,
children,
}: Props = $props();
let left: number = $state(0);
let top: number = $state(0);
// We need to bind clientHeight since the bounding box may return a height
// of zero when starting the 'slide' animation.
let height: number = $state(0);
$effect(() => {
if (menuElement) {
let layoutDirection = direction;
if (languageManager.rtl) {
layoutDirection = direction === 'left' ? 'right' : 'left';
}
const rect = menuElement.getBoundingClientRect();
const directionWidth = layoutDirection === 'left' ? rect.width : 0;
const menuHeight = Math.min(menuElement.clientHeight, height) || 0;
left = Math.max(8, Math.min(window.innerWidth - rect.width, x - directionWidth));
top = Math.max(8, Math.min(window.innerHeight - menuHeight, y));
}
});
</script>
<div
bind:clientHeight={height}
class="fixed z-10 min-w-[200px] w-max max-w-[300px] overflow-hidden rounded-lg shadow-lg"
style:left="{left}px"
style:top="{top}px"
transition:slide={{ duration: 250, easing: quintOut }}
use:clickOutside={{ onOutclick: onClose }}
>
<ul
{id}
aria-activedescendant={ariaActiveDescendant ?? ''}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
bind:this={menuElement}
class="{isVisible
? 'max-h-dvh'
: 'max-h-0'} flex flex-col transition-all duration-[250ms] ease-in-out outline-none overflow-auto"
role="menu"
tabindex="-1"
>
{@render children?.()}
</ul>
</div>