-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
66 lines (59 loc) · 2.2 KB
/
index.tsx
File metadata and controls
66 lines (59 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { Card } from '@amsterdam/design-system-react';
import { Heading } from '@nl-design-system-candidate/heading-react';
import { Link } from '@nl-design-system-candidate/link-react';
import { Paragraph } from '@nl-design-system-candidate/paragraph-react';
import { IconCalendar } from '@tabler/icons-react';
import { Icon } from '@utrecht/component-library-react';
import React from 'react';
import type { NewsItem } from './types';
import { Column, Row } from '../Layout';
import '../shared/card-styles.css';
import './styles.css';
export interface NewsCardsProps {
cards: NewsItem[];
}
const getImageSrc = (src: string | { src: string }): string => {
return typeof src === 'string' ? src : src.src;
};
const NewsCards = ({ cards }: NewsCardsProps) => (
<Row columnGap="var(--basis-space-column-xl)" justify="flex-start" rowGap="var(--basis-space-row-xl)" role="list">
{cards.map((card) => (
<Column key={`${card.href}-${card.title}`} cols={6} role="listitem">
<Card className="clippy-voorbeeld__link">
{card.image && (
<div style={{ blockSize: '18rem', inlineSize: '100%', overflow: 'hidden' }}>
<Card.Image
src={getImageSrc(card.image.src)}
alt={card.image.alt}
style={{
blockSize: '18rem',
inlineSize: '100%',
objectFit: 'cover',
objectPosition: card.image.focalPoint || 'center center',
}}
/>
</div>
)}
<div className="clippy-voorbeeld__content">
<header>
<Card.HeadingGroup tagline="Nieuws">
<Heading level={3}>{card.title}</Heading>
</Card.HeadingGroup>
<Icon>
<IconCalendar />
</Icon>
<time dateTime={card.dateTime}>{card.date}</time>
</header>
<Paragraph>{card.body}</Paragraph>
<footer>
<Link href={card.href} aria-label={`Lees meer over ${card.title}`}>
Meer lezen
</Link>
</footer>
</div>
</Card>
</Column>
))}
</Row>
);
export default NewsCards;