forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArticleCard.tsx
46 lines (43 loc) · 1.39 KB
/
ArticleCard.tsx
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
import { Label } from '@primer/react'
import { ArticleGuide } from 'components/context/ProductGuidesContext'
import { Link } from 'components/Link'
type Props = {
card: ArticleGuide
typeLabel: string
tabIndex?: number
}
export const ArticleCard = ({ tabIndex, card, typeLabel }: Props) => {
return (
<li
tabIndex={tabIndex}
data-testid="article-card"
className="d-flex col-12 col-md-4 pr-0 pr-md-6 pr-lg-8"
>
<Link className="no-underline d-flex flex-column py-3 border-bottom" href={card.href}>
<h3 className="h4 color-fg-default mb-1" dangerouslySetInnerHTML={{ __html: card.title }} />
<div className="h6 text-uppercase" data-testid="article-card-type">
{typeLabel}
</div>
<p className="color-fg-muted my-3" dangerouslySetInnerHTML={{ __html: card.intro }} />
{card.topics.length > 0 && (
<ul style={{ listStyleType: 'none' }}>
{card.topics.map((topic) => {
return (
<li className="d-inline-block" key={topic}>
<Label
data-testid="article-card-topic"
size="small"
variant="accent"
sx={{ mr: 1 }}
>
{topic}
</Label>
</li>
)
})}
</ul>
)}
</Link>
</li>
)
}