-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
549df98
commit 43486fa
Showing
3 changed files
with
18 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import React, { ComponentPropsWithoutRef } from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import { LoaderCircle } from 'lucide-react'; | ||
|
||
import Logo from '../../assets/images/loading.gif'; | ||
import { cn } from '../../lib/utils'; | ||
|
||
const TypeLoader = { | ||
default: 'default', | ||
raccord: 'raccord', | ||
}; | ||
|
||
interface LoaderProps extends ComponentPropsWithoutRef<'div'> { | ||
customClass?: string; | ||
interface LoaderProps extends React.HTMLAttributes<SVGSVGElement> { | ||
size?: number; | ||
type?: keyof typeof TypeLoader; | ||
} | ||
|
||
export function Loader(props: LoaderProps) { | ||
const { size = 24, customClass = '', type = 'default', ...rest } = props; | ||
const Loader = forwardRef<SVGSVGElement, LoaderProps>((props, ref) => { | ||
const { size = 24, className, ...rest } = props; | ||
|
||
return ( | ||
<div data-testid="loader" className={customClass} {...rest}> | ||
{type === 'default' ? ( | ||
<LoaderCircle size={size} className="animate-spin text-primary" /> | ||
) : ( | ||
<img src={Logo} alt="loading" width={size} height={size} /> | ||
)} | ||
</div> | ||
<LoaderCircle | ||
ref={ref} | ||
data-testid="loader" | ||
strokeWidth={2} | ||
size={size} | ||
className={cn('animate-spin text-primary', className)} | ||
{...rest} | ||
/> | ||
); | ||
} | ||
}); | ||
|
||
Loader.displayName = 'Loader'; | ||
|
||
export { Loader }; |