forked from polkadot-js/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpinner.tsx
72 lines (58 loc) · 1.51 KB
/
Spinner.tsx
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
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import styled from 'styled-components';
import spinnerSrc from './Spinner.png';
import { useTranslation } from './translate';
interface Props {
className?: string;
label?: React.ReactNode;
noLabel?: boolean;
variant?: 'app' | 'appPadded' | 'cover' | 'push' | 'mini';
}
// prefetch
const img = new Image();
img.src = spinnerSrc as string;
function Spinner ({ className = '', label, noLabel, variant = 'app' }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
return (
<div className={`${className} ui--Spinner variant-${variant}`}>
<img
className={variant === 'push' ? '' : 'highlight--bg highlight--border'}
src={spinnerSrc as string}
/>
{!noLabel && variant.startsWith('app') && <div className='text'>{label || t('Retrieving data')}</div>}
</div>
);
}
export default React.memo(styled(Spinner)`
display: block;
line-height: 1rem;
margin: 0 auto;
text-align: center;
&.variant-appPadded {
margin-top: 0.5rem;
}
img {
border: 1px solid transparent;
border-radius: 10rem;
}
&.variant-cover {
bottom: 0;
left: 0;
position: absolute;
right: 0;
img {
border: 1 px solid white;
margin: 0 auto;
}
}
.text {
color: inherit !important;
margin: 0.25rem auto 1.5rem auto;
opacity: 0.6;
div+div {
margin-top: 0.25rem;
}
}
`);