-
-
Notifications
You must be signed in to change notification settings - Fork 894
/
Copy pathLoader.tsx
41 lines (33 loc) · 1.07 KB
/
Loader.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
import React from 'react';
import { twMerge } from 'tailwind-merge';
import AsyncAPIColorIcon from './icons/AsyncAPIColorIcon';
interface LoaderProps {
// eslint-disable-next-line prettier/prettier
/** The text to be displayed along with the loading animation. */
loaderText?: string;
/** The icon to be displayed along with the loading animation. */
loaderIcon?: React.ReactElement | null;
/** Additional classes for the loader. */
className?: string;
/** Whether the loader should be in dark mode. */
dark?: boolean;
/** Whether the loader should be pulsating. */
pulsating?: boolean;
}
/**
* This component displays a loader.
*/
export default function Loader({
loaderText = '',
loaderIcon = <AsyncAPIColorIcon alt='Loading...' />,
className = '',
dark = false,
pulsating = false
}: LoaderProps) {
return (
<div className={twMerge(`w-fit flex gap-4 m-auto items-center ${pulsating ? 'animate-pulse ' : ''} ${className}`)}>
{loaderIcon}
<div className={`my-2 ${dark ? 'text-white' : 'text-black'}`}>{loaderText}</div>
</div>
);
}