mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
refactor: use item component for favorites avatar item
This commit is contained in:
@@ -352,8 +352,7 @@
|
||||
:group="activeRemoteGroup"
|
||||
:selected="selectedFavoriteAvatars.includes(favorite.id)"
|
||||
:edit-mode="avatarEditMode"
|
||||
@toggle-select="toggleAvatarSelection(favorite.id, $event)"
|
||||
@click="showAvatarDialog(favorite.id)" />
|
||||
@toggle-select="toggleAvatarSelection(favorite.id, $event)" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="flex items-center justify-center text-[13px] h-full">
|
||||
@@ -385,8 +384,7 @@
|
||||
:favorite="favorite"
|
||||
:group="activeLocalGroupName"
|
||||
is-local-favorite
|
||||
:edit-mode="avatarEditMode"
|
||||
@click="showAvatarDialog(favorite.id)" />
|
||||
:edit-mode="avatarEditMode" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="flex items-center justify-center text-[13px] h-full">
|
||||
@@ -403,8 +401,7 @@
|
||||
<FavoritesAvatarLocalHistoryItem
|
||||
v-for="favorite in avatarHistory"
|
||||
:key="favorite.id"
|
||||
:favorite="favorite"
|
||||
@click="showAvatarDialog(favorite.id)" />
|
||||
:favorite="favorite" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="flex items-center justify-center text-[13px] h-full">
|
||||
|
||||
@@ -1,161 +1,126 @@
|
||||
<template>
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger as-child>
|
||||
<div :class="cardClasses" @click="$emit('click')">
|
||||
<template v-if="localFavFakeRef">
|
||||
<div class="favorites-search-card__content">
|
||||
<div
|
||||
class="favorites-search-card__avatar"
|
||||
:class="{ 'is-empty': !localFavFakeRef.thumbnailImageUrl }">
|
||||
<img v-if="localFavFakeRef.thumbnailImageUrl" :src="smallThumbnail" loading="lazy" />
|
||||
</div>
|
||||
<div class="favorites-search-card__detail">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="name text-sm">{{ localFavFakeRef.name }}</span>
|
||||
<span class="inline-flex items-center gap-1 text-sm">
|
||||
<TooltipWrapper
|
||||
v-if="favorite.deleted"
|
||||
side="top"
|
||||
:content="t('view.favorite.unavailable_tooltip')">
|
||||
<AlertTriangle class="h-4 w-4" />
|
||||
</TooltipWrapper>
|
||||
<TooltipWrapper
|
||||
v-if="!isLocalFavorite && favorite.ref?.releaseStatus === 'private'"
|
||||
side="top"
|
||||
:content="t('view.favorite.private')">
|
||||
<Lock class="h-4 w-4" />
|
||||
</TooltipWrapper>
|
||||
</span>
|
||||
</div>
|
||||
<span class="text-xs text-muted-foreground">{{ localFavFakeRef.authorName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="favorites-search-card__actions">
|
||||
<template v-if="editMode">
|
||||
<div
|
||||
v-if="!isLocalFavorite"
|
||||
class="flex justify-end w-full favorites-search-card__action--checkbox"
|
||||
@click.stop>
|
||||
<Checkbox v-model="isSelected" />
|
||||
</div>
|
||||
<div class="flex gap-[var(--favorites-card-action-group-gap,8px)] w-full">
|
||||
<div class="flex justify-end w-full flex-1" @click.stop>
|
||||
<FavoritesMoveDropdown
|
||||
:favoriteGroup="favoriteAvatarGroups"
|
||||
:currentFavorite="props.favorite"
|
||||
:currentGroup="group"
|
||||
class="w-full"
|
||||
:is-local-favorite="isLocalFavorite"
|
||||
type="avatar" />
|
||||
</div>
|
||||
<div class="flex justify-end w-full">
|
||||
<TooltipWrapper
|
||||
side="left"
|
||||
:content="
|
||||
isLocalFavorite
|
||||
? t('view.favorite.delete_tooltip')
|
||||
: t('view.favorite.unfavorite_tooltip')
|
||||
">
|
||||
<Button
|
||||
size="icon-sm"
|
||||
variant="outline"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="handlePrimaryDeleteAction">
|
||||
<Trash2 class="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="flex gap-(--favorites-card-action-group-gap,8px) w-full">
|
||||
<div class="flex justify-end w-full" v-if="canSelectAvatar">
|
||||
<TooltipWrapper side="top" :content="t('view.favorite.select_avatar_tooltip')">
|
||||
<Button
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="selectAvatarWithConfirmation(favorite.id)"
|
||||
><Check class="h-4 w-4"
|
||||
/></Button>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
<div class="flex justify-end w-full">
|
||||
<TooltipWrapper
|
||||
v-if="showDangerUnfavorite"
|
||||
side="bottom"
|
||||
:content="t('view.favorite.unfavorite_tooltip')">
|
||||
<Button
|
||||
size="icon-sm"
|
||||
variant="destructive"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="handlePrimaryDeleteAction"
|
||||
><Trash2 class="h-4 w-4"
|
||||
/></Button>
|
||||
</TooltipWrapper>
|
||||
<TooltipWrapper
|
||||
v-else
|
||||
side="bottom"
|
||||
:content="t('view.favorite.edit_favorite_tooltip')">
|
||||
<Button
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="showFavoriteDialog('avatar', favorite.id)"
|
||||
><Star class="h-4 w-4"
|
||||
/></Button>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="favorites-search-card__content">
|
||||
<div class="favorites-search-card__avatar is-empty"></div>
|
||||
<div class="favorites-search-card__detail">
|
||||
<span>{{ favorite.name || favorite.id }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="favorites-search-card__actions">
|
||||
<div class="flex justify-end w-full">
|
||||
<Button
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
@click.stop="handlePrimaryDeleteAction">
|
||||
<Trash2 class="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
@click="selectAvatarWithConfirmation(favorite.id)">
|
||||
{{ t('view.favorite.select_avatar_tooltip') }}
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
<template v-if="localFavFakeRef">
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger as-child>
|
||||
<Item variant="outline" class="cursor-pointer" :style="itemStyle" @click="handleViewDetails">
|
||||
<ItemMedia variant="image">
|
||||
<img
|
||||
v-if="smallThumbnail"
|
||||
:src="smallThumbnail"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"
|
||||
class="object-cover" />
|
||||
<Avatar v-else>
|
||||
<AvatarFallback>{{ avatarFallback }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</ItemMedia>
|
||||
<ItemContent class="min-w-0">
|
||||
<ItemTitle class="truncate max-w-full">
|
||||
{{ localFavFakeRef.name }}
|
||||
<AlertTriangle
|
||||
v-if="showUnavailable"
|
||||
:title="t('view.favorite.unavailable_tooltip')"
|
||||
class="h-4 w-4" />
|
||||
<Lock v-if="isPrivateAvatar" :title="t('view.favorite.private')" class="h-4 w-4" />
|
||||
</ItemTitle>
|
||||
<ItemDescription class="truncate line-clamp-1 text-xs">
|
||||
{{ localFavFakeRef.authorName }}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
<ItemActions v-if="editMode && !isLocalFavorite" @click.stop>
|
||||
<Checkbox v-model="isSelected" />
|
||||
</ItemActions>
|
||||
<ItemActions v-else-if="!editMode">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<Button size="icon-sm" variant="ghost" class="rounded-full" @click.stop>
|
||||
<MoreHorizontal class="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem @click="handleViewDetails">
|
||||
{{ t('common.actions.view_details') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
v-if="canSelectAvatar"
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
@click="selectAvatarWithConfirmation(favorite.id)">
|
||||
{{ t('view.favorite.select_avatar_tooltip') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator v-if="canSelectAvatar" />
|
||||
<DropdownMenuItem @click="showFavoriteDialog('avatar', favorite.id)">
|
||||
{{ t('view.favorite.edit_favorite_tooltip') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem variant="destructive" @click="handleDeleteFavorite">
|
||||
{{ deleteMenuLabel }}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</ItemActions>
|
||||
</Item>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem @click="handleViewDetails">{{ t('common.actions.view_details') }}</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
v-if="canSelectAvatar"
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
@click="selectAvatarWithConfirmation(favorite.id)">
|
||||
{{ t('view.favorite.select_avatar_tooltip') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuSeparator v-if="canSelectAvatar" />
|
||||
<ContextMenuItem @click="showFavoriteDialog('avatar', favorite.id)">
|
||||
{{ t('view.favorite.edit_favorite_tooltip') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem variant="destructive" @click="handleDeleteFavorite">
|
||||
{{ deleteMenuLabel }}
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Item variant="outline" :style="itemStyle">
|
||||
<ItemMedia variant="image" />
|
||||
<ItemContent class="min-w-0">
|
||||
<ItemTitle class="truncate max-w-full">{{ favorite.name || favorite.id }}</ItemTitle>
|
||||
</ItemContent>
|
||||
<ItemActions>
|
||||
<Button class="rounded-full h-6 w-6" size="icon-sm" variant="ghost" @click.stop="handleDeleteFavorite">
|
||||
<Trash2 class="h-4 w-4" />
|
||||
</Button>
|
||||
</ItemActions>
|
||||
</Item>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { AlertTriangle, Check, Lock, Star, Trash2 } from 'lucide-vue-next';
|
||||
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from '@/components/ui/context-menu';
|
||||
import { AlertTriangle, Lock, MoreHorizontal, Trash2 } from 'lucide-vue-next';
|
||||
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuSeparator,
|
||||
ContextMenuTrigger
|
||||
} from '@/components/ui/context-menu';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from '@/components/ui/item';
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useAvatarStore, useFavoriteStore, useUiStore, useUserStore } from '../../../stores';
|
||||
import { removeLocalAvatarFavorite } from '../../../coordinators/favoriteCoordinator';
|
||||
import { favoriteRequest } from '../../../api';
|
||||
|
||||
import FavoritesMoveDropdown from './FavoritesMoveDropdown.vue';
|
||||
import { selectAvatarWithConfirmation, showAvatarDialog } from '../../../coordinators/avatarCoordinator';
|
||||
import { removeLocalAvatarFavorite } from '../../../coordinators/favoriteCoordinator';
|
||||
import { useFavoriteStore, useUserStore } from '../../../stores';
|
||||
|
||||
const props = defineProps({
|
||||
favorite: Object,
|
||||
@@ -164,30 +129,39 @@
|
||||
editMode: { type: Boolean, default: false },
|
||||
selected: { type: Boolean, default: false }
|
||||
});
|
||||
const emit = defineEmits(['click', 'toggle-select']);
|
||||
const emit = defineEmits(['toggle-select']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const { favoriteAvatarGroups } = storeToRefs(useFavoriteStore());
|
||||
const { showFavoriteDialog } = useFavoriteStore();
|
||||
import { selectAvatarWithConfirmation } from '../../../coordinators/avatarCoordinator';
|
||||
const { shiftHeld } = storeToRefs(useUiStore());
|
||||
const { currentUser } = storeToRefs(useUserStore());
|
||||
|
||||
const isSelected = computed({
|
||||
get: () => props.selected,
|
||||
set: (value) => emit('toggle-select', value)
|
||||
});
|
||||
|
||||
const localFavFakeRef = computed(() => (props.isLocalFavorite ? props.favorite : props.favorite?.ref));
|
||||
|
||||
const cardClasses = computed(() => [
|
||||
'favorites-search-card',
|
||||
'favorites-search-card--avatar',
|
||||
{
|
||||
'is-selected': props.selected,
|
||||
'is-edit-mode': props.editMode
|
||||
}
|
||||
]);
|
||||
const displayName = computed(() => localFavFakeRef.value?.name || props.favorite?.name || props.favorite?.id);
|
||||
|
||||
const avatarFallback = computed(() => displayName.value?.charAt(0)?.toUpperCase() || '?');
|
||||
|
||||
const showUnavailable = computed(() => !props.isLocalFavorite && props.favorite?.deleted);
|
||||
|
||||
const isPrivateAvatar = computed(() => !props.isLocalFavorite && props.favorite?.ref?.releaseStatus === 'private');
|
||||
|
||||
const deleteMenuLabel = computed(() =>
|
||||
props.isLocalFavorite ? t('view.favorite.delete_tooltip') : t('view.favorite.unfavorite_tooltip')
|
||||
);
|
||||
|
||||
const itemStyle = computed(() => ({
|
||||
padding: 'var(--favorites-card-padding-y, 8px) var(--favorites-card-padding-x, 10px)',
|
||||
gap: 'var(--favorites-card-content-gap, 10px)',
|
||||
minWidth: 'var(--favorites-card-min-width, 220px)',
|
||||
maxWidth: 'var(--favorites-card-target-width, 220px)',
|
||||
width: '100%',
|
||||
fontSize: 'calc(0.875rem * var(--favorites-card-scale, 1))'
|
||||
}));
|
||||
|
||||
const smallThumbnail = computed(() => {
|
||||
if (!localFavFakeRef.value?.thumbnailImageUrl) {
|
||||
@@ -200,7 +174,7 @@
|
||||
if (typeof props.group === 'string') {
|
||||
return props.group;
|
||||
}
|
||||
return props.group?.name;
|
||||
return props.group?.name ?? props.group?.key;
|
||||
});
|
||||
|
||||
const canSelectAvatar = computed(() => {
|
||||
@@ -213,30 +187,15 @@
|
||||
return props.favorite?.ref?.releaseStatus !== 'private';
|
||||
});
|
||||
|
||||
const showDangerUnfavorite = computed(() => {
|
||||
return shiftHeld.value;
|
||||
});
|
||||
function handleViewDetails() {
|
||||
showAvatarDialog(props.favorite.id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function handlePrimaryDeleteAction() {
|
||||
function handleDeleteFavorite() {
|
||||
if (props.isLocalFavorite) {
|
||||
removeLocalAvatarFavorite(props.favorite.id, favoriteGroupName.value);
|
||||
return;
|
||||
}
|
||||
deleteFavorite(props.favorite.id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objectId
|
||||
*/
|
||||
function deleteFavorite(objectId) {
|
||||
favoriteRequest.deleteFavorite({ objectId });
|
||||
favoriteRequest.deleteFavorite({ objectId: props.favorite.id });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import './favorites-card.css';
|
||||
</style>
|
||||
|
||||
@@ -1,81 +1,94 @@
|
||||
<template>
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger as-child>
|
||||
<div :class="cardClasses" @click="$emit('click')">
|
||||
<div class="favorites-search-card__content">
|
||||
<div class="favorites-search-card__avatar" :class="{ 'is-empty': !favorite.thumbnailImageUrl }">
|
||||
<img v-if="favorite.thumbnailImageUrl" :src="smallThumbnail" loading="lazy" />
|
||||
</div>
|
||||
<div class="favorites-search-card__detail">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="name text-sm">{{ favorite.name }}</span>
|
||||
</div>
|
||||
<span class="text-xs">{{ favorite.authorName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="favorites-search-card__actions">
|
||||
<div class="flex gap-(--favorites-card-action-group-gap,8px) w-full">
|
||||
<div class="flex justify-end w-full">
|
||||
<TooltipWrapper side="top" :content="t('view.favorite.select_avatar_tooltip')">
|
||||
<Button
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="selectAvatarWithConfirmation(favorite.id)">
|
||||
<Check class="h-4 w-4" />
|
||||
></Button
|
||||
>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
<div class="flex justify-end w-full">
|
||||
<TooltipWrapper side="bottom" :content="t('view.favorite.edit_favorite_tooltip')">
|
||||
<Button
|
||||
v-if="favoriteExists"
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="showFavoriteDialog('avatar', favorite.id)">
|
||||
<Star class="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
v-else
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
class="rounded-full text-xs h-6 w-6"
|
||||
@click.stop="showFavoriteDialog('avatar', favorite.id)">
|
||||
<Star class="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipWrapper>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Item variant="outline" class="cursor-pointer" :style="itemStyle" @click="handleViewDetails">
|
||||
<ItemMedia variant="image">
|
||||
<img
|
||||
v-if="smallThumbnail"
|
||||
:src="smallThumbnail"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
fetchpriority="low"
|
||||
class="object-cover" />
|
||||
<Avatar v-else>
|
||||
<AvatarFallback>{{ avatarFallback }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</ItemMedia>
|
||||
<ItemContent class="min-w-0">
|
||||
<ItemTitle class="truncate max-w-full">{{ favorite.name }}</ItemTitle>
|
||||
<ItemDescription class="truncate line-clamp-1 text-xs">
|
||||
{{ favorite.authorName }}
|
||||
</ItemDescription>
|
||||
</ItemContent>
|
||||
<ItemActions>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<Button size="icon-sm" variant="ghost" class="rounded-full" @click.stop>
|
||||
<MoreHorizontal class="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem @click="handleViewDetails">
|
||||
{{ t('common.actions.view_details') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
@click="selectAvatarWithConfirmation(favorite.id)">
|
||||
{{ t('view.favorite.select_avatar_tooltip') }}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem @click="showFavoriteDialog('avatar', favorite.id)">
|
||||
{{ t('view.favorite.edit_favorite_tooltip') }}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</ItemActions>
|
||||
</Item>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem @click="handleViewDetails">{{ t('common.actions.view_details') }}</ContextMenuItem>
|
||||
<ContextMenuItem
|
||||
:disabled="currentUser.currentAvatar === favorite.id"
|
||||
@click="selectAvatarWithConfirmation(favorite.id)">
|
||||
{{ t('view.favorite.select_avatar_tooltip') }}
|
||||
</ContextMenuItem>
|
||||
<ContextMenuSeparator />
|
||||
<ContextMenuItem @click="showFavoriteDialog('avatar', favorite.id)">
|
||||
{{ t('view.favorite.edit_favorite_tooltip') }}
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from '@/components/ui/context-menu';
|
||||
import { Check, Star } from 'lucide-vue-next';
|
||||
import { MoreHorizontal } from 'lucide-vue-next';
|
||||
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuSeparator,
|
||||
ContextMenuTrigger
|
||||
} from '@/components/ui/context-menu';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from '@/components/ui/item';
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useAvatarStore, useFavoriteStore, useUserStore } from '../../../stores';
|
||||
import { useFavoriteStore, useUserStore } from '../../../stores';
|
||||
import { selectAvatarWithConfirmation, showAvatarDialog } from '../../../coordinators/avatarCoordinator';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const { showFavoriteDialog, getCachedFavoritesByObjectId } = useFavoriteStore();
|
||||
import { selectAvatarWithConfirmation } from '../../../coordinators/avatarCoordinator';
|
||||
const { showFavoriteDialog } = useFavoriteStore();
|
||||
const { currentUser } = storeToRefs(useUserStore());
|
||||
|
||||
const props = defineProps({
|
||||
@@ -85,11 +98,16 @@
|
||||
}
|
||||
});
|
||||
|
||||
defineEmits(['click']);
|
||||
const avatarFallback = computed(() => props.favorite.name?.charAt(0)?.toUpperCase() || '?');
|
||||
|
||||
const favoriteExists = computed(() => Boolean(getCachedFavoritesByObjectId(props.favorite.id)));
|
||||
|
||||
const cardClasses = computed(() => ['favorites-search-card', 'favorites-search-card--avatar']);
|
||||
const itemStyle = computed(() => ({
|
||||
padding: 'var(--favorites-card-padding-y, 8px) var(--favorites-card-padding-x, 10px)',
|
||||
gap: 'var(--favorites-card-content-gap, 10px)',
|
||||
minWidth: 'var(--favorites-card-min-width, 220px)',
|
||||
maxWidth: 'var(--favorites-card-target-width, 220px)',
|
||||
width: '100%',
|
||||
fontSize: 'calc(0.875rem * var(--favorites-card-scale, 1))'
|
||||
}));
|
||||
|
||||
const smallThumbnail = computed(() => {
|
||||
if (!props.favorite.thumbnailImageUrl) {
|
||||
@@ -97,8 +115,8 @@
|
||||
}
|
||||
return props.favorite.thumbnailImageUrl.replace('256', '128');
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import './favorites-card.css';
|
||||
</style>
|
||||
function handleViewDetails() {
|
||||
showAvatarDialog(props.favorite.id);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user