You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

171 lines
3.2 KiB

<script setup lang="ts">
defineProps<{
image: string
title: string
description: string
tags: string[]
aspectRatio: number
}>()
const imgLoaded = ref(false)
const imgFailed = ref(false)
function onImgLoad() {
imgLoaded.value = true
}
function onImgError() {
imgFailed.value = true
imgLoaded.value = true
}
</script>
<template>
<div class="card" :style="{ aspectRatio }">
<div class="img-placeholder" :class="{ loaded: imgLoaded }" />
<img
v-if="!imgFailed"
:src="image"
:alt="title"
loading="lazy"
class="card-img"
:class="{ loaded: imgLoaded }"
@load="onImgLoad"
@error="onImgError"
>
<div v-if="imgFailed" class="img-fallback">
<span class="fallback-icon">&#128247;</span>
</div>
<div class="gradient-fade" />
<div class="card-body">
<h3>{{ title }}</h3>
<p>{{ description }}</p>
<div class="tags">
<span v-for="tag in tags" :key="tag" class="tag">{{ tag }}</span>
</div>
</div>
</div>
</template>
<style scoped>
.card {
position: relative;
border-radius: 12px;
background: var(--color-surface-card);
overflow: hidden;
transition: transform 0.4s var(--ease-out-expo), box-shadow 0.4s var(--ease-out-expo);
}
.card:hover {
transform: translateY(-5px) scale(1.01);
box-shadow: 0 16px 48px rgba(20, 20, 19, 0.12);
}
.img-placeholder {
position: absolute;
inset: 0;
background: linear-gradient(135deg, #e8e0d2 0%, #efe9de 50%, #e8e0d2 100%);
background-size: 200% 200%;
animation: shimmer 1.8s ease-in-out infinite;
}
.img-placeholder.loaded {
display: none;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.card-img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
display: block;
opacity: 0;
transition: opacity 0.5s ease;
}
.card-img.loaded {
opacity: 1;
}
.img-fallback {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #e8e0d2 0%, #efe9de 50%, #e8e0d2 100%);
}
.fallback-icon {
font-size: 40px;
opacity: 0.3;
}
.gradient-fade {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 62%;
background: linear-gradient(
to bottom,
transparent 0%,
rgba(20, 20, 19, 0) 25%,
rgba(20, 20, 19, 0.35) 50%,
rgba(20, 20, 19, 0.78) 100%
);
pointer-events: none;
}
.card-body {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 0 20px 22px;
z-index: 1;
}
.card-body h3 {
color: #fff;
font-family: var(--font-display);
font-size: 18px;
font-weight: 400;
line-height: 1.3;
margin: 0 0 5px;
letter-spacing: -0.01em;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.card-body p {
color: rgba(255, 255, 255, 0.78);
font-size: 13px;
font-weight: 400;
line-height: 1.5;
margin: 0 0 14px;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.tag {
font-size: 11.5px;
font-weight: 400;
color: rgba(255, 255, 255, 0.82);
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.18);
padding: 3px 10px;
border-radius: 9999px;
line-height: 1.3;
}
</style>