@stasho/ds 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stasho/ds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "stasho design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"./logo": "./src/components/logo/logo.tsx",
|
|
49
49
|
"./progress-bar": "./src/components/progress-bar/progress-bar.tsx",
|
|
50
50
|
"./stepper": "./src/components/stepper/stepper.tsx",
|
|
51
|
+
"./loader": "./src/components/loader/loader.tsx",
|
|
51
52
|
"./lib/cn": "./src/lib/cn.ts",
|
|
52
53
|
"./styles/tokens.css": "./src/styles/tokens.css"
|
|
53
54
|
},
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@ac/lib/cn";
|
|
4
|
+
|
|
5
|
+
const loaderVariants = cva(
|
|
6
|
+
"inline-flex items-center text-foreground",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
xs: "gap-1.5 text-xs",
|
|
11
|
+
sm: "gap-2 text-sm",
|
|
12
|
+
md: "gap-2 text-sm",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
size: "md",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const dotSizeClass: Record<NonNullable<VariantProps<typeof loaderVariants>["size"]>, string> = {
|
|
22
|
+
xs: "size-1",
|
|
23
|
+
sm: "size-[5px]",
|
|
24
|
+
md: "size-1.5",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type LoaderProps = HTMLAttributes<HTMLSpanElement> &
|
|
28
|
+
VariantProps<typeof loaderVariants> & {
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const Loader = forwardRef<HTMLSpanElement, LoaderProps>(
|
|
33
|
+
({ size, className, children, "aria-label": ariaLabel, ...rest }, ref) => {
|
|
34
|
+
const s = size ?? "md";
|
|
35
|
+
const dotCn = cn(
|
|
36
|
+
"inline-block rounded-full shrink-0",
|
|
37
|
+
"bg-accent text-accent [box-shadow:0_0_8px_currentColor]",
|
|
38
|
+
dotSizeClass[s],
|
|
39
|
+
);
|
|
40
|
+
return (
|
|
41
|
+
<span
|
|
42
|
+
ref={ref}
|
|
43
|
+
role="status"
|
|
44
|
+
aria-label={children ? undefined : (ariaLabel ?? "Loading")}
|
|
45
|
+
className={cn(loaderVariants({ size }), className)}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
<span aria-hidden="true" className="inline-flex shrink-0 gap-[3px]">
|
|
49
|
+
<span className={cn(dotCn, "animate-button-chase-a")} />
|
|
50
|
+
<span className={cn(dotCn, "animate-button-chase-b")} />
|
|
51
|
+
</span>
|
|
52
|
+
{children ? <span>{children}</span> : null}
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
Loader.displayName = "Loader";
|
|
59
|
+
|
|
60
|
+
export { Loader, loaderVariants, type LoaderProps };
|