ServiceCards Sections
Diensten als hoverable cards met icon, titel, beschrijving en optionele link. 2-4 kolommen.
src/components/sections/ServiceCards.astro
---
/**
* ServiceCards
* Diensten als hoverable cards met icon, titel, beschrijving en optionele link.
* 2-4 kolommen. Optionele prijs.
*/
interface Props {
headline?: string;
sub?: string;
services: { icon?: string; title: string; body: string; href?: string; price?: string; tag?: string }[];
columns?: 2 | 3 | 4;
}
const { headline, sub, services, columns = 3 } = Astro.props;
---
<section class="sc" data-service-cards>
<div class="sc-inner">
{(headline || sub) && (
<div class="sc-header">
{headline && <h2 class="sc-headline">{headline}</h2>}
{sub && <p class="sc-sub">{sub}</p>}
</div>
)}
<div class={`sc-grid sc-grid--${columns}`}>
{services.map(s => (
s.href
? <a href={s.href} class="sc-card sc-card--link">
{s.tag && <span class="sc-tag">{s.tag}</span>}
{s.icon && <span class="sc-icon">{s.icon}</span>}
<h3 class="sc-title">{s.title}</h3>
<p class="sc-body">{s.body}</p>
{s.price && <span class="sc-price">{s.price}</span>}
<span class="sc-arrow">→</span>
</a>
: <div class="sc-card">
{s.tag && <span class="sc-tag">{s.tag}</span>}
{s.icon && <span class="sc-icon">{s.icon}</span>}
<h3 class="sc-title">{s.title}</h3>
<p class="sc-body">{s.body}</p>
{s.price && <span class="sc-price">{s.price}</span>}
</div>
))}
</div>
</div>
</section>
<style>
.sc { padding: 5rem 2rem; background: #f8fafc; }
.sc-inner { max-width: 1280px; margin: 0 auto; }
.sc-header { text-align: center; max-width: 640px; margin: 0 auto 3.5rem; }
.sc-headline { font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; margin: 0 0 0.75rem; }
.sc-sub { font-size: 1.0625rem; color: #6b7280; line-height: 1.6; margin: 0; }
.sc-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .sc-grid--2, .sc-grid--3, .sc-grid--4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .sc-grid--3 { grid-template-columns: repeat(3,1fr); } .sc-grid--4 { grid-template-columns: repeat(4,1fr); } }
.sc-card { position: relative; background: #fff; border-radius: 1rem; padding: 2rem; display: flex; flex-direction: column; gap: 0.75rem; border: 1px solid #e2e8f0; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.sc-card--link { text-decoration: none; color: inherit; cursor: pointer; }
.sc-card:hover, .sc-card--link:hover { border-color: var(--color-accent,#6366f1); box-shadow: 0 8px 30px rgba(99,102,241,0.08); transform: translateY(-2px); }
.sc-tag { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent,#6366f1); background: rgba(99,102,241,0.08); padding: 0.2rem 0.6rem; border-radius: 100px; width: fit-content; }
.sc-icon { font-size: 1.75rem; }
.sc-title { font-size: 1.0625rem; font-weight: 700; color: #0a0a0a; margin: 0; }
.sc-body { font-size: 0.9375rem; color: #6b7280; line-height: 1.6; margin: 0; flex: 1; }
.sc-price { font-size: 0.875rem; font-weight: 700; color: #0a0a0a; margin-top: auto; }
.sc-arrow { font-size: 1.25rem; color: var(--color-accent,#6366f1); transition: transform 0.2s; margin-top: auto; }
.sc-card:hover .sc-arrow { transform: translateX(4px); }
</style>
Props
| Prop | Type | Default | Beschrijving |
|---|---|---|---|
services * | { icon?: string; title: string; body: string; href?: string; price?: string; tag?: string }[] | — | Dienst items |
headline | string | — | Sectie headline |
sub | string | — | Sectie ondertitel |
columns | 2 | 3 | 4 | 3 | Aantal kolommen |
* = verplicht