-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCard.tsx
More file actions
74 lines (70 loc) · 1.92 KB
/
Card.tsx
File metadata and controls
74 lines (70 loc) · 1.92 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
71
72
73
74
import { Icon, Nameplate, text2color } from 'idea-react';
import { marked } from 'marked';
import { Issue } from 'mobx-github';
import { FC } from 'react';
import { Badge, Card, CardProps, Stack } from 'react-bootstrap';
export type IssueCardProps = Issue & Omit<CardProps, 'id' | 'body'>;
export const IssueCard: FC<IssueCardProps> = ({
bg = 'light',
text = 'dark',
id,
number,
title,
labels,
body,
html_url,
user,
comments,
created_at,
...props
}) => (
<Card {...{ ...props, bg, text }}>
<Card.Header
as="h4"
className="d-flex justify-content-between align-items-center gap-3"
>
<a
className="text-decoration-none text-secondary text-truncate"
title={title}
href={html_url}
target="_blank"
rel="noreferrer"
>
#{number} {title}
</a>
<Stack direction="horizontal" gap={2}>
{labels.map(
label =>
typeof label === 'object' && (
<Badge
key={label.name}
className="fs-6"
{...(label.color
? {
bg: '',
style: { background: `#${label.color}` },
}
: {
bg: text2color(label.name || '', ['light']),
})}
>
{label.name}
</Badge>
),
)}
</Stack>
</Card.Header>
<Card.Body
as="article"
dangerouslySetInnerHTML={{ __html: marked(body || '') }}
/>
<Card.Footer className="d-flex justify-content-between align-items-center">
{user && <Nameplate name={user.name || ''} avatar={user.avatar_url} />}
<Stack direction="horizontal" gap={2}>
<Icon name="chat-left-text" />
{comments}
</Stack>
<time dateTime={created_at}>{new Date(created_at).toLocaleString()}</time>
</Card.Footer>
</Card>
);