2023-08-01 07:31:35 +00:00
|
|
|
import { Loader2 } from 'lucide-react';
|
|
|
|
import { PropsWithChildren } from 'react';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
|
|
import { Icon } from '@@/Icon';
|
|
|
|
|
2023-08-27 21:01:35 +00:00
|
|
|
type Size = 'xs' | 'sm' | 'md';
|
|
|
|
|
2023-08-01 07:31:35 +00:00
|
|
|
export type Props = {
|
2023-08-27 21:01:35 +00:00
|
|
|
className?: string;
|
|
|
|
size?: Size;
|
|
|
|
};
|
|
|
|
|
|
|
|
const sizeStyles: Record<Size, string> = {
|
|
|
|
xs: 'text-xs',
|
|
|
|
sm: 'text-sm',
|
|
|
|
md: 'text-md',
|
2023-08-01 07:31:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export function InlineLoader({
|
|
|
|
children,
|
|
|
|
className,
|
2023-08-27 21:01:35 +00:00
|
|
|
size = 'sm',
|
2023-08-01 07:31:35 +00:00
|
|
|
}: PropsWithChildren<Props>) {
|
|
|
|
return (
|
|
|
|
<div
|
2023-08-27 21:01:35 +00:00
|
|
|
className={clsx(
|
|
|
|
'text-muted flex items-center gap-2',
|
|
|
|
className,
|
|
|
|
sizeStyles[size]
|
|
|
|
)}
|
2023-08-01 07:31:35 +00:00
|
|
|
>
|
|
|
|
<Icon icon={Loader2} className="animate-spin-slow" />
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|