Open History to see the last commit
1import { useGT } from "gt-react";
2import { LoaderCircleIcon } from "lucide-react";
3import { cva, type VariantProps } from "class-variance-authority";
4import { observeVisibleAnimation } from "~/lib/visibleAnimation";
5import { cn } from "~/lib/utils";
6
7// No default size: inside a Button the parent's svg rule sizes the glyph.
8const spinnerVariants = cva("motion-safe:visible-animate-spin", {
9 variants: {
10 size: {
11 xs: "size-3",
12 sm: "size-3.5",
13 md: "size-4",
14 lg: "size-5",
15 },
16 tone: {
17 current: "",
18 muted: "text-muted-foreground",
19 },
20 },
21 defaultVariants: { tone: "current" },
22});
23
24function Spinner({
25 className,
26 size,
27 tone,
28 ...props
29}: React.ComponentPropsWithoutRef<typeof LoaderCircleIcon> & VariantProps<typeof spinnerVariants>) {
30 const gt = useGT();
31 return (
32 <LoaderCircleIcon
33 aria-label={gt("Loading")}
34 ref={observeVisibleAnimation}
35 className={cn(spinnerVariants({ size, tone }), className)}
36 role="status"
37 {...props}
38 />
39 );
40}
41
42export { Spinner };