Zoeken...  ⌘K GitHub

VideoCarousel video

Horizontaal scrollende carrousel van videothumbnails.

/video-carousel
src/components/video/VideoCarousel.astro
---
interface VideoItem {
  href?: string;
  poster?: string;
  alt: string;
  title: string;
  duration?: string;
}

interface Props {
  videos?: VideoItem[];
  heading?: string;
}

const {
  videos = [
    { alt: 'Video 1', title: 'Case: TechFlow +280% leads in 3 maanden', duration: '4:12' },
    { alt: 'Video 2', title: 'Hoe wij Google Ads optimaliseren', duration: '6:30' },
    { alt: 'Video 3', title: 'Brand identity voor Mode & Meer', duration: '2:55' },
    { alt: 'Video 4', title: 'De BLURR SEO methode uitgelegd', duration: '8:14' },
    { alt: 'Video 5', title: 'Social media strategie 2024', duration: '5:02' },
  ],
  heading = 'Video overzicht',
} = Astro.props;
---

<section class="vca">
  {heading && <h2 class="vca__heading">{heading}</h2>}
  <div class="vca__track">
    {videos.map((v) => (
      <a class="vca__item" href={v.href ?? '#'} aria-label={`Bekijk: ${v.title}`}>
        <div class="vca__media">
          {v.poster ? (
            <img class="vca__poster" src={v.poster} alt={v.alt} />
          ) : (
            <div class="vca__placeholder" aria-label={v.alt}></div>
          )}
          <span class="vca__play" aria-hidden="true">▶</span>
          {v.duration && <span class="vca__duration">{v.duration}</span>}
        </div>
        <p class="vca__title">{v.title}</p>
      </a>
    ))}
  </div>
</section>

<style>
  :root {
    --color-accent: #6366f1;
    --color-primary: #0a0a0a;
  }
  .vca { padding: 2rem 0; overflow: hidden; }
  .vca__heading {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary, #0a0a0a);
    margin: 0 0 2rem;
  }
  .vca__track {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent, #6366f1) #eee;
  }
  .vca__track::-webkit-scrollbar { height: 4px; }
  .vca__track::-webkit-scrollbar-thumb { background: var(--color-accent, #6366f1); border-radius: 2px; }
  .vca__item {
    flex: 0 0 280px;
    scroll-snap-align: start;
    text-decoration: none;
  }
  .vca__media {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
    margin-bottom: 0.75rem;
  }
  .vca__poster { width: 100%; height: 100%; object-fit: cover; }
  .vca__placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4e 100%);
  }
  .vca__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  }
  .vca__duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
  }
  .vca__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary, #0a0a0a);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
</style>

Props

Prop Type Default Beschrijving
videos { href?: string; poster?: string; alt: string; title: string; duration?: string }[] Video-items
heading string Sectietitel

* = verplicht