@mbao01/common 0.0.5 → 0.0.7
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/README.md +1 -2
- package/dist/types/components/Avatar/Avatar.d.ts +14 -0
- package/dist/types/components/Avatar/constants.d.ts +15 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/types.d.ts +6 -0
- package/dist/types/components/Badge/Badge.d.ts +1 -1
- package/dist/types/components/Badge/constants.d.ts +5 -5
- package/dist/types/components/Badge/types.d.ts +3 -7
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
- package/dist/types/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +11 -2
- package/dist/types/components/Button/constants.d.ts +7 -8
- package/dist/types/components/Button/types.d.ts +6 -12
- package/dist/types/components/Card/Card.d.ts +1 -1
- package/dist/types/components/Card/constants.d.ts +6 -0
- package/dist/types/components/Card/types.d.ts +3 -18
- package/dist/types/components/Description/Description.d.ts +2 -2
- package/dist/types/components/Loading/Loading.d.ts +2 -0
- package/dist/types/components/Loading/constants.d.ts +5 -0
- package/dist/types/components/Loading/index.d.ts +1 -0
- package/dist/types/components/Loading/types.d.ts +3 -0
- package/dist/types/components/Progress/Progress.d.ts +5 -0
- package/dist/types/components/Progress/constants.d.ts +6 -0
- package/dist/types/components/Progress/index.d.ts +1 -0
- package/dist/types/components/Progress/types.d.ts +4 -0
- package/dist/types/components/Separator/Separator.d.ts +2 -0
- package/dist/types/components/Separator/constants.d.ts +3 -0
- package/dist/types/components/Separator/index.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +2 -0
- package/dist/types/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/Skeleton/constants.d.ts +6 -5
- package/dist/types/components/Skeleton/types.d.ts +3 -7
- package/dist/types/components/Text/Text.d.ts +2 -4
- package/dist/types/components/Text/constants.d.ts +4 -5
- package/dist/types/components/Text/types.d.ts +4 -9
- package/dist/types/components/Tooltip/Tooltip.d.ts +14 -2
- package/dist/types/components/Tooltip/constants.d.ts +6 -5
- package/dist/types/components/Tooltip/types.d.ts +5 -10
- package/dist/types/index.d.ts +5 -0
- package/dist/types/libs/cva.d.ts +1 -0
- package/dist/types/libs/index.d.ts +1 -0
- package/dist/types/utilities/cn.d.ts +2 -0
- package/dist/types/utilities/getSubpaths/getSubpaths.d.ts +6 -0
- package/dist/types/utilities/getSubpaths/index.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +2 -0
- package/package.json +14 -4
- package/plugin.js +1 -3
- package/src/components/Avatar/Avatar.tsx +59 -0
- package/src/components/Avatar/constants.ts +69 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +25 -0
- package/src/components/Badge/Badge.tsx +4 -14
- package/src/components/Badge/constants.ts +28 -30
- package/src/components/Badge/types.ts +4 -17
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +13 -0
- package/src/components/Breadcrumbs/index.ts +1 -0
- package/src/components/Breadcrumbs/types.ts +3 -0
- package/src/components/Button/Button.tsx +51 -37
- package/src/components/Button/constants.ts +39 -43
- package/src/components/Button/types.ts +7 -25
- package/src/components/Card/Card.tsx +9 -15
- package/src/components/Card/constants.ts +22 -0
- package/src/components/Card/types.ts +4 -18
- package/src/components/Description/Description.tsx +11 -6
- package/src/components/Loading/Loading.tsx +18 -0
- package/src/components/Loading/constants.ts +30 -0
- package/src/components/Loading/index.ts +1 -0
- package/src/components/Loading/types.ts +5 -0
- package/src/components/Progress/Progress.tsx +31 -0
- package/src/components/Progress/constants.ts +49 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/types.ts +9 -0
- package/src/components/Separator/Separator.tsx +20 -0
- package/src/components/Separator/constants.ts +10 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/types.ts +5 -0
- package/src/components/Skeleton/Skeleton.tsx +7 -11
- package/src/components/Skeleton/constants.ts +39 -37
- package/src/components/Skeleton/types.ts +4 -7
- package/src/components/Text/Text.tsx +24 -9
- package/src/components/Text/constants.ts +26 -28
- package/src/components/Text/types.ts +9 -20
- package/src/components/Tooltip/Tooltip.tsx +35 -21
- package/src/components/Tooltip/constants.ts +32 -31
- package/src/components/Tooltip/types.ts +13 -22
- package/src/index.ts +5 -0
- package/src/libs/cva.ts +1 -0
- package/src/libs/index.ts +1 -0
- package/src/utilities/cn.ts +6 -0
- package/src/utilities/getSubpaths/getSubpaths.ts +34 -0
- package/src/utilities/getSubpaths/index.ts +1 -0
- package/src/utilities/index.ts +2 -0
- package/vitest-setup.ts +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Avatar } from "./Avatar";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getAvatarClasses,
|
|
5
|
+
getAvatarFallbackClasses,
|
|
6
|
+
getAvatarImageClasses,
|
|
7
|
+
} from "./constants";
|
|
8
|
+
|
|
9
|
+
export type AvatarProps = Omit<
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
|
|
11
|
+
"asChild" | "size"
|
|
12
|
+
> &
|
|
13
|
+
VariantProps<typeof getAvatarClasses>;
|
|
14
|
+
|
|
15
|
+
export type AvatarImageProps = Omit<
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>,
|
|
17
|
+
"asChild"
|
|
18
|
+
> &
|
|
19
|
+
VariantProps<typeof getAvatarImageClasses>;
|
|
20
|
+
|
|
21
|
+
export type AvatarFallbackProps = Omit<
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>,
|
|
23
|
+
"asChild"
|
|
24
|
+
> &
|
|
25
|
+
VariantProps<typeof getAvatarFallbackClasses>;
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { cn } from "../../utilities";
|
|
2
2
|
import { getBadgeClasses } from "./constants";
|
|
3
3
|
import { type BadgeProps } from "./types";
|
|
4
4
|
|
|
5
5
|
export const Badge = ({
|
|
6
6
|
size,
|
|
7
7
|
outline,
|
|
8
|
-
variant
|
|
9
|
-
children,
|
|
8
|
+
variant,
|
|
10
9
|
className,
|
|
11
10
|
...props
|
|
12
11
|
}: BadgeProps) => {
|
|
13
12
|
return (
|
|
14
13
|
<span
|
|
14
|
+
className={cn(getBadgeClasses({ size, variant, outline }), className)}
|
|
15
15
|
{...props}
|
|
16
|
-
|
|
17
|
-
getBadgeClasses({ size, variant }),
|
|
18
|
-
{
|
|
19
|
-
"badge-outline": outline,
|
|
20
|
-
"text-base-200": !["ghost", "neutral"].includes(variant),
|
|
21
|
-
},
|
|
22
|
-
className
|
|
23
|
-
)}
|
|
24
|
-
>
|
|
25
|
-
{children}
|
|
26
|
-
</span>
|
|
16
|
+
/>
|
|
27
17
|
);
|
|
28
18
|
};
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { BadgeSize, BadgeVariant } from "./types";
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
};
|
|
3
|
+
export const getBadgeClasses = cva("badge", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
accent: "badge-accent",
|
|
7
|
+
error: "badge-error",
|
|
8
|
+
ghost: "badge-ghost",
|
|
9
|
+
info: "badge-info",
|
|
10
|
+
neutral: "badge-neutral",
|
|
11
|
+
primary: "badge-primary",
|
|
12
|
+
secondary: "badge-secondary",
|
|
13
|
+
success: "badge-success",
|
|
14
|
+
warning: "badge-warning",
|
|
15
|
+
},
|
|
16
|
+
outline: {
|
|
17
|
+
true: "badge-outline",
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
xs: "badge-xs",
|
|
21
|
+
sm: "badge-sm",
|
|
22
|
+
md: "badge-md",
|
|
23
|
+
lg: "badge-lg",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "ghost",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getBadgeClasses } from "./constants";
|
|
2
3
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
| "primary"
|
|
6
|
-
| "secondary"
|
|
7
|
-
| "accent"
|
|
8
|
-
| "ghost"
|
|
9
|
-
| "info"
|
|
10
|
-
| "success"
|
|
11
|
-
| "warning"
|
|
12
|
-
| "error";
|
|
13
|
-
|
|
14
|
-
export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
15
|
-
size?: BadgeSize;
|
|
16
|
-
outline?: boolean;
|
|
17
|
-
variant?: BadgeVariant;
|
|
18
|
-
};
|
|
4
|
+
export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> &
|
|
5
|
+
VariantProps<typeof getBadgeClasses>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BreadcrumbProps, BreadcrumbsProps } from "./types";
|
|
2
|
+
|
|
3
|
+
export const Breadcrumbs = (props: BreadcrumbsProps) => {
|
|
4
|
+
return (
|
|
5
|
+
<div className="breadcrumbs -ml-1 w-fit px-1 text-sm">
|
|
6
|
+
<ul {...props} />
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Breadcrumb = (props: BreadcrumbProps) => {
|
|
12
|
+
return <li {...props} />;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumbs } from "./Breadcrumbs";
|
|
@@ -1,40 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
3
|
import { type ButtonProps } from "./types";
|
|
4
|
+
import { getButtonClasses } from "./constants";
|
|
5
|
+
import { Loading } from "../Loading";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
|
|
8
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
9
|
+
(
|
|
10
|
+
{
|
|
11
|
+
as,
|
|
12
|
+
className,
|
|
13
|
+
outline,
|
|
14
|
+
children,
|
|
15
|
+
isLoading,
|
|
16
|
+
variant,
|
|
17
|
+
size,
|
|
18
|
+
wide,
|
|
19
|
+
...props
|
|
20
|
+
},
|
|
21
|
+
ref
|
|
22
|
+
) => {
|
|
23
|
+
const Comp = as ? Slot : "button";
|
|
24
|
+
const SlotChild = as ? as : React.Fragment;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Comp
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cn(
|
|
30
|
+
getButtonClasses({ size, wide, outline, variant, isLoading }),
|
|
31
|
+
className
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
{/* slot merges it's prop into it's immediate child */}
|
|
36
|
+
<SlotChild>
|
|
37
|
+
{children}
|
|
38
|
+
{isLoading ? (
|
|
39
|
+
<span
|
|
40
|
+
className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
|
|
41
|
+
data-testid="loading"
|
|
42
|
+
>
|
|
43
|
+
<Loading />
|
|
44
|
+
</span>
|
|
45
|
+
) : null}
|
|
46
|
+
</SlotChild>
|
|
47
|
+
</Comp>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
4
51
|
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
className,
|
|
8
|
-
outline,
|
|
9
|
-
label,
|
|
10
|
-
disabled,
|
|
11
|
-
onClick,
|
|
12
|
-
loading,
|
|
13
|
-
variant,
|
|
14
|
-
size,
|
|
15
|
-
wide,
|
|
16
|
-
...rest
|
|
17
|
-
} = props;
|
|
52
|
+
Button.displayName = "Button";
|
|
18
53
|
|
|
19
|
-
|
|
20
|
-
<button
|
|
21
|
-
{...rest}
|
|
22
|
-
onClick={onClick}
|
|
23
|
-
disabled={disabled}
|
|
24
|
-
className={c(
|
|
25
|
-
getButtonClasses({ size, wide, outline, variant, loading }),
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
>
|
|
29
|
-
{label}
|
|
30
|
-
{loading ? (
|
|
31
|
-
<span
|
|
32
|
-
className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
|
|
33
|
-
data-testid="loading"
|
|
34
|
-
>
|
|
35
|
-
<span className="loading loading-spinner" />
|
|
36
|
-
</span>
|
|
37
|
-
) : null}
|
|
38
|
-
</button>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
54
|
+
export { Button };
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ButtonSize, ButtonVariant } from './types';
|
|
1
|
+
import { cva } from "../../libs";
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'min-h-fit h-10': !size,
|
|
43
|
-
});
|
|
44
|
-
};
|
|
3
|
+
export const getButtonClasses = cva("btn", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
accent: "btn-accent",
|
|
7
|
+
default: "btn-default",
|
|
8
|
+
error: "btn-error",
|
|
9
|
+
ghost: "btn-ghost",
|
|
10
|
+
info: "btn-info",
|
|
11
|
+
link: "btn-link",
|
|
12
|
+
neutral: "btn-neutral",
|
|
13
|
+
primary: "btn-primary",
|
|
14
|
+
secondary: "btn-secondary",
|
|
15
|
+
success: "btn-success",
|
|
16
|
+
warning: "btn-warning",
|
|
17
|
+
},
|
|
18
|
+
outline: {
|
|
19
|
+
true: "btn-outline",
|
|
20
|
+
},
|
|
21
|
+
wide: {
|
|
22
|
+
true: "btn-wide",
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
xs: "btn-xs",
|
|
26
|
+
sm: "btn-sm",
|
|
27
|
+
md: "btn-md",
|
|
28
|
+
lg: "btn-lg",
|
|
29
|
+
},
|
|
30
|
+
isLoading: {
|
|
31
|
+
true: "relative overflow-hidden",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
compoundVariants: [
|
|
35
|
+
{
|
|
36
|
+
size: undefined,
|
|
37
|
+
className: "min-h-fit h-10",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { type ButtonHTMLAttributes } from "react";
|
|
3
|
+
import { getButtonClasses } from "./constants";
|
|
2
4
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| 'neutral'
|
|
8
|
-
| 'primary'
|
|
9
|
-
| 'secondary'
|
|
10
|
-
| 'accent'
|
|
11
|
-
| 'ghost'
|
|
12
|
-
| 'link'
|
|
13
|
-
| 'info'
|
|
14
|
-
| 'success'
|
|
15
|
-
| 'warning'
|
|
16
|
-
| 'error';
|
|
17
|
-
|
|
18
|
-
export type ButtonProps = {
|
|
19
|
-
size?: ButtonSize;
|
|
20
|
-
wide?: boolean;
|
|
21
|
-
label: ReactNode;
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
outline?: boolean;
|
|
24
|
-
variant?: ButtonVariant;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
} & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
5
|
+
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
|
|
6
|
+
VariantProps<typeof getButtonClasses> & {
|
|
7
|
+
as?: keyof Pick<JSX.IntrinsicElements, "a" | "span" | "p">;
|
|
8
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type {
|
|
3
2
|
CardContentProps,
|
|
4
3
|
CardDescriptionProps,
|
|
5
4
|
CardFooterProps,
|
|
@@ -7,6 +6,8 @@ import {
|
|
|
7
6
|
CardImageProps,
|
|
8
7
|
CardProps,
|
|
9
8
|
} from "./types";
|
|
9
|
+
import { cn } from "../../utilities";
|
|
10
|
+
import { getCardClasses } from "./constants";
|
|
10
11
|
|
|
11
12
|
const Card = ({
|
|
12
13
|
compact,
|
|
@@ -17,15 +18,8 @@ const Card = ({
|
|
|
17
18
|
...props
|
|
18
19
|
}: CardProps) => (
|
|
19
20
|
<div
|
|
20
|
-
className={
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"card-bordered": bordered,
|
|
24
|
-
"card-compact": compact,
|
|
25
|
-
"card-normal": !compact,
|
|
26
|
-
"image-full": overlay,
|
|
27
|
-
"card-side": horizontal,
|
|
28
|
-
},
|
|
21
|
+
className={cn(
|
|
22
|
+
getCardClasses({ bordered, compact, horizontal, overlay }),
|
|
29
23
|
className
|
|
30
24
|
)}
|
|
31
25
|
{...props}
|
|
@@ -33,15 +27,15 @@ const Card = ({
|
|
|
33
27
|
);
|
|
34
28
|
|
|
35
29
|
const CardHeader = ({ className, ...props }: CardHeaderProps) => (
|
|
36
|
-
<h3 className={
|
|
30
|
+
<h3 className={cn("card-title", className)} {...props} />
|
|
37
31
|
);
|
|
38
32
|
|
|
39
33
|
const CardDescription = ({ className, ...props }: CardDescriptionProps) => (
|
|
40
|
-
<p className={
|
|
34
|
+
<p className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
41
35
|
);
|
|
42
36
|
|
|
43
37
|
const CardContent = ({ className, ...props }: CardContentProps) => (
|
|
44
|
-
<div className={
|
|
38
|
+
<div className={cn("card-body p-6 pt-0", className)} {...props} />
|
|
45
39
|
);
|
|
46
40
|
|
|
47
41
|
const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
|
|
@@ -51,7 +45,7 @@ const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
|
|
|
51
45
|
);
|
|
52
46
|
|
|
53
47
|
const CardFooter = ({ className, ...props }: CardFooterProps) => (
|
|
54
|
-
<div className={
|
|
48
|
+
<div className={cn("card-actions", className)} {...props} />
|
|
55
49
|
);
|
|
56
50
|
|
|
57
51
|
Card.Header = CardHeader;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getCardClasses = cva("card", {
|
|
4
|
+
variants: {
|
|
5
|
+
bordered: {
|
|
6
|
+
true: "card-bordered",
|
|
7
|
+
},
|
|
8
|
+
compact: {
|
|
9
|
+
true: "card-compact",
|
|
10
|
+
false: "card-normal",
|
|
11
|
+
},
|
|
12
|
+
horizontal: {
|
|
13
|
+
true: "card-side",
|
|
14
|
+
},
|
|
15
|
+
overlay: {
|
|
16
|
+
true: "image-full",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
compact: false,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getCardClasses } from "./constants";
|
|
2
4
|
|
|
3
|
-
export type CardProps =
|
|
4
|
-
|
|
5
|
-
* applies smaller padding to the card.
|
|
6
|
-
*/
|
|
7
|
-
compact?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* applies border to the card.
|
|
10
|
-
*/
|
|
11
|
-
bordered?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* shows the card horizontally with image to the right or left of it.
|
|
14
|
-
*/
|
|
15
|
-
horizontal?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* overlay is used to make the image full width with the content on top.
|
|
18
|
-
*/
|
|
19
|
-
overlay?: boolean;
|
|
20
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
export type CardProps = React.HTMLAttributes<HTMLDivElement> &
|
|
6
|
+
VariantProps<typeof getCardClasses>;
|
|
21
7
|
|
|
22
8
|
export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
|
|
23
9
|
export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import c from "clsx";
|
|
2
1
|
import type {
|
|
3
2
|
DescriptionProps,
|
|
4
3
|
DescriptionTermProps,
|
|
5
4
|
DescriptionDetailProps,
|
|
6
5
|
} from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
7
|
|
|
8
8
|
const Description = (props: DescriptionProps) => {
|
|
9
9
|
return <dl role="list" {...props} />;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const DescriptionTerm = (props: DescriptionTermProps) => {
|
|
12
|
+
const DescriptionTerm = ({ className, ...props }: DescriptionTermProps) => {
|
|
13
13
|
return (
|
|
14
14
|
<dt
|
|
15
|
-
{...props}
|
|
16
15
|
role="listitem"
|
|
17
|
-
className={
|
|
16
|
+
className={cn("py-2 text-sm font-semibold", className)}
|
|
17
|
+
{...props}
|
|
18
18
|
/>
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const DescriptionDetail = (props: DescriptionDetailProps) => {
|
|
23
|
-
return
|
|
22
|
+
const DescriptionDetail = ({ className, ...props }: DescriptionDetailProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<dd
|
|
25
|
+
className={cn("text-base [&:not(:last-child)]:mb-1", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
Description.Term = DescriptionTerm;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getLoadingClasses } from "./constants";
|
|
2
|
+
import { type LoadingProps } from "./types";
|
|
3
|
+
import { cn } from "../../utilities";
|
|
4
|
+
|
|
5
|
+
export const Loading = ({
|
|
6
|
+
size,
|
|
7
|
+
intent,
|
|
8
|
+
variant,
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: LoadingProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<span
|
|
14
|
+
className={cn(getLoadingClasses({ intent, size, variant }), className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getLoadingClasses = cva("loading", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
spinner: "loading-spinner",
|
|
7
|
+
dots: "loading-dots",
|
|
8
|
+
ring: "loading-ring",
|
|
9
|
+
ball: "loading-ball",
|
|
10
|
+
bars: "loading-bars",
|
|
11
|
+
infinity: "loading-infinity",
|
|
12
|
+
},
|
|
13
|
+
intent: {
|
|
14
|
+
primary: "text-primary",
|
|
15
|
+
secondary: "text-secondary",
|
|
16
|
+
accent: "text-accent",
|
|
17
|
+
neutral: "text-neutral",
|
|
18
|
+
info: "text-info",
|
|
19
|
+
success: "text-success",
|
|
20
|
+
warning: "text-warning",
|
|
21
|
+
error: "text-error",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
xs: "loading-xs",
|
|
25
|
+
sm: "loading-sm",
|
|
26
|
+
md: "loading-md",
|
|
27
|
+
lg: "loading-lg",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Loading } from "./Loading";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
5
|
+
import { type ProgressProps } from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { getProgressClasses, getProgressIndicatorClasses } from "./constants";
|
|
8
|
+
|
|
9
|
+
export const Progress = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
11
|
+
ProgressProps
|
|
12
|
+
>(({ className, value, max = 100, variant, ...props }, ref) => (
|
|
13
|
+
<ProgressPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
max={max}
|
|
16
|
+
value={value}
|
|
17
|
+
className={cn(getProgressClasses({ variant }), className)}
|
|
18
|
+
{...props}
|
|
19
|
+
>
|
|
20
|
+
<ProgressPrimitive.Indicator
|
|
21
|
+
className={cn(getProgressIndicatorClasses({ variant }))}
|
|
22
|
+
style={{
|
|
23
|
+
transform: `translateX(-${
|
|
24
|
+
(100 * (max - Math.max(Math.min(value ?? 0, max), 0))) / max
|
|
25
|
+
}%)`,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</ProgressPrimitive.Root>
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getProgressClasses = cva(
|
|
4
|
+
"relative h-2 w-full overflow-hidden rounded-full",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "bg-accent/20",
|
|
9
|
+
base: "bg-base-content/20",
|
|
10
|
+
error: "bg-error/20",
|
|
11
|
+
ghost: "bg-ghost/20",
|
|
12
|
+
info: "bg-info/20",
|
|
13
|
+
link: "bg-link/20",
|
|
14
|
+
neutral: "bg-neutral/20",
|
|
15
|
+
primary: "bg-primary/20",
|
|
16
|
+
secondary: "bg-secondary/20",
|
|
17
|
+
success: "bg-success/20",
|
|
18
|
+
warning: "bg-warning/20",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "base",
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const getProgressIndicatorClasses = cva(
|
|
28
|
+
"h-full w-full flex-1 transition-all",
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
variant: {
|
|
32
|
+
accent: "bg-accent",
|
|
33
|
+
base: "bg-base-content",
|
|
34
|
+
error: "bg-error",
|
|
35
|
+
ghost: "bg-ghost",
|
|
36
|
+
info: "bg-info",
|
|
37
|
+
link: "bg-link",
|
|
38
|
+
neutral: "bg-neutral",
|
|
39
|
+
primary: "bg-primary",
|
|
40
|
+
secondary: "bg-secondary",
|
|
41
|
+
success: "bg-success",
|
|
42
|
+
warning: "bg-warning",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
variant: "base",
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
);
|