Skip to content

Commit

Permalink
Add Spinner ui component
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinWalzel committed Sep 18, 2024
1 parent 1b012a6 commit 14483a0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions app/frontend/components/ui/spinner.tsx
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>
);
}

0 comments on commit 14483a0

Please sign in to comment.