inhaus-plugin-kleinanzeigen/resources/js/components/ListingCard.vue
Friederich Loheide f05c44733f Kleinanzeigen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 17:06:02 +00:00

43 lines
3.1 KiB
Vue

<script setup>
import { Link, router } from '@inertiajs/vue3';
import { Camera, Heart, ImageOff, MapPin } from '@lucide/vue';
const props = defineProps({
listing: { type: Object, required: true },
compact: { type: Boolean, default: false },
});
function toggleFavorite() {
const l = props.listing;
l.favorite = !l.favorite;
router.visit(`/kleinanzeigen/${l.id}/merken`, { method: l.favorite ? 'post' : 'delete', preserveScroll: true, preserveState: true });
}
</script>
<template>
<article class="ih:group ih:relative ih:flex ih:flex-col ih:overflow-hidden ih:rounded-lg ih:border ih:bg-card ih:shadow-xs ih:transition-shadow ih:hover:shadow-md">
<Link :href="listing.url" class="ih:relative ih:block ih:aspect-[4/3] ih:overflow-hidden ih:bg-muted">
<img v-if="listing.thumb_url" :src="listing.thumb_url" :alt="listing.title" loading="lazy" class="ih:size-full ih:object-cover ih:transition-transform ih:duration-300 ih:group-hover:scale-[1.03]" />
<span v-else class="ih:grid ih:size-full ih:place-items-center ih:text-muted-foreground"><ImageOff class="ih:size-8" :stroke-width="1.5" /></span>
<span class="ih:absolute ih:top-2 ih:left-2 ih:rounded ih:bg-card/95 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:shadow-xs">{{ listing.type_label }}</span>
<span v-if="listing.reserved" class="ih:absolute ih:bottom-2 ih:left-2 ih:rounded ih:bg-foreground/85 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:text-background">Reserviert</span>
<span v-if="listing.images > 1" class="ih:absolute ih:right-2 ih:bottom-2 ih:inline-flex ih:items-center ih:gap-1 ih:rounded ih:bg-foreground/70 ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:text-background"><Camera class="ih:size-3" />{{ listing.images }}</span>
</Link>
<button
type="button"
class="ih:absolute ih:top-2 ih:right-2 ih:grid ih:size-8 ih:place-items-center ih:rounded-full ih:bg-card/95 ih:shadow-xs ih:transition-colors ih:hover:text-brand-text"
:class="listing.favorite ? 'ih:text-brand-text' : 'ih:text-muted-foreground'"
:aria-pressed="listing.favorite"
:aria-label="listing.favorite ? 'Von der Merkliste nehmen' : 'Merken'"
@click="toggleFavorite"
><Heart class="ih:size-4" :class="listing.favorite ? 'ih:fill-current' : ''" /></button>
<div class="ih:flex ih:flex-1 ih:flex-col ih:gap-1 ih:p-3">
<p v-if="listing.price" class="ih:text-[15px] ih:font-semibold ih:text-brand-text">{{ listing.price }}</p>
<Link :href="listing.url" class="ih:line-clamp-2 ih:text-sm ih:leading-snug ih:font-medium ih:hover:underline">{{ listing.title }}</Link>
<p v-if="!compact" class="ih:mt-auto ih:flex ih:items-center ih:gap-1 ih:pt-1 ih:text-xs ih:text-muted-foreground">
<MapPin v-if="listing.location" class="ih:size-3 ih:shrink-0" />
<span class="ih:truncate">{{ [listing.location, listing.category_label].filter(Boolean).join(' · ') }}</span>
</p>
</div>
</article>
</template>