-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageCard.tsx
More file actions
executable file
·59 lines (51 loc) · 1.36 KB
/
ImageCard.tsx
File metadata and controls
executable file
·59 lines (51 loc) · 1.36 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
import React from 'react';
import './ImageCard.scss';
import { IconAlt as Icon } from '@veupathdb/wdk-client/lib/Components';
interface ImageCardProps {
card: {
appImage?: string;
image?: string;
appUrl?: string;
url?: string;
title: string;
description: string;
linkText: string;
linkTarget?: string;
};
prefix?: string;
}
class ImageCard extends React.Component<ImageCardProps> {
render() {
const { card, prefix = '' } = this.props;
const {
appImage,
image,
appUrl,
url,
title,
description,
linkText,
linkTarget,
} = card;
const imageUrl = typeof appImage !== 'string' ? image : prefix + appImage;
const linkUrl = typeof appUrl !== 'string' ? url : prefix + appUrl;
return (
<div className="Card ImageCard">
<div
className="box ImageCard-Image"
style={{ backgroundImage: `url(${imageUrl})` }}
/>
<div className="box ImageCard-Title">
<a href={linkUrl}>
<h3 dangerouslySetInnerHTML={{ __html: title }} />
</a>
<p dangerouslySetInnerHTML={{ __html: description }} />
</div>
<a className="ImageCard-Footer" href={linkUrl} target={linkTarget}>
{linkText} <Icon fa={'chevron-circle-right'} />
</a>
</div>
);
}
}
export default ImageCard;