-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathLoading.tsx
83 lines (73 loc) · 2.04 KB
/
Loading.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
73
74
75
76
77
78
79
80
81
82
83
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { SxProps } from '@mui/material';
import PropTypes from 'prop-types';
import CircularProgress from '@mui/material/CircularProgress';
import { useTranslate } from 'ra-core';
export const Loading = (props: LoadingProps) => {
const {
className,
loadingPrimary = 'ra.page.loading',
loadingSecondary = 'ra.message.loading',
...rest
} = props;
const translate = useTranslate();
return (
<Root className={className} {...rest}>
<div className={LoadingClasses.message}>
<CircularProgress
className={LoadingClasses.icon}
color="primary"
/>
<h1>{translate(loadingPrimary)}</h1>
<div>{translate(loadingSecondary)}.</div>
</div>
</Root>
);
};
Loading.propTypes = {
className: PropTypes.string,
loadingPrimary: PropTypes.string,
loadingSecondary: PropTypes.string,
};
Loading.defaultProps = {
loadingPrimary: 'ra.page.loading',
loadingSecondary: 'ra.message.loading',
};
export interface LoadingProps {
className?: string;
loadingPrimary?: string;
loadingSecondary?: string;
sx?: SxProps;
}
const PREFIX = 'RaLoading';
export const LoadingClasses = {
root: `${PREFIX}-root`,
icon: `${PREFIX}-icon`,
message: `${PREFIX}-message`,
};
const Root = styled('div', {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
[theme.breakpoints.up('md')]: {
height: '100%',
},
[theme.breakpoints.down('xl')]: {
height: '100vh',
marginTop: '-3em',
},
[`& .${LoadingClasses.icon}`]: {
width: '9em',
height: '9em',
},
[`& .${LoadingClasses.message}`]: {
textAlign: 'center',
fontFamily: 'Roboto, sans-serif',
opacity: 0.5,
margin: '0 1em',
},
}));