src/components/image/ImageLightbox.astro
---
interface LightboxImage {
src?: string;
alt: string;
thumb?: string;
caption?: string;
}
interface Props {
images?: LightboxImage[];
title?: string;
columns?: number;
}
const {
images = [
{ alt: 'Foto 1', caption: 'Campagne lancering' },
{ alt: 'Foto 2', caption: 'Team event 2024' },
{ alt: 'Foto 3', caption: 'Nieuwe huisstijl' },
{ alt: 'Foto 4', caption: 'Shoot dag' },
{ alt: 'Foto 5', caption: 'Awards night' },
{ alt: 'Foto 6', caption: 'Klant bijeenkomst' },
],
title = 'Fotogalerij',
columns = 3,
} = Astro.props;
---
<section class="ilb">
{title && <h2 class="ilb__title">{title}</h2>}
<div class="ilb__grid" style={`--ilb-cols: ${columns}`}>
{images.map((img) => (
<button class="ilb__thumb" type="button" aria-label={`Bekijk: ${img.alt}`}>
{img.src ? (
<img class="ilb__img" src={img.src} alt={img.alt} />
) : (
<div class="ilb__placeholder" aria-label={img.alt}></div>
)}
<span class="ilb__hint" aria-hidden="true">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
<line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/>
</svg>
</span>
{img.caption && <span class="ilb__caption">{img.caption}</span>}
</button>
))}
</div>
<p class="ilb__note">Klik op een foto voor een grotere weergave (lightbox vereist JavaScript)</p>
</section>
<style>
:root {
--color-accent: #6366f1;
--color-primary: #0a0a0a;
}
.ilb { padding: 2rem 0; }
.ilb__title {
font-size: 2rem;
font-weight: 700;
color: var(--color-primary, #0a0a0a);
margin: 0 0 2rem;
text-align: center;
}
.ilb__grid {
display: grid;
grid-template-columns: repeat(var(--ilb-cols, 3), 1fr);
gap: 0.75rem;
}
.ilb__thumb {
position: relative;
aspect-ratio: 1;
border: none;
padding: 0;
cursor: pointer;
border-radius: 8px;
overflow: hidden;
background: #eee;
}
.ilb__img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s;
}
.ilb__thumb:hover .ilb__img { transform: scale(1.06); }
.ilb__placeholder {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #e0e0f0 0%, #c8c8e8 100%);
transition: opacity 0.3s;
}
.ilb__hint {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: rgba(99,102,241,0.7);
color: #fff;
opacity: 0;
transition: opacity 0.25s;
}
.ilb__thumb:hover .ilb__hint { opacity: 1; }
.ilb__caption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(10,10,10,0.7);
color: #fff;
font-size: 0.75rem;
font-weight: 600;
padding: 0.5rem;
text-align: center;
transform: translateY(100%);
transition: transform 0.25s;
}
.ilb__thumb:hover .ilb__caption { transform: translateY(0); }
.ilb__note {
font-size: 0.8rem;
color: #999;
text-align: center;
margin: 1.5rem 0 0;
font-style: italic;
}
@media (max-width: 640px) {
.ilb__grid { grid-template-columns: repeat(2, 1fr); }
}
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
images | { src?: string; alt: string; thumb?: string; caption?: string }[] | — | Galerij-afbeeldingen |
title | string | — | Galerij-titel |
columns | number | — | Aantal kolommen |
* = verplicht