-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProductCard.tsx
More file actions
91 lines (85 loc) · 2.94 KB
/
ProductCard.tsx
File metadata and controls
91 lines (85 loc) · 2.94 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { observer } from 'mobx-react';
import { FilePreview } from 'mobx-restful-table';
import { FC } from 'react';
import { CardProps, Card, Button } from 'react-bootstrap';
import { formatDate } from 'web-utility';
import { Product } from '../../models/Hackathon';
import styles from '../../styles/Hackathon.module.less';
export type ProductCardProps = Product & Omit<CardProps, 'id' | 'title'>;
export const ProductCard: FC<ProductCardProps> = observer(
({ className = '', id, createdAt, name, sourceLink, link = sourceLink, summary, ...props }) => {
const createdAtValue = Number(createdAt);
const createdAtISO = Number.isFinite(createdAtValue)
? new Date(createdAtValue).toJSON()
: undefined;
const createdAtText = Number.isFinite(createdAtValue) ? formatDate(createdAtValue) : '';
return (
<Card className={`${styles.projectCard} ${className}`} {...props}>
<Card.Body className="d-flex flex-column">
<Card.Title
as="a"
className="text-dark fw-bold"
title={name as string}
target="_blank"
href={link as string}
>
{(name || link) as string}
</Card.Title>
<p className="text-dark opacity-75 mb-3">{summary as string}</p>
<div className="flex-fill mb-3">
<FilePreview className="w-100" path={link as string} />
</div>
{sourceLink && (
<div className="d-flex flex-wrap gap-2 mb-3">
<Button
variant="dark"
size="sm"
href={sourceLink as string}
target="_blank"
rel="noreferrer"
>
GitHub
</Button>
<Button
variant="primary"
size="sm"
href={`https://github.dev/${(sourceLink as string).replace('https://github.com/', '')}`}
target="_blank"
rel="noreferrer"
>
GitHub.dev
</Button>
<Button
variant="dark"
size="sm"
href={`https://codespaces.new/${(sourceLink as string).replace('https://github.com/', '')}`}
target="_blank"
rel="noreferrer"
>
Codespaces
</Button>
<Button
variant="warning"
size="sm"
href={`https://gitpod.io/#${sourceLink as string}`}
target="_blank"
rel="noreferrer"
>
GitPod
</Button>
</div>
)}
{createdAtISO && (
<time
suppressHydrationWarning
className="text-dark opacity-75 small"
dateTime={createdAtISO}
>
📅 {createdAtText}
</time>
)}
</Card.Body>
</Card>
);
},
);