src/components/video/VideoThumbnail.astro
---
interface Props {
href?: string;
poster?: string;
alt?: string;
title?: string;
duration?: string;
aspectRatio?: string;
}
const {
href = '#',
poster = '',
alt = 'Video thumbnail',
title = 'Hoe BLURR jouw merk laat groeien',
duration = '3:42',
aspectRatio = '16/9',
} = Astro.props;
---
<a class="vtn" href={href} aria-label={`Bekijk video: ${title}`} style={`--vtn-ratio: ${aspectRatio}`}>
<div class="vtn__media">
{poster ? (
<img class="vtn__poster" src={poster} alt={alt} />
) : (
<div class="vtn__placeholder" aria-label={alt}></div>
)}
<div class="vtn__play" aria-hidden="true">
<svg width="40" height="40" viewBox="0 0 40 40" fill="none">
<circle cx="20" cy="20" r="20" fill="rgba(99,102,241,0.9)"/>
<polygon points="16,12 32,20 16,28" fill="white"/>
</svg>
</div>
{duration && <span class="vtn__duration">{duration}</span>}
</div>
{title && <p class="vtn__title">{title}</p>}
</a>
<style>
:root {
--color-accent: #6366f1;
--color-primary: #0a0a0a;
}
.vtn {
display: block;
text-decoration: none;
}
.vtn__media {
position: relative;
aspect-ratio: var(--vtn-ratio, 16/9);
border-radius: 10px;
overflow: hidden;
background: #111;
}
.vtn__poster {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s;
}
.vtn:hover .vtn__poster { transform: scale(1.04); }
.vtn__placeholder {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4e 100%);
}
.vtn__play {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
transition: opacity 0.2s;
}
.vtn:hover .vtn__play { opacity: 0.9; }
.vtn__duration {
position: absolute;
bottom: 0.5rem;
right: 0.6rem;
background: rgba(10,10,10,0.75);
color: #fff;
font-size: 0.75rem;
font-weight: 700;
padding: 0.2rem 0.5rem;
border-radius: 4px;
}
.vtn__title {
font-size: 0.95rem;
font-weight: 600;
color: var(--color-primary, #0a0a0a);
margin: 0.75rem 0 0;
line-height: 1.4;
}
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
href | string | — | Link URL |
poster | string | — | Thumbnail URL |
alt | string | — | Alt-tekst |
title | string | — | Video-titel |
duration | string | — | Afspeelduur |
aspectRatio | string | — | CSS aspect-ratio |
* = verplicht