ImageBefore image
Voor-na vergelijking naast elkaar met labels. Toont transformatie visueel aan.
src/components/image/ImageBefore.astro
---
interface Props {
title?: string;
beforeLabel?: string;
afterLabel?: string;
beforeSrc?: string;
afterSrc?: string;
beforeAlt?: string;
afterAlt?: string;
}
const {
title = 'Transformatie in actie',
beforeLabel = 'Voor',
afterLabel = 'Na',
beforeSrc,
afterSrc,
beforeAlt = 'Situatie voor',
afterAlt = 'Situatie na',
} = Astro.props;
---
<section class="bl-section iba">
<div class="bl-inner iba__inner">
<h2 class="iba__title">{title}</h2>
<div class="iba__wrapper">
<div class="iba__panel iba__panel--before">
{beforeSrc
? <img data-allow-img class="iba__img" src={beforeSrc} alt={beforeAlt} loading="lazy" decoding="async" />
: <div class="iba__placeholder iba__placeholder--before" aria-label={beforeAlt}></div>
}
<span class="iba__label iba__label--before">{beforeLabel}</span>
</div>
<div class="iba__divider" aria-hidden="true">
<span class="iba__divider-line"></span>
<span class="iba__divider-icon">↔</span>
<span class="iba__divider-line"></span>
</div>
<div class="iba__panel iba__panel--after">
{afterSrc
? <img data-allow-img class="iba__img" src={afterSrc} alt={afterAlt} loading="lazy" decoding="async" />
: <div class="iba__placeholder iba__placeholder--after" aria-label={afterAlt}></div>
}
<span class="iba__label iba__label--after">{afterLabel}</span>
</div>
</div>
</div>
</section>
<style>
.iba__title {
font-size: clamp(1.75rem, 3vw, 2.5rem);
font-weight: 700;
color: var(--color-primary, #0a0a0a);
text-align: center;
margin: 0 0 2rem;
}
.iba__wrapper {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: stretch;
gap: 0;
border-radius: 12px;
overflow: hidden;
border: 1px solid #e0e0e0;
}
.iba__panel {
position: relative;
aspect-ratio: 4/3;
}
.iba__img {
width: 100%;
height: 100%;
object-fit: cover;
}
.iba__placeholder {
width: 100%;
height: 100%;
}
.iba__placeholder--before {
background: linear-gradient(135deg, #d0d0d0, #b0b0b0);
}
.iba__placeholder--after {
background: linear-gradient(135deg, #c8d8f0, #a8c0e8);
}
.iba__label {
position: absolute;
top: 1rem;
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
padding: 0.3rem 0.75rem;
border-radius: 20px;
}
.iba__label--before {
left: 1rem;
background: #333;
color: #fff;
}
.iba__label--after {
right: 1rem;
background: var(--color-accent, #6366f1);
color: #fff;
}
.iba__divider {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 2.5rem;
background: #fff;
gap: 0.5rem;
padding: 1rem 0;
}
.iba__divider-line {
display: block;
width: 1px;
flex: 1;
background: #e0e0e0;
}
.iba__divider-icon {
font-size: 1rem;
color: var(--color-accent, #6366f1);
font-weight: 700;
}
@media (max-width: 640px) {
.iba__wrapper {
grid-template-columns: 1fr;
grid-template-rows: 1fr auto 1fr;
}
.iba__divider {
flex-direction: row;
width: 100%;
height: 2.5rem;
}
.iba__divider-line {
width: auto;
flex: 1;
height: 1px;
}
}
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
title | string | - | Kop boven het voor-na paar |
beforeLabel | string | "Voor" | Label op het voor-beeld |
afterLabel | string | "Na" | Label op het na-beeld |
beforeSrc | string | - | URL van de voor-afbeelding |
afterSrc | string | - | URL van de na-afbeelding |
beforeAlt | string | - | Alt-tekst voor het voor-beeld |
afterAlt | string | - | Alt-tekst voor het na-beeld |
* = verplicht