-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProductCard.tsx
More file actions
97 lines (92 loc) · 3.31 KB
/
ProductCard.tsx
File metadata and controls
97 lines (92 loc) · 3.31 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
92
93
94
95
96
97
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';
export type ProductCardProps = Product & Omit<CardProps, 'id' | 'title'>;
export const ProductCard: FC<ProductCardProps> = observer(
({ className = '', id, createdAt, name, sourceLink, link = sourceLink, summary, ...props }) => {
if (!sourceLink) return null;
return (
<Card className={`border-success ${className}`} {...props}>
<Card.Body className="d-flex flex-column">
<Card.Title
as="a"
className="text-primary"
title={name as string}
target="_blank"
href={link as string}
>
{(name || link) as string}
</Card.Title>
<p className="border-bottom p-2 text-muted text-truncate">{summary as string}</p>
<div className="border-bottom py-2 my-2 flex-fill">
<FilePreview className="w-100" path={link as string} />
<div className="d-flex flex-wrap gap-2 mt-2">
<Button
variant="dark"
size="sm"
href={sourceLink as string}
target="_blank"
rel="noreferrer"
>
<img
src="https://img.shields.io/badge/GitHub-181717?logo=github"
alt="GitHub"
style={{ height: '20px' }}
/>
</Button>
<Button
variant="primary"
size="sm"
href={`https://github.dev/${(sourceLink as string).replace('https://github.com/', '')}`}
target="_blank"
rel="noreferrer"
>
<img
src="https://img.shields.io/badge/GitHub.dev-blue?logo=visualstudio"
alt="GitHub.dev"
style={{ height: '20px' }}
/>
</Button>
<Button
variant="dark"
size="sm"
href={`https://codespaces.new/${(sourceLink as string).replace('https://github.com/', '')}`}
target="_blank"
rel="noreferrer"
>
<img
src="https://img.shields.io/badge/GitHub_codespaces-black?logo=github"
alt="GitHub Codespaces"
style={{ height: '20px' }}
/>
</Button>
<Button
variant="warning"
size="sm"
href={`https://gitpod.io/#${sourceLink as string}`}
target="_blank"
rel="noreferrer"
>
<img
src="https://img.shields.io/badge/GitPod.io-orange?logo=git"
alt="GitPod"
style={{ height: '20px' }}
/>
</Button>
</div>
</div>
<time
className="d-block p-2 text-truncate"
dateTime={new Date(createdAt as number).toJSON()}
>
📅
{formatDate(createdAt as number)}
</time>
</Card.Body>
</Card>
);
},
);