mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(web): migration svelte 5 syntax (#13883)
This commit is contained in:
parent
9203a61709
commit
0b3742cf13
310 changed files with 6435 additions and 4176 deletions
|
|
@ -4,12 +4,16 @@
|
|||
import { mdiArrowUpLeft, mdiChevronRight } from '@mdi/js';
|
||||
import { t } from 'svelte-i18n';
|
||||
|
||||
export let pathSegments: string[] = [];
|
||||
export let getLink: (path: string) => string;
|
||||
export let title: string;
|
||||
export let icon: string;
|
||||
interface Props {
|
||||
pathSegments?: string[];
|
||||
getLink: (path: string) => string;
|
||||
title: string;
|
||||
icon: string;
|
||||
}
|
||||
|
||||
$: isRoot = pathSegments.length === 0;
|
||||
let { pathSegments = [], getLink, title, icon }: Props = $props();
|
||||
|
||||
let isRoot = $derived(pathSegments.length === 0);
|
||||
</script>
|
||||
|
||||
<nav class="flex items-center py-2">
|
||||
|
|
@ -21,6 +25,7 @@
|
|||
href={getLink(pathSegments.slice(0, -1).join('/'))}
|
||||
class="mr-2"
|
||||
padding="2"
|
||||
onclick={() => {}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
@ -37,6 +42,7 @@
|
|||
size="1.25em"
|
||||
padding="2"
|
||||
aria-current={isRoot ? 'page' : undefined}
|
||||
onclick={() => {}}
|
||||
/>
|
||||
</li>
|
||||
{#each pathSegments as segment, index}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
<script lang="ts">
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
|
||||
export let items: string[] = [];
|
||||
export let icon: string;
|
||||
export let onClick: (path: string) => void;
|
||||
interface Props {
|
||||
items?: string[];
|
||||
icon: string;
|
||||
onClick: (path: string) => void;
|
||||
}
|
||||
|
||||
let { items = [], icon, onClick }: Props = $props();
|
||||
</script>
|
||||
|
||||
{#if items.length > 0}
|
||||
|
|
@ -13,7 +17,7 @@
|
|||
{#each items as item}
|
||||
<button
|
||||
class="flex flex-col place-items-center gap-2 py-2 px-4 hover:bg-immich-primary/10 dark:hover:bg-immich-primary/40 rounded-xl"
|
||||
on:click={() => onClick(item)}
|
||||
onclick={() => onClick(item)}
|
||||
title={item}
|
||||
type="button"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -2,12 +2,16 @@
|
|||
import Tree from '$lib/components/shared-components/tree/tree.svelte';
|
||||
import { normalizeTreePath, type RecursiveObject } from '$lib/utils/tree-utils';
|
||||
|
||||
export let items: RecursiveObject;
|
||||
export let parent = '';
|
||||
export let active = '';
|
||||
export let icons: { default: string; active: string };
|
||||
export let getLink: (path: string) => string;
|
||||
export let getColor: (path: string) => string | undefined = () => undefined;
|
||||
interface Props {
|
||||
items: RecursiveObject;
|
||||
parent?: string;
|
||||
active?: string;
|
||||
icons: { default: string; active: string };
|
||||
getLink: (path: string) => string;
|
||||
getColor?: (path: string) => string | undefined;
|
||||
}
|
||||
|
||||
let { items, parent = '', active = '', icons, getLink, getColor = () => undefined }: Props = $props();
|
||||
</script>
|
||||
|
||||
<ul class="list-none ml-2">
|
||||
|
|
|
|||
|
|
@ -4,19 +4,31 @@
|
|||
import { normalizeTreePath, type RecursiveObject } from '$lib/utils/tree-utils';
|
||||
import { mdiChevronDown, mdiChevronRight } from '@mdi/js';
|
||||
|
||||
export let tree: RecursiveObject;
|
||||
export let parent: string;
|
||||
export let value: string;
|
||||
export let active = '';
|
||||
export let icons: { default: string; active: string };
|
||||
export let getLink: (path: string) => string;
|
||||
export let getColor: (path: string) => string | undefined;
|
||||
interface Props {
|
||||
tree: RecursiveObject;
|
||||
parent: string;
|
||||
value: string;
|
||||
active?: string;
|
||||
icons: { default: string; active: string };
|
||||
getLink: (path: string) => string;
|
||||
getColor: (path: string) => string | undefined;
|
||||
}
|
||||
|
||||
$: path = normalizeTreePath(`${parent}/${value}`);
|
||||
$: isActive = active === path || active.startsWith(`${path}/`);
|
||||
$: isOpen = isActive;
|
||||
$: isTarget = active === path;
|
||||
$: color = getColor(path);
|
||||
let { tree, parent, value, active = '', icons, getLink, getColor }: Props = $props();
|
||||
|
||||
let path = $derived(normalizeTreePath(`${parent}/${value}`));
|
||||
let isActive = $derived(active === path || active.startsWith(`${path}/`));
|
||||
let isOpen = $state(false);
|
||||
$effect(() => {
|
||||
isOpen = isActive;
|
||||
});
|
||||
let isTarget = $derived(active === path);
|
||||
let color = $derived(getColor(path));
|
||||
|
||||
const onclick = (event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
isOpen = !isOpen;
|
||||
};
|
||||
</script>
|
||||
|
||||
<a
|
||||
|
|
@ -24,11 +36,7 @@
|
|||
title={value}
|
||||
class={`flex flex-grow place-items-center pl-2 py-1 text-sm rounded-lg hover:bg-slate-200 dark:hover:bg-slate-800 hover:font-semibold ${isTarget ? 'bg-slate-100 dark:bg-slate-700 font-semibold text-immich-primary dark:text-immich-dark-primary' : 'dark:text-gray-200'}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
on:click|preventDefault={() => (isOpen = !isOpen)}
|
||||
class={Object.values(tree).length === 0 ? 'invisible' : ''}
|
||||
>
|
||||
<button type="button" {onclick} class={Object.values(tree).length === 0 ? 'invisible' : ''}>
|
||||
<Icon path={isOpen ? mdiChevronDown : mdiChevronRight} class="text-gray-400" size={20} />
|
||||
</button>
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue