|
1 | | -import { Box, CircularProgress, CircularProgressProps, Typography, type BoxProps } from '@mui/material'; |
2 | | -import { type ReactNode, type FC } from 'react'; |
3 | | - |
4 | | -import { useTheme2 } from '@grafana/ui'; |
| 1 | +import { type FC } from 'react'; |
5 | 2 |
|
6 | 3 | import { CodeRabbitLogo } from './CodeRabbitLogo'; |
7 | 4 |
|
8 | 5 | export type FnLoaderProps = { |
9 | | - outerContainerProps?: Omit<BoxProps, 'children'>; |
10 | | - innerContainerProps?: Omit<BoxProps, 'children'>; |
11 | | - circularProgressProps?: CircularProgressProps; |
12 | | - text?: ReactNode; |
| 6 | + size?: 'small' | 'medium' | 'large'; |
| 7 | + loadingMessage?: string; |
13 | 8 | }; |
14 | 9 |
|
15 | | -export const FnLoader: FC<FnLoaderProps> = ({ |
16 | | - outerContainerProps, |
17 | | - innerContainerProps, |
18 | | - circularProgressProps, |
19 | | - text, |
20 | | -}) => { |
21 | | - const theme = useTheme2(); |
22 | | - |
| 10 | +export const FnLoader: FC<FnLoaderProps> = ({ size = 'medium', loadingMessage = 'Loading dashboard...' }) => { |
23 | 11 | return ( |
24 | | - <Box |
25 | | - display="flex" |
26 | | - justifyContent="center" |
27 | | - alignItems="center" |
28 | | - flexDirection="column" |
29 | | - paddingTop="150px" |
30 | | - {...outerContainerProps} |
31 | | - > |
32 | | - <CodeRabbitLogo width={350} /> |
33 | | - <Box marginTop="100px" {...innerContainerProps}> |
34 | | - <CircularProgress |
35 | | - role="alert" |
36 | | - aria-busy="true" |
37 | | - aria-label="Loading..." |
38 | | - disableShrink |
39 | | - sx={{ |
40 | | - color: theme.colors.primary.main, |
41 | | - }} |
42 | | - {...circularProgressProps} |
43 | | - /> |
44 | | - </Box> |
45 | | - {typeof text === 'string' ? <Typography>{text}</Typography> : text || null} |
46 | | - </Box> |
| 12 | + <div className="hide-theme-toggle relative"> |
| 13 | + <div className="mx-auto flex w-10/12 flex-col items-center sm:w-full"> |
| 14 | + {size === 'medium' && <CodeRabbitLogo width={200} className="" />} |
| 15 | + <div className="flex items-center justify-center gap-x-4"> |
| 16 | + <p className="font-poppins text-shimmer from-muted via-secondary to-foreground -mt-2 ml-1 bg-gradient-to-r bg-clip-text text-lg tracking-wide text-transparent"> |
| 17 | + {loadingMessage} |
| 18 | + </p> |
| 19 | + </div> |
| 20 | + </div> |
| 21 | + </div> |
47 | 22 | ); |
48 | 23 | }; |
0 commit comments