Zoeken...  ⌘K GitHub

ImageLightbox image

Fotogalerij met klikbare thumbnails en hover-overlay. Lightbox vereist eigen JS implementatie.

/image-lightbox
src/components/image/ImageLightbox.astro
---
interface LightboxPhoto {
  src?: string;
  alt: string;
  caption?: string;
}

interface Props {
  title?: string;
  photos?: LightboxPhoto[];
  cols?: number;
}

const {
  title = 'Fotogalerij',
  photos = [
    { alt: 'Foto 1', caption: 'Campagne lancering' },
    { alt: 'Foto 2', caption: 'Team event' },
    { alt: 'Foto 3', caption: 'Nieuwe huisstijl' },
    { alt: 'Foto 4', caption: 'Shoot dag' },
  ],
  cols = 3,
} = Astro.props;
---

<section class="bl-section ilb">
  <div class="bl-inner ilb__inner">
    {title && <h2 class="ilb__title">{title}</h2>}
    <div class="ilb__grid" style={`--ilb-cols: ${cols}`}>
      {photos.map((photo) => (
        <button class="ilb__thumb" type="button" aria-label={`Bekijk: ${photo.alt}`}>
          {photo.src
            ? <img data-allow-img class="ilb__img" src={photo.src} alt={photo.alt} loading="lazy" decoding="async" />
            : <div class="ilb__placeholder" aria-label={photo.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"></circle>
              <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
              <line x1="11" y1="8" x2="11" y2="14"></line>
              <line x1="8" y1="11" x2="14" y2="11"></line>
            </svg>
          </span>
          {photo.caption && <span class="ilb__caption">{photo.caption}</span>}
        </button>
      ))}
    </div>
  </div>
</section>

<style>
  .ilb__title {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--color-primary, #0a0a0a);
    margin: 0 0 2rem;
  }
  .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, #c8c8e8);
    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);
  }
  @media (max-width: 640px) {
    .ilb__grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
</style>

Props

Prop Type Default Beschrijving
title string - Kop boven de galerij
photos { src?: string; alt: string; caption?: string }[] - Array fotobeschrijvingen
cols number 3 Aantal kolommen in de grid

* = verplicht