-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathChartWithDescriptionCard.tsx
More file actions
70 lines (63 loc) · 2.59 KB
/
ChartWithDescriptionCard.tsx
File metadata and controls
70 lines (63 loc) · 2.59 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
67
68
69
70
/* eslint-disable @typescript-eslint/no-explicit-any */
import clsx from 'clsx'
import { snakeCase } from 'lodash'
import Link from 'next/link'
import { hasSource, SourceFooter } from '@/app/components/cms/SourceFooter/SourceFooter'
import { Card, Chart } from '@/app/components/ui/ukhsa'
import { getPath } from '@/app/utils/cms/slug'
type ChartWithDescriptionCardProps = {
readonly value: any
readonly cardsCount: number
}
export function ChartWithDescriptionCard({ value, cardsCount }: ChartWithDescriptionCardProps) {
const topicPagePath = getPath(value.topic_page)
const showSource = hasSource(value.source)
return (
<div className="group flex h-full flex-col">
<Card
asChild
aria-labelledby={`chart-with-description-card-heading-${snakeCase(value.title)}`}
className={clsx(
'ukhsa-chart-card relative flex min-h-0 flex-1 flex-col border border-grey-2 bg-[var(--colour-home-chart-background)] no-underline transition-colors duration-200 ukhsa-focus focus:border-grey-2 focus:bg-[var(--colour-home-chart-background-hover)] group-hover:bg-[var(--colour-home-chart-background-hover)]',
showSource && 'border-b-0 pb-2'
)}
>
<Link href={topicPagePath} prefetch className="flex h-full min-h-0 flex-col">
<h3 id={`chart-with-description-card-heading-${snakeCase(value.title)}`} className="govuk-heading-m mb-1">
{value.title}
</h3>
<p className="govuk-body-s mb-3 text-grey-1">{value.sub_title}</p>
<div>
<Chart
enableInteractive={false}
data={value}
sizes={[
{
minWidth: 1200,
size: cardsCount < 3 ? 'half' : 'third',
},
{
size: 'third',
default: true,
},
]}
/>
</div>
{value.description && (
<p className="govuk-body-s mb-0 mt-3 text-grey-1" data-testid="chart-description">
{value.description}
<span className="govuk-link govuk-link--no-visited-state ml-1 text-blue hover:text-dark-blue">
Visit {value.title} to find out more
</span>
</p>
)}
</Link>
</Card>
<SourceFooter
source={value.source}
className="border-x border-b border-grey-2 bg-[var(--colour-home-chart-background)] !px-4 !py-2 pb-4 transition-colors duration-200 group-hover:bg-[var(--colour-home-chart-background-hover)]"
testId="chart-source"
/>
</div>
)
}