forked from astroport-fi/astroport-lbp-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo_card.js
45 lines (40 loc) · 1.32 KB
/
info_card.js
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
import { useState } from 'react';
import Card from './card';
import { ReactComponent as LoadingIndicator } from '../assets/images/loading-indicator.svg';
import { ReactComponent as InfoIcon } from '../assets/images/info.svg';
import classNames from 'classnames';
import Popover from './info_card/popover';
function InfoCard({ label, value, loading, moreInfo, className }) {
const [showMoreInfo, setShowMoreInfo] = useState(false);
return (
<Card
className={classNames('relative', { 'cursor-pointer': moreInfo }, className)}
onMouseEnter={() => setShowMoreInfo(true)}
onMouseLeave={() => setShowMoreInfo(false)}
>
<div className="px-5 pt-4 pb-5 text-center">
<h3 className="text-secondary mb-2 flex items-center justify-center">
{label}
{
!loading && moreInfo &&
<InfoIcon className="text-white h-4 w-4 ml-2 cursor-pointer" />
}
</h3>
<span className="text-lg">
{
loading ?
<div className="flex justify-center">
<LoadingIndicator className="w-8 h-8" />
</div> :
value
}
</span>
</div>
{
!loading && showMoreInfo && moreInfo &&
<Popover>{moreInfo}</Popover>
}
</Card>
);
}
export default InfoCard;