2022-05-21 02:23:55 -05:00
|
|
|
<script lang="ts">
|
2023-10-25 09:48:25 -04:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2024-03-12 14:11:16 +01:00
|
|
|
import { resolveRoute } from '$app/paths';
|
|
|
|
|
import { page } from '$app/stores';
|
2023-02-10 23:17:39 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
title: string;
|
|
|
|
|
routeId: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
flippedLogo?: boolean;
|
|
|
|
|
isSelected?: boolean;
|
|
|
|
|
preloadData?: boolean;
|
|
|
|
|
}
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let {
|
|
|
|
|
title,
|
|
|
|
|
routeId,
|
|
|
|
|
icon,
|
|
|
|
|
flippedLogo = false,
|
|
|
|
|
isSelected = $bindable(false),
|
|
|
|
|
preloadData = true,
|
|
|
|
|
}: Props = $props();
|
|
|
|
|
|
|
|
|
|
let routePath = $derived(resolveRoute(routeId, {}));
|
|
|
|
|
|
|
|
|
|
$effect(() => {
|
|
|
|
|
isSelected = ($page.route.id?.match(/^\/(admin|\(user\))\/[^/]*/) || [])[0] === routeId;
|
|
|
|
|
});
|
2022-05-21 02:23:55 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-12 14:11:16 +01:00
|
|
|
<a
|
|
|
|
|
href={routePath}
|
|
|
|
|
data-sveltekit-preload-data={preloadData ? 'hover' : 'off'}
|
|
|
|
|
draggable="false"
|
|
|
|
|
aria-current={isSelected ? 'page' : undefined}
|
2024-11-26 08:59:47 -06:00
|
|
|
class="flex w-full place-items-center gap-4 rounded-r-full py-3 transition-[padding] delay-100 duration-100 hover:cursor-pointer hover:bg-immich-gray hover:text-immich-primary dark:text-immich-dark-fg dark:hover:bg-immich-dark-gray dark:hover:text-immich-dark-primary
|
2023-04-15 03:41:52 +02:00
|
|
|
{isSelected
|
2024-04-25 13:42:09 -06:00
|
|
|
? 'bg-immich-primary/10 text-immich-primary hover:bg-immich-primary/10 dark:bg-immich-dark-primary/10 dark:text-immich-dark-primary'
|
2023-07-01 00:50:47 -04:00
|
|
|
: ''}
|
2023-04-17 18:18:49 +02:00
|
|
|
pl-5 group-hover:sm:px-5 md:px-5
|
2023-04-15 03:41:52 +02:00
|
|
|
"
|
2022-05-21 02:23:55 -05:00
|
|
|
>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex w-full place-items-center gap-4 overflow-hidden truncate">
|
2024-03-12 14:11:16 +01:00
|
|
|
<Icon path={icon} size="1.5em" class="shrink-0" flipped={flippedLogo} ariaHidden />
|
|
|
|
|
<span class="text-sm font-medium">{title}</span>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2024-11-26 08:59:47 -06:00
|
|
|
<div></div>
|
2024-03-12 14:11:16 +01:00
|
|
|
</a>
|