-
Notifications
You must be signed in to change notification settings - Fork 41
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
1b012a6
commit 14483a0
Showing
1 changed file
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { VariantProps, cva } from "class-variance-authority"; | ||
import { Loader2 } from "lucide-react"; | ||
|
||
import { cn } from "@/utils/ui"; | ||
|
||
const spinnerVariants = cva("flex-col items-center justify-center", { | ||
variants: { | ||
show: { | ||
true: "flex", | ||
false: "hidden", | ||
}, | ||
}, | ||
defaultVariants: { | ||
show: true, | ||
}, | ||
}); | ||
|
||
const loaderVariants = cva("animate-spin text-primary", { | ||
variants: { | ||
size: { | ||
small: "size-6", | ||
medium: "size-8", | ||
large: "size-12", | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: "medium", | ||
}, | ||
}); | ||
|
||
interface SpinnerContentProps | ||
extends VariantProps<typeof spinnerVariants>, | ||
VariantProps<typeof loaderVariants> { | ||
className?: string; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export function Spinner({ | ||
size, | ||
show, | ||
children, | ||
className, | ||
}: SpinnerContentProps) { | ||
return ( | ||
<span className={spinnerVariants({ show })}> | ||
<Loader2 className={cn(loaderVariants({ size }), className)} /> | ||
{children} | ||
</span> | ||
); | ||
} |