Skip to content

Commit dc33d8c

Browse files
committed
Add the Card and CardGroup components
1 parent 2a932c2 commit dc33d8c

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
'use client';
2+
3+
import React from 'react';
4+
5+
// Card Component
6+
export function Card({ name, odsCode, address, specialty }) {
7+
return (
8+
<li className="nhsuk-grid-column-one-third nhsuk-card-group__item">
9+
<div className="nhsuk-card nhsuk-card--clickable">
10+
<div className="nhsuk-card__content">
11+
{/* Header */}
12+
<h5 className="nhsuk-card__heading nhsuk-heading-xs">
13+
<a className="nhsuk-card__link" href="#">
14+
{name} (ODS: {odsCode})
15+
</a>
16+
</h5>
17+
{/* Address Section */}
18+
<p className="nhsuk-card__address">
19+
{address ? (
20+
address.split('\n').map((line, index) => (
21+
<span key={index} className="address-line">
22+
{line}
23+
<br />
24+
</span>
25+
))
26+
) : (
27+
<span>No address found</span>
28+
)}
29+
</p>
30+
{/* Specialty */}
31+
<p className="nhsuk-card__specialty">{specialty}</p>
32+
</div>
33+
</div>
34+
</li>
35+
);
36+
}
37+
38+
// CardGroup Component
39+
export default function CardGroup() {
40+
const cards = [
41+
{
42+
name: 'JONES SURGERY',
43+
odsCode: 'RCD60',
44+
address: '4 Sardinia street\nHolborn\nLondon\nSE4 6ER',
45+
specialty: 'General Medical Practitioner',
46+
},
47+
{
48+
name: 'JONES SURGERY',
49+
odsCode: 'RCD60',
50+
address: null, // No address
51+
specialty: 'General Medical Practitioner',
52+
},
53+
];
54+
55+
return (
56+
<ul className="nhsuk-grid-row nhsuk-card-group">
57+
{cards.map((card, index) => (
58+
<Card
59+
key={index}
60+
name={card.name}
61+
odsCode={card.odsCode}
62+
address={card.address}
63+
specialty={card.specialty}
64+
/>
65+
))}
66+
</ul>
67+
);
68+
}

0 commit comments

Comments
 (0)