2022-06-03 11:04:30 -05:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
|
|
|
|
import CloudDownloadOutline from 'svelte-material-icons/CloudDownloadOutline.svelte';
|
|
|
|
import InformationOutline from 'svelte-material-icons/InformationOutline.svelte';
|
2022-11-04 10:32:09 -04:00
|
|
|
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
|
2022-10-30 17:08:22 +01:00
|
|
|
import DeleteOutline from 'svelte-material-icons/DeleteOutline.svelte';
|
2022-07-16 23:52:00 -05:00
|
|
|
import CircleIconButton from '../shared-components/circle-icon-button.svelte';
|
2022-11-04 10:32:09 -04:00
|
|
|
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
|
|
|
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
2022-11-08 11:20:36 -05:00
|
|
|
import Star from 'svelte-material-icons/Star.svelte';
|
|
|
|
import StarOutline from 'svelte-material-icons/StarOutline.svelte';
|
|
|
|
import { page } from '$app/stores';
|
|
|
|
import { AssetResponseDto } from '../../../api';
|
|
|
|
|
|
|
|
export let asset: AssetResponseDto;
|
|
|
|
|
|
|
|
const isOwner = asset.ownerId === $page.data.user.id;
|
2022-11-04 10:32:09 -04:00
|
|
|
|
2022-06-03 11:04:30 -05:00
|
|
|
const dispatch = createEventDispatcher();
|
2022-11-04 10:32:09 -04:00
|
|
|
|
|
|
|
let contextMenuPosition = { x: 0, y: 0 };
|
|
|
|
let isShowAssetOptions = false;
|
|
|
|
|
|
|
|
const showOptionsMenu = (event: CustomEvent) => {
|
|
|
|
contextMenuPosition = {
|
|
|
|
x: event.detail.mouseEvent.x,
|
|
|
|
y: event.detail.mouseEvent.y
|
|
|
|
};
|
|
|
|
|
|
|
|
isShowAssetOptions = !isShowAssetOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
const onMenuClick = (eventName: string) => {
|
|
|
|
isShowAssetOptions = false;
|
|
|
|
dispatch(eventName);
|
|
|
|
};
|
2022-06-03 11:04:30 -05:00
|
|
|
</script>
|
|
|
|
|
2022-07-16 23:52:00 -05:00
|
|
|
<div
|
|
|
|
class="h-16 bg-black/5 flex justify-between place-items-center px-3 transition-transform duration-200 z-[9999]"
|
|
|
|
>
|
2022-06-03 11:04:30 -05:00
|
|
|
<div>
|
|
|
|
<CircleIconButton logo={ArrowLeft} on:click={() => dispatch('goBack')} />
|
|
|
|
</div>
|
|
|
|
<div class="text-white flex gap-2">
|
|
|
|
<CircleIconButton logo={CloudDownloadOutline} on:click={() => dispatch('download')} />
|
2022-10-30 11:08:55 -05:00
|
|
|
<CircleIconButton logo={InformationOutline} on:click={() => dispatch('showDetail')} />
|
2022-11-08 11:20:36 -05:00
|
|
|
{#if isOwner}
|
|
|
|
<CircleIconButton
|
|
|
|
logo={asset.isFavorite ? Star : StarOutline}
|
|
|
|
on:click={() => dispatch('favorite')}
|
|
|
|
title="Favorite"
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
<CircleIconButton logo={DeleteOutline} on:click={() => dispatch('delete')} />
|
2022-11-04 10:32:09 -04:00
|
|
|
<CircleIconButton logo={DotsVertical} on:click={(event) => showOptionsMenu(event)} />
|
2022-06-03 11:04:30 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-04 10:32:09 -04:00
|
|
|
|
|
|
|
{#if isShowAssetOptions}
|
|
|
|
<ContextMenu {...contextMenuPosition} on:clickoutside={() => (isShowAssetOptions = false)}>
|
|
|
|
<div class="flex flex-col rounded-lg ">
|
|
|
|
<MenuOption on:click={() => onMenuClick('addToAlbum')} text="Add to Album" />
|
|
|
|
<MenuOption on:click={() => onMenuClick('addToSharedAlbum')} text="Add to Shared Album" />
|
|
|
|
</div>
|
|
|
|
</ContextMenu>
|
|
|
|
{/if}
|